Repository navigation
fix(core): send only changed entries in instruction updates - #57626
Conversation
There was a problem hiding this comment.
The change looks sound. I ran the updated instruction tests against the base: 4 fail because a changed entry restates the whole list. With this PR all 17 pass. The session runner and compaction tests (249) and bun typecheck in packages/core also pass. Rendering each changed entry whole under a "replaces the previously listed entry" line matches how the Code Mode catalog already handles changed tools. It also covers the case where MCP drops the execute hint when Code Mode is turned off. Baseline text is untouched, so prompt caches in existing sessions stay valid.
Public API is unchanged: only the text of model-facing instruction updates differs, and update texts already stored in sessions are not re-rendered.
No blocking concerns.
Related: #55529
Issue for this PR
Related to #55529
Type of change
What does this PR do?
Problem
When a skill, MCP server instruction or project reference changed, the update message restated the whole list. Additions and removals were already small deltas, but a single edited description resent every entry, which wastes context in long sessions.
Change
Skill, MCP and reference updates now send only the entries that changed. Each changed entry is rendered whole with the existing entry renderer, under a line saying it replaces the previously listed entry with the same ID or name. This is not a field-level diff. For MCP that framing matters: a server that turns off Code Mode loses its "Use tools from this server through
execute..." line, and the new entry replaces the old one.When one update has additions, changes and removals, they go in one text in a fixed order: added, changed, removed. The full list is still restated only when no difference is detected.
Before and after, when one skill's description changes:
Update texts are rendered once and stored in the durable event, so update messages already in existing sessions stay byte-identical. I did not change the baseline (
initial) text, which is re-rendered on every request, so existing sessions keep their prompt cache.Out of scope
The Code Mode catalog part of #55529 is not addressed here.
How did you verify your code works?
From
packages/core:bun typecheck: passesbun run script/test.ts test/skill/instructions.test.ts test/mcp-instructions.test.ts test/reference-instructions.test.ts: 17 pass. I updated the tests that asserted the full-list restatement and added a reference test that covers added, changed and removed entries in one update.bun run script/test.ts test/session-runner.test.ts test/session-compaction.test.ts: 249 passScreenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #55529