Repository navigation
fix(core): tell Code Mode models built-in tools stay top-level - #57627
rekram1-node wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
The change looks right overall. On the base, the new test fails with the old Unknown tool 'read'. error and passes with this PR. codemode tests (1416) and core codemode tests (23) pass, and both packages typecheck. I couldn't check that the models themselves behave differently: that needs a real provider, and the simulated model only replays scripted calls.
Public API: the published @opencode/codemode package changes behaviour. Unknown tool paths whose first segment is one of the hardcoded names now fail with an opencode-specific message instead of the fuzzy "Did you mean" suggestion. Nothing is added or removed from its API, and opencode's SDK, server, config and plugin API are unchanged.
One concern, inline: the hardcoded list of built-in tool names in packages/codemode would be better passed in from core, using the tools core keeps out of Code Mode (codemode: false).

Issue for this PR
Fixes #53623
Type of change
What does this PR do?
Problem. Weaker models (Gemma 4, MiMo v2.6 Flash) write
await tools.read(...),tools.shell(...)ortools.glob(...)insideexecute. The Code Mode prompt opens with "Use theexecutetool to call the tools listed below" under## Available tools, and nothing says the regular tools are still called directly.Change. Only the Code Mode prompt wording in
packages/core/src/codemode/instructions.ts:Evidence. From the
codemode-routingeval (https://github.com/anomalyco/evals/pull/18, run on dev aadd4d8) with only this wording change, share of trials that call a built-in insideexecute:Mean tokens on the small catalog dropped from 136k to 26k (Gemma 4 31B) and 180k to 33k (Gemma 4 26B), mostly from fewer runaway loops.
Cache effect. The Code Mode block is part of the instruction baseline, which is re-rendered from the stored catalog on every request. Existing Code Mode sessions get the new text on their next request after deploy and miss the prompt cache once for that prefix.
Out of scope. Gemma 4 26B with an 84-tool partial catalog still guesses tool names instead of searching, and the runtime error for unknown paths is unchanged.
How did you verify your code works?
bun typecheckinpackages/core: passbun test test/codemodeinpackages/core: 23 passScreenshots / recordings
Not a UI change.
Checklist