Skip to content

fix: #2061 handle invalid tool arguments JSON without crashing - #2337

Merged
seratch merged 3 commits into
mainfrom
fix/handle-invalid-tool-args-json
Jan 20, 2026
Merged

fix: #2061 handle invalid tool arguments JSON without crashing#2337
seratch merged 3 commits into
mainfrom
fix/handle-invalid-tool-args-json

Conversation

@seratch

@seratch seratch commented Jan 20, 2026

Copy link
Copy Markdown
Member

This pull request fixes the tool execution flow to handle malformed JSON arguments gracefully instead of raising and crashing. It adds an early JSON parse check in src/agents/_run_impl.py to return a user-friendly tool output, while still emitting tool hooks and output guardrails, and records the parse error in tracing. Tests in tests/test_tracing_errors.py and tests/test_tracing_errors_streamed.py are updated to assert the new tool output and tracing payload.

Resolves #2061
See also: openai/openai-agents-js#887

@seratch seratch added this to the 0.6.x milestone Jan 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbe0c64b59

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/_run_impl.py Outdated
@seratch
seratch merged commit cdc0ad6 into main Jan 20, 2026
9 checks passed
@seratch
seratch deleted the fix/handle-invalid-tool-args-json branch January 20, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid JSON in tool call arguments breaks session with Anthropic models

1 participant