You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code Mode resends the whole tool catalog on every inventory change #60128
In Code Mode a single tool being added or removed re-sends the entire catalog block (~8.8k characters) instead of saying what changed. In one long session on 2.2.0 I measured 120 catalog notices, 1,375,313 characters (~340k tokens), and 15 notices that were byte-identical to an earlier one.
Two things combine:
packages/core/src/codemode/catalog.tssummarize() spreads a fixed INLINE_BUDGET across namespaces and rotates which listings are inlined, so adding one tool shifts what the other namespaces show.
packages/core/src/codemode/instructions.tsupdate() compares that sample and answers any difference with a replacement block.
Sampling rotation and a real inventory change are therefore indistinguishable on the wire, and one changed tool costs the whole catalog.
Steps to reproduce
Run opencode serve, create a session.
Send a turn, then toggle an MCP server: POST /api/experimental/mcp/gh_grep/disconnect, then the same path with /connect.
Repeat, then count the Code Mode notices: rows in session_message where type='system' and metadata.instructionSources contains core/codemode.
Six toggles produce 57,072 characters of notices on 2.2.0.
Thanks for the detailed measurements and the clear pointer to summarize() and update().
I think this is a duplicate of #55529. It reports the same thing: when the Code Mode tool inventory changes (MCP reconnect, browser attach/detach), the whole catalog is re-injected, because the shared inline budget moves which entries are shown and update() then falls back to the full catalog block.
Possible duplicates and related issues, ordered by likelihood:
Closing this as a duplicate of #55529, as mentioned yesterday. There's been no reply saying how this differs. That issue tracks the same problem: a change to the Code Mode tool inventory re-sends the whole catalog. PR #57090 is open to address it.
Your 2.2.0 measurements and the MCP disconnect/connect steps would still help on #55529, so please add them there. If your case turns out to be different, reply here and we can reopen.
Activity
opencodejr commentedon Oct 29, 2026
Thanks for the detailed measurements and the clear pointer to
summarize()andupdate().I think this is a duplicate of #55529. It reports the same thing: when the Code Mode tool inventory changes (MCP reconnect, browser attach/detach), the whole catalog is re-injected, because the shared inline budget moves which entries are shown and
update()then falls back to the full catalog block.Possible duplicates and related issues, ordered by likelihood:
search(...)" notice instead of the full catalog.Your 2.2.0 numbers and the MCP disconnect/connect repro would be useful on #55529, so feel free to add them there.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencodejr commentedon Oct 30, 2026
Closing this as a duplicate of #55529, as mentioned yesterday. There's been no reply saying how this differs. That issue tracks the same problem: a change to the Code Mode tool inventory re-sends the whole catalog. PR #57090 is open to address it.
Your 2.2.0 measurements and the MCP disconnect/connect steps would still help on #55529, so please add them there. If your case turns out to be different, reply here and we can reopen.