Repository navigation
fix(AIC-3586): propagate tool handler errors instead of sending them to the model - #139
Merged
Merged
Conversation
…them to the model @openai/agents' tool() catches an execute() error and returns it to the model as the tool result unless errorFunction is null, so a failing tool handler never failed the run. TESTING.md §1.4 requires the error to propagate. Set errorFunction: null in both the handler and the native graph adapter. The existing test called a mocked tool's execute() directly, which skips the SDK's wrapper. The new tests build the tool with the real tool() and fail without this fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jeffdupont
marked this pull request as ready for review
October 15, 2026 20:55
raskara-LD
approved these changes
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes AIC-3586.
Problem
openai-agentsbuilds each tool with@openai/agents'tool()and leaveserrorFunctionunset. When it's unset, the SDK catches an error thrown byexecute()and returns"An error occurred while running the tool. Please try again. Error: ..."to the model as the tool result. So a failing tool handler never fails the run: the model gets the error text and keeps going, and the caller never sees the error.The shared spec says the opposite: TESTING.md §1.4, "The handler must propagate the error (not swallow it silently)." Python and Go already propagate.
Fix
errorFunction: nullon bothtool()calls:src/handler.tsandsrc/native-graph.ts.handler.test.tsand innative-graph.test.ts. Each passes the handler's arguments to the realtool()and checks thatinvoke()rejects. The existing test mockstool()and calls the rawexecute, which skips the SDK's error wrapper, so it couldn't catch this.agents.md: the tool example showserrorFunction: null, plus a pitfall note on why it's needed.Testing
openai-agentstests pass;tscandbiomeare clean.promise resolved "An error occurred while running the t…" instead of rejecting.Not covered: a full
run()against a fake model. The tests stop attool.invoke.🤖 Generated with Claude Code
Note
Overview
Sets
errorFunction: nullon every@openai/agentstool()built in the single-agent handler (buildAgentTools) and the native graph adapter (buildNodeTools). Without it, the SDK turns handler failures into a tool result string for the model and the run continues; with it, errors reject per TESTING.md §1.4 (aligned with Python/Go).Adds integration-style tests in
handler.test.tsandnative-graph.test.tsthat rebuild tools with the real SDKtool()and assertinvoke()rejects—mock-onlyexecutetests miss the SDK wrapper.agents.mddocuments the option in the wiring example and a common pitfall.Reviewed by Cursor Bugbot for commit 82d1fc3. Bugbot is set up for automated code reviews on this repo. Configure here.