Repository navigation
fix(codemode): Redirect catalog dispatcher calls from scripts - #3229
Merged
Merged
Conversation
Co-Authored-By: Thomas Jiang <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
11 screenshot changes — 11 changed · 0 added · 0 removed Review screenshots in Frameshift |
Co-Authored-By: Thomas Jiang <[email protected]>
thomasjiangcy
approved these changes
Nov 12, 2026
thomasjiangcy
pushed a commit
that referenced
this pull request
Nov 12, 2026
Follow-up to #3229. That PR kept its own list of the tools to redirect (`executeTool`, `searchTools`) in `codemode/redirect.ts`. Tool exposure already decides which tools a script cannot call, so the list was a second copy of that rule. It also drifts: a new `modelOnly` tool would get pi's misleading hint again until someone added it by hand. Now `createPiAgentTools` passes every model tool that is not a script tool to the bridge as `modelOnlyTools`. That is the `modelOnly` registry tools plus `searchTools`, `executeTool`, and `codemode`. The VM declares each one, and a call to one fails with a redirect. `redirect.ts` owns only the text: the two specific messages for `executeTool` and `searchTools`, and "X does not run in a script. Call it directly, outside the script." for the rest. So `spawnAgent`, `handoff`, and the other loop-control tools are covered too. `Object.hasOwn(run.tools, name)` is still the only check that lets a call run. Names that no tool has still get pi's error, labeled `missing_tool`. The `codemode` tool test now calls `tools.executeTool` through the real `createPiAgentTools` wiring, so dropping the derived list fails a test. <!-- junior-request-attribution:start --> via @thomasjiangcy. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0AHB7N2JCR%3A1794440124.103639 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AC0AHB7N2JCR%3A1794440124.103639) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0AHB7N2JCR%3A1794440124.103639/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
23 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Models keep calling
tools.executeTool(...)andtools.searchTools(...)inside Code Mode scripts, even though thecodemodedescription says scripts cannot call them (#2578). Reported by @dcramer.Today pi-codemode's
toolsproxy fails the property read with its own hint: "ALL_TOOLS lists every tool; searchTools(query) finds tools by topic." That hint is wrong for Junior, becausesearchToolsis not a script tool either. So it steers the model into its next failure. The error also happens before any host call. A script that catches it hides the mistake completely: the call list is empty and the return value looks like "no results".Now the bridge declares
executeToolandsearchToolsin the VM, but they never run. A call to one reaches the bridge with its arguments and fails at once with the call to make instead. Nothing is reviewed, counted toward the Turn limit, or run:executeTool({ tool_name: "searchConversationEvents", arguments })→ "Calltools.searchConversationEvents(arguments)directly, with only the object from the executeTool arguments field."executeToolfor a name that is not a script tool → call it outside the script.searchTools→ call it directly before the script, then call each result astools.<tool_name>(args).The error is stored on the call record, so it shows in the
codemoderesult even when the script swallows the rejection or never awaits the call.Object.hasOwn(run.tools, name)is still the only check that lets a call run, and the declarations in the tool description still come fromscriptTools. The two declarations do show up inALL_TOOLS, and their descriptions say how to make the call.No pi change is needed: this uses only the tools list we pass to
start()and the outcomes we send back withdeliver().To measure whether the steering works, the
codemodespan gets two new signals:app.codemode.call.redirected_count: dispatcher calls that the bridge redirected.app.codemode.error.kind:missing_tool: a script that failed on pi's "tools.X does not exist" read. Before, these were allscript. It is found the same way asmemory, by matching pi's error text. If pi changes that text, these go back toscript.Not in this PR: other
modelOnlynames (spawnAgent,handoff, ...) still get pi's generic miss error. There is no eval either. The failing shape needs the model to reach forexecuteToolon its own, and evals cannot script the model.via @thomasjiangcy.
--
View Session [Sentry]