Skip to content

fix(server): MCP tools report readable argument errors and typed model selection - #112

Merged
yvesoddly merged 4 commits into
mainfrom
fix/mcp-tool-args
Nov 20, 2026
Merged

yvesoddly merged 4 commits into
mainfrom
fix/mcp-tool-args

Conversation

@yvesoddly

@yvesoddly yvesoddly commented Nov 20, 2026 •

Copy link
Copy Markdown

Problem

When calling t3_thread_launch or t3_thread_configure, MCP advertised modelSelection fields (instanceId, provider, model, options) as untyped {} objects because ModelSelection decodes from untyped fields. Models like Gemini on Cursor guessed shapes such as options: [null], and because MCP returned InvalidParams as a JSON-RPC error, Cursor collapsed the failure into an opaque "Tool execution error" with no hint on how to recover.

Change

  • Wrapped MCP toolkit registration with withReadableInvalidArguments (apps/server/src/mcp/McpHttpServer.ts, backport of pingdotgg/t3code#35729) so invalid tool arguments return an isError: true tool result containing the validation message.
  • Treated options: null as omitted in ModelSelection (packages/contracts/src/modelSelection.ts, backport of pingdotgg/t3code#29149).
  • Added OrchestratorMcpModelSelection (packages/contracts/src/orchestratorMcp.ts) and wired it into t3_thread_launch and t3_thread_configure so MCP advertises real field types and options shapes while decoding to the same ModelSelection (legacy provider included), and updated agentContextBudget.json.

Verification

  • vp run check:changed passed under Node 26 across all affected packages and tests, including new unit tests in McpHttpServer.test.ts, advertisedJsonSchema.test.ts, core.test.ts, and modelSelection.test.ts.
  • Not yet tested against a live Cursor + Gemini turn or the paid mcp-tool-use eval.

Implemented with Claude Opus 5.5 (Claude Code); reviewed and opened with Gemini 4 Neon (Antigravity).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T21:33:08.116770Z b6ca34d Manual request
🔒 Security Review ❌ Failed 2026-11-20T20:11:58.282703Z
We couldn’t complete this review. Comment @codex security review to try again.
984c6fa PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M labels Nov 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: 984c6fa5ec

ℹ️ 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 on lines +113 to +117
options: Schema.optional(
OrchestratorMcpTargetOptions.annotate({
description: "Options from `orchestrator_capabilities`, such as {effort:'max'}.",
}),
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add an eval case for model-selection argument recovery

This fixes a model-behavior bug by changing the advertised tool schema and validation feedback, but adds no corresponding mcp-tool-use eval case. The new unit tests establish the schema shape and decoding behavior, not whether an agent avoids malformed options or recovers after receiving the readable error—the reported failure this change addresses. Add a case reproducing that failure and compare its behavior before and after the fix, as required by the root AGENTS.md Evals guidance.

AGENTS.md reference: AGENTS.md:L148-L148

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Skipping an evals/mcp-tool-use case here: two commits are upstream backports (pingdotgg/t3code#35729 and #29149), and the untyped-schema failure was reproduced on Gemini via Cursor, which the mcp-tool-use harness does not cover.

@github-actions github-actions Bot added size:L and removed size:M labels Nov 20, 2026
@yvesoddly

Copy link
Copy Markdown
Author

@codex review
@codex security review

@yvesoddly yvesoddly added the agent-context-increase Accept an intentional increase in agent context label Nov 20, 2026
yvesoddly and others added 4 commits November 20, 2026 15:32
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 <[email protected]>
…ction

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 <[email protected]>
…id-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.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: b6ca34d8ed

ℹ️ 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".

@yvesoddly
yvesoddly merged commit 3958d02 into main Nov 20, 2026
10 checks passed
@yvesoddly
yvesoddly deleted the fix/mcp-tool-args branch November 20, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-context-increase Accept an intentional increase in agent context size:L vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants