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
{{ message }}
Repository navigation
Audit prompt_reveal cache cost on multi-topic sessions #346
Prompt-reveal rescore (#334) re-scores at every user turn. Cache invalidation now happens whenever the SELECTED rows change at a turn boundary. On a local seat (~1.7k t/s prefill at 128k context) a full bust costs minutes. The freeze existed because of #162 ("every memory write busts the prompt cache") and #165 (92% of lifetime busts were self-writes). We changed that policy on correctness grounds; the cost side is unmeasured.
Change
Multi-topic session audit on the live host:
Drive one session through 5–8 unrelated topic turns (build question → auth question → docs question …), warm store.
Count from evidence + status: epoch_recompute reason=prompt_reveal events, invalidations, measured prompt-cache read share per turn (the badge's measured receipts).
Compare against the same script on the pre-fix build (frozen epochs): tokens saved by better retrieval vs tokens spent on busts.
Acceptance
A table in this issue: busts per session, cache-read share, net token delta. Then a keep/tune decision (tune knobs: re-score only when the abstain/overlap state flips; guided cap; budget).
Footguns
Keep the seat quiet during measurement (leftover harness traffic skews both timing and cache receipts — measured before).
The comparison build differs in TWO ways (rescore + hint channel); to isolate rescore, run the audit with guided rows absent (store with no user-guided tags).
Measured: per-turn rescore is cheap on the provider cache (#346, 2026-11-07 night)
Harness: chain-cache.ts in the bench repo — one session, 6 topic turns (test-suite / tax / deploy / rate-limit / haiku / repeat-of-1) over a 10-row seeded store (2 guided), autoCapture: false so only rescore moves the block. Real opencode serve + recording proxy + local seat. Transports: V2 API (POST /api/session, /prompt, /experimental/.../wait).
Total input 1934, cache.read 74,219 — 97.5% cache share. Block frozen at 236 chars: the SAME single row (test-suite) rode all six turns; the tax, deploy and rate-limit turns got zero relevant rows.
Why the bust is small
The wire shows the block rides at the END of the system message — the divergence point sits after ~9.7k stable prefix tokens, so a selected-row change re-prefills only the tail: 68–427 input tokens/turn. Turn 5 (guided-only, biggest content move) is the one real spike at 3257.
Note for docs: the status invalidations counter counts every byte-moving recompute and OVERSTATES provider cost — receipts are the honest signal.
Footguns found building this:
POST /api/experimental/session/{id}/wait returns instantly when the session is not marked busy YET — the prompt is queued async. Poll for a NEW assistant receipt, not just wait.
OPENCODE_MEMORY_DIR resolves against the serve process cwd (the repo copy), not the driver's — pass an absolute path or the plugin silently writes a second store.
POST /api/session rejects a model field (400); the profile's default model is the source of truth.
Table (bench@b53a102, run dirs results-cache-audit-on / results-cache-audit-pin, per-turn rows in audit.json): with rescore ON, cache-read share 94.4% vs 97.5% frozen; net rescore cost ~344 tok/turn; invalidations land on prompt_reveal boundaries only, matching the #340 contract (bytes move when SELECTED rows change).
Decision: KEEP rescore. 3.1 pp cache share and ~344 tok/turn buy back the later-topic rows the freeze hid (#340 was a correctness bug; correctness outranks the cache delta). Tune knobs (re-score only on abstain/overlap flip, guided cap, budget) not needed at this cost; revisit if the per-turn delta grows with store size.
Activity
abogartz commentedon Nov 7, 2026
Measured: per-turn rescore is cheap on the provider cache (#346, 2026-11-07 night)
Harness:
chain-cache.tsin the bench repo — one session, 6 topic turns (test-suite / tax / deploy / rate-limit / haiku / repeat-of-1) over a 10-row seeded store (2 guided),autoCapture: falseso only rescore moves the block. Realopencode serve+ recording proxy + local seat. Transports: V2 API (POST /api/session,/prompt,/experimental/.../wait).Fixed build (
chain-audit-on, branch @ee769ef) —prompt_revealfires every turn (invalidations 5/6):Total input 3999, cache.read 67,585 — 94.4% cache share.
Frozen baseline (
chain-audit-pin@29268ef) — block computed once, never moves:Total input 1934, cache.read 74,219 — 97.5% cache share. Block frozen at 236 chars: the SAME single row (test-suite) rode all six turns; the tax, deploy and rate-limit turns got zero relevant rows.
Why the bust is small
The wire shows the block rides at the END of the system message — the divergence point sits after ~9.7k stable prefix tokens, so a selected-row change re-prefills only the tail: 68–427 input tokens/turn. Turn 5 (guided-only, biggest content move) is the one real spike at 3257.
Verdict: KEEP prompt_reveal
invalidationscounter counts every byte-moving recompute and OVERSTATES provider cost — receipts are the honest signal.Footguns found building this:
POST /api/experimental/session/{id}/waitreturns instantly when the session is not marked busy YET — the prompt is queued async. Poll for a NEW assistant receipt, not just wait.OPENCODE_MEMORY_DIRresolves against the serve process cwd (the repo copy), not the driver's — pass an absolute path or the plugin silently writes a second store.POST /api/sessionrejects amodelfield (400); the profile's default model is the source of truth.abogartz commentedon Nov 8, 2026
Table (bench@b53a102, run dirs results-cache-audit-on / results-cache-audit-pin, per-turn rows in audit.json): with rescore ON, cache-read share 94.4% vs 97.5% frozen; net rescore cost ~344 tok/turn; invalidations land on prompt_reveal boundaries only, matching the #340 contract (bytes move when SELECTED rows change).
Decision: KEEP rescore. 3.1 pp cache share and ~344 tok/turn buy back the later-topic rows the freeze hid (#340 was a correctness bug; correctness outranks the cache delta). Tune knobs (re-score only on abstain/overlap flip, guided cap, budget) not needed at this cost; revisit if the per-turn delta grows with store size.