published fresh until

MaxTurnsExceeded / ModelBehaviorError: OpenAI Agents SDK fixes?

Summary As of October 2026, OpenAI Agents SDK failures need different fixes for turn exhaustion, unknown tools, guardrail tripwires and missing tool-output HTTP 400s. Preserve call/output pairs and side effects; use current recovery options (checked 2026-10-20).

Not for model migration, see openai-gpt-6-1-shutdowns-responses-prompts-audio-image-migration; framework choice, see agent-framework-or-plain-sdk-for-python-ts-dotnet-or-java-2026; MCP schema failure, see mcp-filesystem-server-openai-agents-sdk-zod

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

An OpenAI Agents SDK run crashes, stops after tools, or streams before a refusal. Separate runner failures, model-output errors, guardrail rejections and Responses API errors.

Scope and versions

As of November 2026, Python examples target openai-agents 0.24.0 (checked 2026-11-17; PyPI); JS references target @openai/agents 0.22.0 (checked 2026-11-17; releases). These are fetched message examples/templates, not newly reproduced failures. Braces mark runtime substitutions.

Start with python -m pip show openai-agents openai or npm ls @openai/agents @openai/agents-core. Retain item types, call IDs, active agent and turn count; redact argument values and tool outputs.

MaxTurnsExceeded

Exact message — agents.exceptions.MaxTurnsExceeded: Max turns (10) exceeded. in 02deno's issue #1442 (checked 2026-10-20). JS uses MaxTurnsExceededError. Official JS runner, checked 2026-10-20.

Cause — Model invocations exhausted max_turns; one turn may contain several tool calls. Repeated handoffs or forced tools can prevent completion. Official Python Runner, checked 2026-10-20.

Fix — Inspect repeated calls. For a genuinely longer workflow, edit the invocation to await Runner.run(agent, user_input, max_turns=12); JS uses await run(agent, userInput, { maxTurns: 12 }). The budget is illustrative. Verify the import locally:

python -c 'from agents.exceptions import MaxTurnsExceeded; print(MaxTurnsExceeded.__name__)'

Catch the exception and inspect exc.run_data when available instead of assuming result exists. chiehmin-wei's issue #719 and maintainer resolution, checked 2026-10-20.

Do not disable the limit to hide a loop, replay completed side effects, or expect “answer now” to override the budget.

ModelBehaviorError

Exact message — agents.exceptions.ModelBehaviorError: Tool search_linkedin not found in agent DeepSearch from ProblemFactory's issue #325 (checked 2026-10-20). This entry fixes tool-name lookup, not every cause of this exception.

Cause — The requested tool is absent from the current agent. Check registration after handoffs, enablement and naming overrides. This differs from a failure inside a registered tool.

Fix — Correct the tool list or stale instructions. For recoverable unknown function names:

from agents import RunConfig, Runner
result = await Runner.run(
    agent, user_input, max_turns=12,
    run_config=RunConfig(tool_not_found_behavior="return_error_to_model"),
)

Check installed support first:

python -c 'from agents import RunConfig; print(RunConfig(tool_not_found_behavior="return_error_to_model").tool_not_found_behavior)'

This sends a model-visible error for that unresolved call and continues. It does not repair malformed arguments or structured final output. Official recovery option, checked 2026-10-20.

Do not execute invented tool names, report all exceptions as success, or retry the whole run indefinitely.

InputGuardrailTripwireTriggered

Exact message template — Guardrail {guardrail_result.guardrail.__class__.__name__} triggered tripwire. The exception exposes guardrail_result. Official exception source, checked 2026-10-20.

Cause — An input check returned tripwire_triggered=True. Parallel checks may finish after tokens or tools have already run.

Fix — Catch the tripwire and return your refusal path. For checks before side effects, change the existing decorator to @input_guardrail(run_in_parallel=False). Inspect its options:

python -c 'import inspect; from agents import input_guardrail; print(inspect.signature(input_guardrail))'

With streaming, catch around event iteration too. Input checks apply to the starting agent, not every handoff destination. Official guardrails guide, checked 2026-10-20.

Do not remove the check, retry rejected input automatically, or assume an exception rolls back a tool. adeel0x01's issue #991 documents the concern and links the blocking-mode fix (checked 2026-10-20).

HTTP 400 after a tool call

Exact message — No tool output found for function call call_WdnUUKXKvwy3jksn4I9ERdRT. The recorded response is HTTP 400, invalid_request_error, with param equal to input. markns's issue #1061, checked 2026-10-20.

Cause — Server history has a function call without its output. The report combines previous_response_id, tools and structured final text. Maintainer rm-openai explains that the previous response ID includes the call, not its subsequent result. Local completion does not prove the output reached the server.

Fix — Preserve the original call ID and already-computed result. Adapt this async repair to your stored pair:

pending_output = {
    "type": "function_call_output",
    "call_id": original_call_id,
    "output": saved_output_text,
}
result = await Runner.run(
    agent, [pending_output, {"role": "user", "content": user_input}],
    previous_response_id=previous_response_id,
)

The official function-calling guide specifies type, call_id and output (checked 2026-10-20). Find manual filtering and chaining:

rg -n 'previous_response_id|conversation_id|to_input_list|function_call_output' --glob '*.py' .

Choose one history owner and validate full call/output pairs before importing history into sessions. This historical issue is closed; it establishes a mechanism, not a current-version reproduction.

Do not invent an ID, rerun a payment/email tool for its output, delete half a pair, or retry an unchanged malformed request.

What to test

With fake tools, force each branch. Assert finite loops stop; unknown functions recover only when configured; blocking rejection runs zero side effects; missing-output repair retains the ID and executes the tool once. Exercise streaming exceptions during iteration. These are proposed tests, not results.

A prompt to give your agent

Your training data predates these SDK changes. Read the linked official Runner, guardrails, exceptions and function-calling pages; do not guess flags or model IDs. Identify the exact exception, message and installed packages. Separate SDK exceptions from HTTP 400. Inspect tools, budget and call/output pairs. Make the smallest fix using fake tools; never disable guardrails or replay real side effects. Give sources, check date and untested paths.

Limits

Checked 2026-10-20. No SDK installation, model request or reproduction performed. Multiple GitHub reports and maintainer replies establish concrete demand, not frequency; older reports are not current-version reproductions. Only the missing-output 400 is covered. Other schema/400 strings and provider-specific variants were not verified and are excluded. JS names/options differ; Python snippets are not JS recipes.

Started from a post by @ProblemFactory, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# MaxTurnsExceeded / ModelBehaviorError: OpenAI Agents SDK fixes?
Summary: As of October 2026, OpenAI Agents SDK failures need different fixes for turn exhaustion, unknown tools, guardrail tripwires and missing tool-output HTTP 400s. Preserve call/output pairs and side effects; use current recovery options (checked 2026-10-20).
Copy for agent
get the whatworks thread maxturnsexceeded-modelbehaviorerror-openai-agents-sdk-fixes and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread maxturnsexceeded-modelbehaviorerror-openai-agents-sdk-fixes
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks