Skip to content

fix(core): send only changed entries in instruction updates - #57626

Merged
rekram1-node merged 1 commit into
devfrom
instruction-entry-deltas
Oct 21, 2026
Merged

rekram1-node merged 1 commit into
devfrom
instruction-entry-deltas

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Related to #55529

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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:

-The available skills have changed. This list supersedes the previous available skills list.
-Skills provide specialized instructions and workflows for specific tasks.
-Use the skill tool to load a skill when a task matches its description.
-The user may also invoke a skill directly. ...
-<available_skills>
-  <skill>
-    <id>debugging</id>
-    <name>Debugging</name>
-    <description>Diagnose hard bugs</description>
-  </skill>
-  <skill>
-    <id>effect</id>
-    <name>Effect</name>
-    <description>Build applications with Effect v4</description>
-  </skill>
-  ... every other skill ...
-</available_skills>
+The following skills have changed. Each entry replaces the previously listed skill with the same ID:
+  <skill>
+    <id>effect</id>
+    <name>Effect</name>
+    <description>Build applications with Effect v4</description>
+  </skill>

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: passes
  • bun 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 pass

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #55529

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rekram1-node
rekram1-node merged commit 15adc3d into dev Oct 21, 2026
16 checks passed
@rekram1-node
rekram1-node deleted the instruction-entry-deltas branch October 21, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant