Repository navigation
fix(mcp): preserve server error reasons for structured tool failures - #179345
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR bypasses success-schema validation for explicit MCP tool errors so their explanations and recovery guidance reach the agent. Example: get_conversation declares an output schema requiring messages but returns isError: true, structuredContent: { error: "ambiguous contact" }, and instructions to call list_conversations.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR provides a focused repair for a confirmed MCP result-validation bug still present on current main, with no actionable patch defects found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared MCP catalog owner captures result validators used by Gateway bundle calls, node-host calls, and native stdio continuations; validated results then enter model-facing projection. flowchart LR
A[MCP server result] --> B[Transport result parsing]
B --> C[Shared result validator]
C --> D[Explicit tool error]
C --> E[Successful result schema validation]
D --> F[Existing result projector]
E --> F
F --> G[Agent receives result]
Technical reviewBest possible solution: Retain the shared-owner error bypass and existing success validation, allowing this focused repair to proceed through its normal CI gates. Do we have a high-confidence way to reproduce the issue? Current-main and released source show that an explicit error containing structured content incompatible with the success schema throws before projection; the linked report supplies an affected server, release, and concrete trigger. Is this the best way to solve the issue? The bypass is the smallest complete fix: it uses the existing validator owner, matches the pinned client's contract, preserves successful-result checks, and requires no caller-specific workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f56292998380. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +16, Docs +7. Total +23 across 3 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 21, 2026, 6:04 AM ET / 10:04 UTC. |
|
Exact-head PR CI has passed on Per the maintainer proof policy for this repair, PR CI is the proof; local validation is limited to changed-file lint/format. Live entry-point proof and local base-red/head-green execution were intentionally skipped, as documented in the Evidence section. The proof-only note does not require additional runs for this work order. ClawSweeper reported no actionable code findings. |
|
Merged via squash.
|
Fixes #179318
What Problem This Solves
Fixes MCP tools losing the server's error reason and recovery guidance when an
isError: trueresult includes structured error details that do not match the tool's success schema.User Impact
Agents receive the server's error content and can follow its recovery guidance, such as selecting a conversation ID after an ambiguous-contact error.
Why This Change Was Made
The shared MCP result validator now returns immediately for explicit tool errors, matching the MCP client's success-only output-schema validation. Successful results still require valid structured content. Bundle tools, node-host calls, and native stdio continuations share this owner; MCP apps and plugin-backed tools benefit through their existing runtime paths.
The cleanup replaces the redundant missing-content return with the error return: production +4/-4 (net 0), tests +16/-0, docs +7/-0.
Evidence
accepts tool errors without requiring the success output schema (%j)insrc/agents/mcp-tool-metadata.test.ts, covering an incompatible structured error envelope and an error without structured content. The structured-envelope case reaches the erroneous schema rejection on the base by source inspection. Existing tests retain successful-result validation coverage.git diff --checkpassed. Deslop/pr-simplify completed.3f66c754bff1a8fe900a723e386bfa59acb9ec2b: 33 jobs passed, 27 policy-selected skips, no failures or retries.