diff --git a/nodejs/openai/sample-agent/package.json b/nodejs/openai/sample-agent/package.json index 54c778f0..a07a3777 100644 --- a/nodejs/openai/sample-agent/package.json +++ b/nodejs/openai/sample-agent/package.json @@ -24,7 +24,8 @@ "@microsoft/agents-a365-tooling": "^0.1.0-preview.30", "@microsoft/agents-a365-tooling-extensions-openai": "^0.1.0-preview.30", "@microsoft/agents-a365-observability-extensions-openai": "^0.1.0-preview.30", - "@openai/agents": "0.1.11", + "@openai/agents": "^0.1.11", + "openai": "^4.77.0", "dotenv": "^17.2.2", "express": "^5.1.0" }, @@ -36,11 +37,10 @@ "rimraf": "^5.0.0", "ts-node": "^10.9.2", "typescript": "^5.9.2" - } - , - "pnpm": { - "overrides": { - "@openai/agents-core": "0.1.11" - } + }, + "overrides": { + "@openai/agents-core": "$@openai/agents", + "@openai/agents-openai": "$@openai/agents", + "openai": "$openai" } } diff --git a/nodejs/openai/sample-agent/src/client.ts b/nodejs/openai/sample-agent/src/client.ts index 56e05908..afd23b81 100644 --- a/nodejs/openai/sample-agent/src/client.ts +++ b/nodejs/openai/sample-agent/src/client.ts @@ -1,6 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +// IMPORTANT: Load environment variables FIRST before any other imports +// This ensures AZURE_OPENAI_* and other config is available when packages initialize +import { configDotenv } from 'dotenv'; +configDotenv(); + import { Agent, run } from '@openai/agents'; import { Authorization, TurnContext } from '@microsoft/agents-hosting'; diff --git a/nodejs/openai/sample-agent/src/index.ts b/nodejs/openai/sample-agent/src/index.ts index 9977ff36..cbf77dae 100644 --- a/nodejs/openai/sample-agent/src/index.ts +++ b/nodejs/openai/sample-agent/src/index.ts @@ -1,7 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -// Note: dotenv is loaded in agent.ts before AgentApplication is instantiated +// IMPORTANT: Load environment variables FIRST before any other imports +// This ensures all config is available when packages initialize at import time +import { configDotenv } from 'dotenv'; +configDotenv(); import { AuthConfiguration, authorizeJWT, CloudAdapter, loadAuthConfigFromEnv, Request } from '@microsoft/agents-hosting'; import express, { Response } from 'express'