Repository navigation
fix(server): agents read why a T3 tool rejected their arguments - #35729
juliusmarminge wants to merge 6 commits into
Conversation
…n error" Failing repro for #35713: over HTTP MCP 2025-06-18, T3 answers invalid tool arguments with a JSON-RPC -32602 error instead of an isError tool result, and Cursor reduces protocol errors to a generic message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under MCP 2025-06-18, which Cursor negotiates, invalid tool arguments went back as a JSON-RPC -32602 error. Cursor reduces that to "Tool execution error", so models never saw what to fix (for example target.options sent as a string to delegate_task). Toolkit tools now return the validation message as an isError tool result on every protocol version, as MCP 2025-11-25 specifies and the hand-registered image tools already do. Fixes #35713 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Invalid tool arguments now return readable validation details as an error-marked tool result, allowing agents to correct their calls. The change is limited to error presentation and leaves successful tool execution and access controls unchanged. Notes:
You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
The automated pipeline stopped on this pull request and will not merge it: the capture step could not show the problem on the base commit, so there is nothing to prove fixed. On head, installed dependencies, started the dev server, enabled Cursor, added a synthetic scratch project, and started gemini-4-carbon. The prompt requested orchestrator_capabilities, an intentionally invalid delegate_task call with string target.options, quoting the received error, then retrying with an object preserving reasoningEffort high. Cursor refused the model before any tool call. Base was not run; neither verdict is established. Stopped the server and removed the scratch directory and worktree. It stays open for a person to finish or close. |
…nt checks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dismissing prior approval to re-evaluate 018a653
Applies upstream pingdotgg#35729. Cursor reduces the JSON-RPC invalid-params error to "Tool execution error", so invalid tool arguments now come back as an isError tool result carrying the validation message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l selection (#112) * fix(server): agents read why a T3 tool rejected their arguments Applies upstream pingdotgg#35729. Cursor reduces the JSON-RPC invalid-params error to "Tool execution error", so invalid tool arguments now come back as an isError tool result carrying the validation message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(contracts): a null model selection options value is treated as omitted (pingdotgg#29149) Co-authored-by: Julius Marminge <julius0216@outlook.com> * fix(server): thread launch and configure advertise a typed model selection t3_thread_launch and t3_thread_configure took ModelSelection, which decodes from untyped fields, so MCP clients saw instanceId, model and options as `{}` and had to guess their shape. They now take OrchestratorMcpModelSelection, which advertises real types (options matches delegate_task's target.options) and decodes to the same ModelSelection, legacy `provider` included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): preserve legacy modelSelection decoding and record invalid-argument spans Separates MCP's typed modelSelection advertisement from ModelSelection's compatibility decoder so legacy inputs (such as null entries inside an options object or a non-string provider beside instanceId) still normalize, while advertising that either instanceId or provider is required alongside model. Moves withReadableInvalidArguments outside withToolSpans and withToolAnalytics so invalid arguments fail tool spans and record an invalid_arguments errorCode in analytics without logging arguments. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Jex <jieyuexing@outlook.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
…ults Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The automated pipeline stopped on this pull request and will not merge it: the fix is written and reviewed, but proving it needs something no worker has:
It stays open for a person to finish or close. |
Cause: Effect's MCP 2025-06-18 adapter (offered first by McpHttpServer.layerMcpTransport and used as the fallback for unknown versions) answers a tool's invalid arguments with a JSON-RPC -32602 error. Only 2025-11-25 and newer turn invalid input into an isError tool result. Cursor reduces the protocol error to "Tool execution error", so models never learned what to fix. Fix: toolkitRegistration now wraps McpServer.registerToolkit with withReadableInvalidArguments, a wrapper around McpServer.addTool in the same style as withAdvertisedSchemas and withToolSpans. For tool calls, registerToolkit raises InvalidParams only when a tool's arguments fail validation, and the wrapper returns it as CallToolResult{isError:true, content:[text: validation message]}. That works on every negotiated protocol version, matches the 2025-11-25 spec, and matches what the hand-registered image tools (preview snapshot, device screenshot) already did. It sits inside the span and analytics wrappers, so those see the isError result and record it as a failure. The repro test from factory/repro-35713 passes unchanged. Five existing tests that asserted the old protocol failure (unknown-argument and below-minimum cases in McpHttpServer.test.ts, and the unknown-organize-target case in toolkits/core.test.ts) now assert the isError result. No production code calls the in-process server directly. No protocol versions, defaults or stdio bridge behaviour changed. No new regex or parser.
Fixes #35713
Reproduction on main
Commit e0d6aad (origin/main). Started
T3CODE_DEV_SEED=0 vp run devin a fresh worktree, enabled acursorprovider instance in the worktree's own .t3 settings.json, added a scratch project witht3 project add, then rant3 thread start --provider cursor --model composer-2.5with a prompt telling the model to call orchestrator_capabilities and then delegate_task once with target.options set to the JSON string "{"reasoningEffort":"high"}" (gemini-4-carbon itself was refused by the VM's Cursor account for usage). Observed: the Cursor SDK's tool-call-completed event for delegate_task carried result {"status":"error","error":{"message":"Tool execution error"}}, matching the reporter's payload, and T3's projected turn item for the call records only "Tool execution error". composer-2.5's reply did quote the full detail ("Tool execution error. MCP error -32602: Invalid parameters for tool 'delegate_task': Expected array | object | null at ["target"]["options"]"), so whether the model sees the detail depends on Cursor's backend and model; what Gemini receives was not verified. Server side: McpHttpServer.layerMcpTransport offers [v2025_06_18, v2026_07_28], with 2025-06-18 first and used as the fallback for unknown versions, and under 2025-06-18 Effect's McpServer answers invalid arguments with a JSON-RPC -32602 error instead of an isError tool result. Added a failing HTTP-transport test in apps/server/src/mcp/McpHttpServer.test.ts that negotiates 2025-06-18 and calls a tool with a string where an object is required; on main it receives {code:-32602, message:"Invalid parameters for tool 'probe': Expected object | null ..."} instead of an isError result.Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/mcp/McpHttpServer.test.ts (before the test updates: repro test passed, 4 old-behaviour tests failed as expected); vp test run src/mcp/ -> 26 files, 365 tests passed; vp run check:changed -> format, lint, knip, graphql, typecheck (3 packages), tests (3 files) all pass
Not in this change
Who did the work
Run by the t3code factory in T3 Code.