Repository navigation
fix(tools): Accept top-level intent on executeTool like callMcpTool - #3495
Conversation
Co-Authored-By: Aditya Mathur <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
33 screenshot changes — 33 changed · 0 added · 0 removed Review screenshots in Frameshift Show 12 more changed screenshots15 more changed screenshots in Frameshift. |
There was a problem hiding this comment.
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.
Co-Authored-By: Aditya Mathur <[email protected]>
|
Addressed the review in e02c8df: |
`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]>
Fixes #2455
callMcpToolaccepts an optional top-levelintent, butexecuteToolrejected it withexecuteTool arguments must be nested under arguments. The model sees both dispatchers in the same turn, so it sometimes carriesintentover. Each time, that costs a tool call. Now both dispatchers take the same envelope:tool_name,arguments, and an optionalintent.executeToolacceptsintentand drops it. It does not go to the catalog tool. For MCP tools,intentbecomes 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 sendintentinto 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-nameviolation atpackages/junior/src/chat/tools/submit-feedback.ts:50. This PR does not touch that file.via @MathurAditya724.
--
View Session [Sentry]