Skip to content

Code Mode resends the whole tool catalog on every inventory change #60128

Closed as duplicate

Description

@Neko-Yukari

Description

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:

  1. packages/core/src/codemode/catalog.ts summarize() spreads a fixed INLINE_BUDGET across namespaces and rotates which listings are inlined, so adding one tool shifts what the other namespaces show.
  2. packages/core/src/codemode/instructions.ts update() 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

  1. Run opencode serve, create a session.
  2. Send a turn, then toggle an MCP server: POST /api/experimental/mcp/gh_grep/disconnect, then the same path with /connect.
  3. 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.

OpenCode version

2.2.0

Operating System

Windows 11

Terminal

Windows Terminal

Fix: #60129

Activity

  1. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    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:

    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.

  2. opencodejr commented on Oct 30, 2026

    @opencodejr
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions