Repository navigation
fix(goal): preserve prompt cache across goal turns and keep timers running - #14680
Merged
Merged
Conversation
…nning Keep goal tool schemas stable so starting, continuing, and finishing a goal does not invalidate the provider prompt cache. Carry the user's shell and custom system context into automatic goal turns, including after compaction, and refresh it from real user input instead of rescanning the growing transcript. Keep the session working timer running across goal turns and between-turn waits instead of resetting each turn. Rejected commands no longer clear an active goal's clock; completion, pause, blocking, and terminal errors still stop it.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The previously reported warning (offline reconnect resetting the goal clock) is fixed: Files Reviewed (3 files, incremental commit)
Previous Review Summary (commit ac4a092)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit ac4a092)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (17 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
marius-kilocode
enabled auto-merge
September 30, 2026 09:17
WebReflection
approved these changes
Sep 30, 2026
This was referenced Oct 1, 2026
This was referenced Oct 7, 2026
5 tasks done
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.
What Problem This Solves
Long-running goals wasted prompt cache and showed a resetting timer.
Cache invalidation at goal transitions. Starting or finishing a goal changed the advertised tool set, and automatic goal turns dropped the user's shell and custom system context. Any of these changes invalidates the provider's cached prompt prefix, forcing a full prefill on the next request. This happened when a goal started, on the first automatic goal turn, and again on the first normal message after a goal finished.
The working timer reset every turn. The live session clock was cleared on each goal-turn boundary and during the between-turn wait, so elapsed goal time never accumulated.
Repeated history scans. Each automatic goal turn rescanned the whole session history to recover the user's context, which grew quadratically across a long goal.
Why This Change Was Made
editorContextandsystemprompt, so the early part of the request stays byte-identical. The context is loaded once per goal run and refreshed only when a real user message arrives; internal compaction markers cannot replace it./gaol) is an admission error that leaves the goal running, so it no longer clears the clock. Error phase now travels from the backend through the legacy SSE bridge and host mapper to the webview.User Impact
Evidence
bun test ./test/kilocode/session/goal.test.tsand./test/kilocode/provider/session-resume-cache.test.ts../test/kilocode/legacy-sse-event.test.tsverifies the phase survives the legacy SSE bridge.bun test tests/unit/session-provider-activity.test.ts tests/unit/session-timing.test.ts tests/unit/session-dock.test.ts tests/unit/working-indicator.test.ts tests/unit/kilo-provider-utils.test.ts.Limitations
Live vendor cache-hit metrics were not measured. Cache expiry or compaction can still cause legitimate misses; this change only removes the unintended prefix changes.