-
Notifications
You must be signed in to change notification settings - Fork 286
Closed
Labels
Description
There is an .env file with GOOGLE_GENERATIVE_AI_API_KEY already set:
import { Agent, run } from '@openai/agents';
import { google } from '@ai-sdk/google';
import { aisdk } from '@openai/agents-extensions';
import { setTracingDisabled } from '@openai/agents';
import dotenv from 'dotenv';
dotenv.config();
setTracingDisabled(true);
// Initialize Gemini model via Vercel AI SDK
const model = aisdk(google('gemini-2.0-flash'));
// Pass an `instructions` string to the Agent constructor
const agent = new Agent({
name: 'My Agent',
instructions: 'You are a helpful assistant.',
model,
});
(async () => {
const result = await run(agent, 'What is the capital of France?');
console.log(result.finalOutput);
})();
I am continuously getting maxTurnsExceeded error (below) even though the message is so simple!!!
C:\Users\mhamz\OneDrive\Documents\New folder>node app.js
(node:6488) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/app.js is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to C:\Users\mhamz\OneDrive\Documents\New folder\package.json.
(Use `node --trace-warnings ...` to show where the warning was created)
[dotenv@17.2.1] injecting env (1) from .env -- tip: 📡 version env with Radar: https://dotenvx.com/radar
Unhandled rejection MaxTurnsExceededError: Max turns (10) exceeded
at file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:135:35
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/tracing/context.mjs:45:24
at async run (file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:546:16)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/app.js:21:18 {
state: RunState {
_currentTurn: 11,
_currentAgent: Agent {
eventEmitter: [EventEmitter],
name: 'My Agent',
instructions: 'You are a helpful assistant.',
prompt: undefined,
handoffDescription: '',
handoffs: [],
model: AiSdkModel {},
modelSettings: {},
tools: [],
mcpServers: [],
inputGuardrails: [],
outputGuardrails: [],
outputType: 'text',
toolUseBehavior: 'run_llm_again',
resetToolChoice: true
},
_originalInput: 'What is the capital of France?',
_modelResponses: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object]
],
_currentAgentSpan: NoopSpan { type: 'trace.span' },
_context: RunContext { context: {}, usage: [Usage] },
_toolUseTracker: AgentToolUseTracker {},
_generatedItems: [],
_maxTurns: 10,
_noActiveAgentRun: false,
_lastTurnResponse: {
responseId: 'FAKE_ID',
usage: [Usage],
output: [],
providerData: [Object]
},
_inputGuardrailResults: [],
_outputGuardrailResults: [],
_currentStep: { type: 'next_step_run_again' },
_lastProcessedResponse: {
newItems: [],
handoffs: [],
functions: [],
computerActions: [],
mcpApprovalRequests: [],
toolsUsed: [],
hasToolsOrApprovalsToRun: [Function: hasToolsOrApprovalsToRun]
},
_trace: Trace {
type: 'trace',
traceId: 'trace_ea02b260e3d1489ea3e3108f33e2cb2e',
name: 'Agent workflow',
groupId: null,
metadata: {}
}
}
} Promise {
<rejected> MaxTurnsExceededError: Max turns (10) exceeded
at file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:135:35
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/tracing/context.mjs:45:24
at async run (file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:546:16)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/app.js:21:18 {
state: RunState {
_currentTurn: 11,
_currentAgent: [Agent],
_originalInput: 'What is the capital of France?',
_modelResponses: [Array],
_currentAgentSpan: [NoopSpan],
_context: [RunContext],
_toolUseTracker: AgentToolUseTracker {},
_generatedItems: [],
_maxTurns: 10,
_noActiveAgentRun: false,
_lastTurnResponse: [Object],
_inputGuardrailResults: [],
_outputGuardrailResults: [],
_currentStep: [Object],
_lastProcessedResponse: [Object],
_trace: [Trace]
}
}
}
Unhandled rejection MaxTurnsExceededError: Max turns (10) exceeded
at file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:135:35
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/tracing/context.mjs:45:24
at async run (file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:546:16)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/app.js:21:18 {
state: RunState {
_currentTurn: 11,
_currentAgent: Agent {
eventEmitter: [EventEmitter],
name: 'My Agent',
instructions: 'You are a helpful assistant.',
prompt: undefined,
handoffDescription: '',
handoffs: [],
model: AiSdkModel {},
modelSettings: {},
tools: [],
mcpServers: [],
inputGuardrails: [],
outputGuardrails: [],
outputType: 'text',
toolUseBehavior: 'run_llm_again',
resetToolChoice: true
},
_originalInput: 'What is the capital of France?',
_modelResponses: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object]
],
_currentAgentSpan: NoopSpan { type: 'trace.span' },
_context: RunContext { context: {}, usage: [Usage] },
_toolUseTracker: AgentToolUseTracker {},
_generatedItems: [],
_maxTurns: 10,
_noActiveAgentRun: false,
_lastTurnResponse: {
responseId: 'FAKE_ID',
usage: [Usage],
output: [],
providerData: [Object]
},
_inputGuardrailResults: [],
_outputGuardrailResults: [],
_currentStep: { type: 'next_step_run_again' },
_lastProcessedResponse: {
newItems: [],
handoffs: [],
functions: [],
computerActions: [],
mcpApprovalRequests: [],
toolsUsed: [],
hasToolsOrApprovalsToRun: [Function: hasToolsOrApprovalsToRun]
},
_trace: Trace {
type: 'trace',
traceId: 'trace_ea02b260e3d1489ea3e3108f33e2cb2e',
name: 'Agent workflow',
groupId: null,
metadata: {}
}
}
} Promise {
<rejected> MaxTurnsExceededError: Max turns (10) exceeded
at file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:135:35
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/tracing/context.mjs:45:24
at async run (file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:546:16)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/app.js:21:18 {
state: RunState {
_currentTurn: 11,
_currentAgent: [Agent],
_originalInput: 'What is the capital of France?',
_modelResponses: [Array],
_currentAgentSpan: [NoopSpan],
_context: [RunContext],
_toolUseTracker: AgentToolUseTracker {},
_generatedItems: [],
_maxTurns: 10,
_noActiveAgentRun: false,
_lastTurnResponse: [Object],
_inputGuardrailResults: [],
_outputGuardrailResults: [],
_currentStep: [Object],
_lastProcessedResponse: [Object],
_trace: [Trace]
}
}
}
Unhandled rejection MaxTurnsExceededError: Max turns (10) exceeded
at file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:135:35
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/tracing/context.mjs:45:24
at async run (file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:546:16)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/app.js:21:18 {
state: RunState {
_currentTurn: 11,
_currentAgent: Agent {
eventEmitter: [EventEmitter],
name: 'My Agent',
instructions: 'You are a helpful assistant.',
prompt: undefined,
handoffDescription: '',
handoffs: [],
model: AiSdkModel {},
modelSettings: {},
tools: [],
mcpServers: [],
inputGuardrails: [],
outputGuardrails: [],
outputType: 'text',
toolUseBehavior: 'run_llm_again',
resetToolChoice: true
},
_originalInput: 'What is the capital of France?',
_modelResponses: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object]
],
_currentAgentSpan: NoopSpan { type: 'trace.span' },
_context: RunContext { context: {}, usage: [Usage] },
_toolUseTracker: AgentToolUseTracker {},
_generatedItems: [],
_maxTurns: 10,
_noActiveAgentRun: false,
_lastTurnResponse: {
responseId: 'FAKE_ID',
usage: [Usage],
output: [],
providerData: [Object]
},
_inputGuardrailResults: [],
_outputGuardrailResults: [],
_currentStep: { type: 'next_step_run_again' },
_lastProcessedResponse: {
newItems: [],
handoffs: [],
functions: [],
computerActions: [],
mcpApprovalRequests: [],
toolsUsed: [],
hasToolsOrApprovalsToRun: [Function: hasToolsOrApprovalsToRun]
},
_trace: Trace {
type: 'trace',
traceId: 'trace_ea02b260e3d1489ea3e3108f33e2cb2e',
name: 'Agent workflow',
groupId: null,
metadata: {}
}
}
} Promise {
<rejected> MaxTurnsExceededError: Max turns (10) exceeded
at file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:135:35
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/tracing/context.mjs:45:24
at async run (file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/node_modules/@openai/agents/node_modules/@openai/agents-core/dist/run.mjs:546:16)
at async file:///C:/Users/mhamz/OneDrive/Documents/New%20folder/app.js:21:18 {
state: RunState {
_currentTurn: 11,
_currentAgent: [Agent],
_originalInput: 'What is the capital of France?',
_modelResponses: [Array],
_currentAgentSpan: [NoopSpan],
_context: [RunContext],
_toolUseTracker: AgentToolUseTracker {},
_generatedItems: [],
_maxTurns: 10,
_noActiveAgentRun: false,
_lastTurnResponse: [Object],
_inputGuardrailResults: [],
_outputGuardrailResults: [],
_currentStep: [Object],
_lastProcessedResponse: [Object],
_trace: [Trace]
}
}
}