Repository navigation
fix(coding-agent): preserve task-state prompt cache prefixes - #293
Merged
Merged
Conversation
Keep request-only task snapshots at their original conversation boundaries and append a new version only when visible task state changes. Reuse unchanged snapshot content and timestamps without rewriting canonical history. Reset snapshots on branch restoration, context replacement, or disabled task tools, and supersede deleted tasks with an empty snapshot. Add regression coverage for append-only turns, serialized Responses requests, retries, and compaction behavior.
ZouR-Ma
requested review from
MelodyVAR,
Uking-xxx and
liuedcson
as code owners
October 22, 2026 08:50
liuedcson
added a commit
that referenced
this pull request
Oct 23, 2026
Brings the seven commits main gained since dff413f: - feat(coding-agent): make a feedback report investigable (#297) - fix(coding-agent): settle extension command turns before returning (#298) - fix(coding-agent): keep the tool block stable across plan mode (#296) - fix(cli): save model selection as default on Enter (#285) - feat(cli): add -C/--cwd flag (#289) - fix(coding-agent): preserve task-state prompt cache prefixes (#293) Two conflicts, both in the plan extension, where this branch had added behaviour on top of files main rewrote: - `plan-mode-tools.ts`: main's comment for `exitPlanMode` ("restore any tools plan mode added") with this branch's optional `submittedPlanHash` parameter, which records the proposal handed to an external reviewer. - `step-plan.ts`: main's `version: 2` entry and `carriesLegacyTools` migration path, plus this branch's `submittedPlanHash` / `planHashAtEnter` on the same entry, and both sides of the restore step (legacy tool baseline and the persisted hashes). Main's `resolveToCwd` guard and `planModeAddedTools` bookkeeping are kept as-is: plan mode now appends tools instead of replacing the list, which is what keeps the request's tool block stable. The host plan-mode test asserted the old refusal wording; the guard now says "Only the plan file may be written", so it matches on that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The task context hook added by
baa1ef8(merged in #232) rebuilds a request-only task snapshot at the end of every model request. On the following turn, that previous input item disappears and assistant/tool messages take its place. This breaks append-only prompt-cache prefixes even when the task state has not changed. The initial4fdb781implementation did not have this hook.Changes
Behavior and compatibility
This is a single fix cherry-picked from
7704518onto currentmain, not a merge of the Desktop branch. The diff contains only six coding-agent source, test, and documentation files; no Desktop/Web changes, dependencies, or lockfile updates.Task state remains authoritative in its existing store. Historical request snapshots are data; the last snapshot is current. Canonical transcripts, editable CLM mirrors, task permissions, and explicit completion rules are unchanged. CLI, RPC, SDK, Web, and Desktop share this extension.
Validation
On macOS with Node 24.3.0 and pnpm 9.15.9, in the independent main-based worktree:
pnpm run build:offline— passed.pnpm run check— passed.TMPDIR=/tmp ./test.sh— all workspace suites passed; existing provider/platform skips retained.The Desktop branch also passed its repository checks and isolated full suite. The first full run with the default macOS temporary directory hit the existing tsx Unix-socket path-length failure; the documented
TMPDIR=/tmprun passed without changing tests or timeouts.Limitations
Provider-side cache hit rates have not been re-measured with paid requests. Intentional context edits, changed system/tool definitions, cold process resumes, and provider eviction can still invalidate caches. Previously issued request-only snapshots are not persisted across process restarts. Installed applications need a rebuilt runtime and restart to use this fix.