Skip to content

fix(tools): Accept top-level intent on executeTool like callMcpTool - #3495

Merged
MathurAditya724 merged 2 commits into
mainfrom
fix/execute-tool-intent
Nov 16, 2026
Merged

MathurAditya724 merged 2 commits into
mainfrom
fix/execute-tool-intent

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #2455

callMcpTool accepts an optional top-level intent, but executeTool rejected it with executeTool arguments must be nested under arguments. The model sees both dispatchers in the same turn, so it sometimes carries intent over. Each time, that costs a tool call. Now both dispatchers take the same envelope: tool_name, arguments, and an optional intent.

executeTool accepts intent and drops it. It does not go to the catalog tool. For MCP tools, intent becomes the reason on the connect prompt. Catalog plugin tools have no per-call reason: plugin OAuth starts in the plugin egress and uses the user's message as the reason. A possible follow-up is to send intent into plugin auth prompts. That needs per-call plumbing through the egress, so it is out of scope here.

This PR does not fix the other rejected shape in the issue (catalog parameters at the top level).

Note for reviewers: main already has a no-hardcoded-bot-name violation at packages/junior/src/chat/tools/submit-feedback.ts:50. This PR does not touch that file.

via @MathurAditya724.

--

View Session [Sentry]

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 16, 2026 8:54am UTC

Request Review

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

33 screenshot changes — 33 changed · 0 added · 0 removed

Review screenshots in Frameshift

Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Run Details Light · Mobile
Automation Run Details Light · Mobile
Changed
Automations Runs Filters · Desktop
Automations Runs Filters · Desktop
Changed
Conversation Attachment · Desktop
Conversation Attachment · Desktop
Changed
Conversation Attachment · Mobile
Conversation Attachment · Mobile
Changed
Conversation Attachment Modal · Desktop
Conversation Attachment Modal · Desktop
Changed
Show 12 more changed screenshots
Conversation Attachment Zoom · Desktop
Conversation Attachment Zoom · Desktop
Changed
Conversation Captured Memories Popover · Desktop
Conversation Captured Memories Popover · Desktop
Changed
Conversation Child Agents · Desktop
Conversation Child Agents · Desktop
Changed
Conversation Details Watched Linked Work · Desktop
Conversation Details Watched Linked Work · Desktop
Changed
Conversation Event Log Virtual · Desktop
Conversation Event Log Virtual · Desktop
Changed
Conversation File Draft · Desktop
Conversation File Draft · Desktop
Changed
Conversation Long Transcript Touch · Mobile
Conversation Long Transcript Touch · Mobile
Changed
Conversation Memory List Jump · Desktop
Conversation Memory List Jump · Desktop
Changed
Conversation Memory List Jump · Mobile
Conversation Memory List Jump · Mobile
Changed
Conversation Object Links · Desktop
Conversation Object Links · Desktop
Changed
Conversation Object Links Light · Desktop
Conversation Object Links Light · Desktop
Changed
Conversation Question · Desktop
Conversation Question · Desktop
Changed

15 more changed screenshots in Frameshift.

@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 16, 2026 07:59
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 16, 2026

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The change itself is right. intent is now the only new key that gets through. Other stray top-level keys are still rejected at both layers, also when intent is present. The new describe() text is accurate, because intent really is dropped before the catalog call.

One gap before this lands: the new test only exercises resolveCatalogToolCall, but that is only half of the fix. The .strict() schema in execute-tool.ts is what Pi's validateToolArguments checks first. I ran the old schema shape through it locally, and an extra key fails there with <key>: unknown field before resolveCatalogToolCall runs. So if someone reverts the schema hunk, real executeTool calls with intent fail again, and this test still passes. Please add one executeTool call with a top-level intent through real wiring. For example, a createModelStream tool call in an existing integration scenario such as tests/integration/annotation-cards.test.ts. Then assert that the catalog tool runs with only the nested arguments.

@sentry-junior

sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the review in e02c8df: tests/integration/annotation-cards.test.ts now sends its first executeTool call with a top-level intent through the real agent loop, so Pi's schema validation runs. It asserts that the catalog tool gets only the nested arguments. If the execute-tool.ts schema change is reverted, this test fails.

@MathurAditya724
MathurAditya724 merged commit 58f6f71 into main Nov 16, 2026
47 checks passed
@MathurAditya724
MathurAditya724 deleted the fix/execute-tool-intent branch November 16, 2026 10:46
MathurAditya724 added a commit that referenced this pull request Nov 16, 2026
`executeTool` and `callMcpTool` each had a hand-written copy of their
input rules next to their zod schema. That's why #3495
had to add `intent` in two places (see #2455). Now
there's one schema per tool and no hand-written copy.

The same error messages now live on the zod schemas. Pi already runs the
schema before the tool, so `executeTool`'s friendly errors never reached
the model before. Now they do. The `executeTool` dispatcher still parses
again with the same schema, because it gets the raw input. `callMcpTool`
is now strict like `executeTool` and accepts the same inputs as before.
Its errors just get the usual `Invalid tool arguments:` prefix.

<!-- junior-request-attribution:start -->
via @MathurAditya724.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Adea09f617657be95bec6aaaca77c1ffd -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Adea09f617657be95bec6aaaca77c1ffd)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Adea09f617657be95bec6aaaca77c1ffd/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Aditya Mathur <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — e02c8df0 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

executeTool rejects top-level intent that its sibling callMcpTool accepts

1 participant