Repository navigation
fix(core): keep partial Code Mode catalog updates proportionate - #57090
reynold-hu wants to merge 1 commit into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
The fix works for the scenario in #55529. I ran the issue's reproduction script (github 46 / nas-ops 35 / opencode 8 tools, adding and removing a 45-tool browser namespace) against the real catalog code. On the base, attach and detach each send the full catalog (8,811 and 8,912 characters). With this PR they send 154 and 184 characters: the re-run line plus the namespace added/removed line. The new test fails on the base and passes here. instructions.test.ts passes (4/4) and the packages/core typecheck passes.
Public API: unchanged. This only changes the text of the Code Mode instruction update.
One point that isn't blocking, noted inline: when a shown tool's own listing changes, the model only gets "catalog changed, re-run search", with no detail.
| // mean the full inventory changed enough to repeat it. Point the model at search instead. | ||
| const parts = [ | ||
| entriesChanged | ||
| ? "The Code Mode tool catalog has changed. Re-run `search(...)` before relying on previous results." |
There was a problem hiding this comment.
Dropping diff.added and diff.removed here makes sense, because shown entries come and go whenever the inline budget is redistributed. diff.changed is different. It means the same path is shown before and after, but its signature or description changed. Budget redistribution doesn't produce that; it's a real change to a tool the model still sees in its earlier catalog. When the count stays the same (for example, an MCP server reconnects with an updated schema), this branch now sends only the generic "re-run search" line, and the old signature stays in context. The complete-catalog branch lists these lines. Listing diff.changed here as well ("Changed tool listings supersede the previously listed ones: …") would cost little and keep the notice accurate.
7b2a2a1 to
2dd7a1d
Compare
|
Posting numbers from the duplicate (#60129) as suggested, since they point the same way and go a bit further. What we changed. Measured on dev
Caveat on this scenario: on Branch: |
…anges Folds in the short notice from anomalyco#57090: when a partial catalog would restate more than 1,000 characters of added or changed listings, the delta names the affected namespaces and asks the model to re-run search(...) instead. Smaller deltas still restate the lines, since one listing costs less than the search step it saves, and complete catalogs always restate because search is not offered there. Co-authored-by: Reynold Hu <[email protected]>
|
Numbers from folding this shape into the fuller delta design from #60129, so the two can be compared side by side. What the merged behaviour is. A complete catalog always restates the added or changed listings, because
Measured on a 60-tool partial catalog (
So the notice path costs roughly 1.5% of the block it replaces, and the single-listing path stays small enough that the model does not need an extra round trip. Checks. Where it lives. Question. If maintainers would rather have the notice shape for every partial-catalog change and no restating at all, that is a two-line change in @opencodejr flagging so triage sees this; if it belongs on #55529 instead, point me there and I will repost. |
|
Thanks for the numbers. The threshold shape is the right call: restating under 1000 chars keeps the common single-change case cheap without an extra search round trip, and the notice covers bulk churn at about 1.5 percent of the block. I would like to fold it into this PR as one diff. Happy for you to fold your branch in, co-author credit stays of course. |
Issue for this PR
Closes #55529
Type of change
What does this PR do?
When the Code Mode catalog is partial (the inline budget hides some tools),
updatefell back to the full catalog as soon as a shown entry changed. Browser attach/detach or MCP reconnect changes those entries, so normal desktop use kept re-injecting the whole ~9–14k-character catalog as a fake user turn.The partial branch now emits a short notice: "The Code Mode tool catalog has changed. Re-run
search(...)before relying on previous results.", plus the existing namespace added/removed/changed details. It never repeats the full catalog from this branch. The complete-catalog delta behavior is unchanged.Debouncing the attach/detach flap itself is left out so semantic changes still surface immediately; this change makes each notice proportional to the change.
How did you verify your code works?
packages/core/test/codemode/instructions.test.ts: a 60-tool partial catalog; changing a shown entry returns a <200-character notice containing the re-run line, without## Available toolsor tool listings. On the parent the same update returns the full catalog.bun test test/codemode/instructions.test.ts: 4 pass, 0 fail.packages/coretypecheck passes.Screenshots / recordings
No UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #55389, #54408