Skip to content

0.1.82: keep the system prompt static so Claude's cache holds (token burn fix) - #98

Merged
pathscale merged 1 commit into
masterfrom
fix/cache-stable-system-prompt
Aug 4, 2026
Merged

pathscale merged 1 commit into
masterfrom
fix/cache-stable-system-prompt

Conversation

@pathscale

Copy link
Copy Markdown
Owner

The problem: fast Claude token burn

Three pieces of per-turn dynamic content were appended to the system prompt, and all three change every turn:

  1. the state snapshot (items, PR rows, ids),
  2. the last turn's directive receipts,
  3. the account-usage sentence (figures climb each turn).

A system prompt that changes every turn never caches. On a long conversation Claude then re-bills the entire history at full input price instead of the ~10%-cost cache read it should be. The usage ledger showed 500k–900k input tokens per turn on an ~800-message project, and the app's own "cache miss?" chip had been flagging exactly this.

The fix

Move all three onto the user turn (where the task manager already carries its own lists). They're regenerated fresh from the store each turn, so they need no compaction survival and belong where changing content is cheap.

The system prompt is now stable across a conversation — repo rules, per-turn instructions, compaction notes, checkpoint + memory locations — so the history reads from cache instead of being re-sent in full. The agent still receives everything (snapshot + receipts + usage now lead the user message; prompt_echo/I/O panel reflects it).

Verify

  • cargo test -p az-gui — 130 pass; cargo fmt --check + clippy clean
  • Live confirmation to watch after merge: the "cache miss?" chip should stop appearing and per-turn input tokens should drop sharply (cache-read figures rise) on a continuing conversation.

The per-turn state snapshot (items, PRs, ids), the last turn's directive
receipts, and the account-usage sentence were all appended to the system
prompt, and all three change every turn. A system prompt that changes
every turn never caches, so on a long conversation Claude re-billed the
whole history at full input price instead of the cache read it should
have been. The ledger showed 500k-900k input tokens per turn on an
800-message project, and the app's own "cache miss?" chip had been
flagging it.

Move all three onto the user turn, where changing content is cheap and
where the task manager already carries its own lists. Regenerated fresh
from the store each turn, they need no compaction survival. The system
prompt is now stable across a conversation (repo rules, per-turn
instructions, notes, checkpoint and memory locations), so the history is
read from cache rather than re-sent in full.

Bump to 0.1.82.
@pathscale
pathscale merged commit a3b6eb4 into master Aug 4, 2026
1 of 2 checks passed
@pathscale
pathscale deleted the fix/cache-stable-system-prompt branch August 4, 2026 21:49
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.

1 participant