Repository navigation
feat(coding-agent): reconcile selected harness revisions - #260
Issacboy123 wants to merge 1 commit into
Conversation
Pepps233
left a comment
There was a problem hiding this comment.
Once an evolution finishes, the system prompt is changed; changing the system prompt invalidates cached input.
Prefix caching can reuse only content before the first changed token:
- An unchanged opening portion of the system prompt may still hit.
- The changed memory/skill section and everything after it, including unchanged conversation history, cannot reuse the old prefix cache.
A good rule of thumb is to keep fixed, static information on the top of the cache while keeping dynamic information on the bottom of the cache. Since evolution changes system prompts, it'll invalidate all of the later cached inputs and thus increase cost. Our goal is to increase input cache hit % as much as possible.
Here's my suggestion: once evolution finishes, don't switch to the new harness version immediately. Instead, switch to the new harness version after a compaction takes place or if the user uses /clear in the same project directory. This is because compaction will rebuild the entire conversation history, and the input cache will be invalidated anyway, so you can freely modify the system prompt and just attach the compacted history right below it. Similar idea with clear, since it is clearing all previously stored input cache for the session, you can just freely modify the system prompt as it will not affect later cached inputs.
Once an evolution finishes, let the user know that it'll automatically update once context compacts or manually update through using /clear.
Let me know if you have any questions.
Summary
When evolution activates a harness revision, regular root sessions automatically adopt the workspace-selected revision at the next safe boundary: session construction or resumption, idle prompt admission, a successful idle reload, or successful manual compaction with no queued continuation. Users do not need to select it manually. Already admitted or queued work remains pinned to its existing revision.
This PR depends on #259.
Reasoning
Automatic activation must update a session only between units of work, never while one is admitted, running, or queued. Reusing the existing activation path keeps evolved memory, skills, system prompt, and subagent state in sync. Reload and compaction refresh only when safe; a post-commit compaction refresh failure is reported without undoing the completed compaction.
Changes
Testing
node ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-harness-version.test.tsnode ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-runtime.test.tsnode ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-compaction.test.tsnpm run check