You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#13 by keeping the goal-mode system reminder byte-stable while an objective and mode remain unchanged.
Active goals currently interpolate live elapsed time, token usage, remaining budget, auto-continue count, checkpoints, and status into output.system[0] on every model request. Prefix-based prompt caches therefore stop matching at the first changing counter, causing most of a long session's context to be processed as uncached input on every tool-call round trip.
This change separates stable goal guidance from dynamic operational state:
The per-request system reminder retains the objective, continuation behavior, evidence requirements, fidelity guidance, and completion/blocking audit rules, but omits live counters and checkpoints.
Plan-mode and paused reminders likewise contain only stable objective and mode guidance.
Dynamic budget/status values remain available through goal tools, the TUI, compaction context, and the trailing auto-continuation prompt, where they do not invalidate the reusable system prefix.
The generated server bundle is rebuilt for package consumers.
Regression Coverage
The server-hook test now renders an active-goal system prompt, records changed token usage and a new assistant checkpoint, renders the prompt again, and requires the two outputs to be exactly equal. It also asserts that volatile token and checkpoint labels are absent from the system reminder.
Thanks for addressing the prompt-cache invalidation. The active-goal reminder is now byte-stable when the objective and mode are unchanged, so the core direction looks correct.
I found a few semantic regressions that should be addressed before merge:
Safety-limited goals are reported as paused.systemReminder() currently maps every open non-active state to the literal Status: paused. This hides budgetLimited and usageLimited, including their stopReason and wrap-up requirement. I reproduced a goal with status: budgetLimited and stopReason: token budget reached (10/10); the generated reminder only reported Status: paused. In Plan mode, the reminder also recommends switching to Build and resuming without mentioning that a safety limit was reached. Please preserve the actual stable status and stop reason/blocker, and retain the “do not start new substantive work; wrap up” guidance for limited goals.
Fixed configured limits are removed unnecessarily.tokenBudget, maxAutoTurns, and maxDurationSeconds are stable for the lifetime of a goal, so keeping them in the active reminder would not invalidate the prompt cache. The volatile fields (timeUsedSeconds, tokensUsed, remainingTokens, autoTurns, checkpoints/status updates) can be omitted independently.
The regression coverage only exercises an active goal. Please add cases for paused, budgetLimited, usageLimited, and Plan + limited states, and preserve the existing idempotence assertion that applying the system transform twice to the same output does not duplicate the reminder.
Local validation otherwise passed for me:
bun run typecheck
bun run lint
bun test (64 passed)
bun run build
bun run pack:dry-run
git diff --check main...HEAD
Once the distinct paused/limited semantics are preserved without reintroducing volatile counters, this should be ready for re-review.
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
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.
Summary
Fixes #13 by keeping the goal-mode system reminder byte-stable while an objective and mode remain unchanged.
Active goals currently interpolate live elapsed time, token usage, remaining budget, auto-continue count, checkpoints, and status into
output.system[0]on every model request. Prefix-based prompt caches therefore stop matching at the first changing counter, causing most of a long session's context to be processed as uncached input on every tool-call round trip.This change separates stable goal guidance from dynamic operational state:
Regression Coverage
The server-hook test now renders an active-goal system prompt, records changed token usage and a new assistant checkpoint, renders the prompt again, and requires the two outputs to be exactly equal. It also asserts that volatile token and checkpoint labels are absent from the system reminder.
Validation
bun run lintbun run typecheckbun test(64 passing)bun run buildnpm pack --dry-run