Skip to content

Fix prompt cache invalidation for active goals#17

Open
brandon93s wants to merge 1 commit into
prevalentWare:mainfrom
brandon93s:fix/cache-stable-system-reminder
Open

Fix prompt cache invalidation for active goals#17
brandon93s wants to merge 1 commit into
prevalentWare:mainfrom
brandon93s:fix/cache-stable-system-reminder

Conversation

@brandon93s

Copy link
Copy Markdown

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:

  • 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.

Validation

  • bun run lint
  • bun run typecheck
  • bun test (64 passing)
  • bun run build
  • npm pack --dry-run

nemowang2003 added a commit to nemowang2003/opencode-goal-plugin that referenced this pull request Jul 21, 2026
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.

[Bug]: Prompt-cache hit rate collapses (85%+ → ~40%) for active goals — live-mutating counters injected into the cached system prompt

1 participant