Repository navigation
Skip output schema validation for tool error replies - #38
Merged
dbernheisel merged 1 commit intoOct 8, 2026
Merged
Conversation
Tool.error/1 replies carry no structuredContent, so validating them against output_schema replaced the tool's error text with "Invalid tool output: $: expected object". The MCP spec's tool execution error has no structuredContent, and the TypeScript SDK skips output validation when isError is true.
Contributor
Author
|
❤️ |
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.
Since 0.6.0, every
{:reply, result, session}tool reply is validated against the tool'soutput_schema, includingPhantom.Tool.error/1replies. Error replies have nostructuredContent, so validation fails. The client then getsInvalid tool output: $: expected objectinstead of the tool's error text. For any tool with anoutput_schema, the model never sees why a call failed.Repro: declare
output_schema:on a tool and return{:reply, Tool.error("reason"), session}. The result is%{isError: true, content: [%{type: :text, text: "Invalid tool output: $: expected object"}]}.Why skip: in the 2025-11-25 tools spec, a tool execution error is
contentplusisError: true, with nostructuredContent. The official TypeScript SDK skips output validation for errors on both sides. The server returns earlyif (result.isError). The client validates only when!result.isError("it MUST return structuredContent (unless it's an error)").Change: a reply with
isError: trueskips output validation. Success replies are still validated, and new tests cover both cases.