Skip to content

Commit ebfc3ea

Browse files
feat(insertion-normalization): pin volatile reminder blocks so mid-history rewrites stop busting the cache
Claude Code re-serializes <system-reminder> hook blocks inside otherwise-stable user messages later in the session — moving one into its own message or merging it into a neighbour — which edits history mid-prefix and re-bills everything after the edit (reported independently as anthropics/claude-code#76606; measured here as the splice/insert-mid class, ~40 kB re-billed per unmitigated hit on a real session). The extension keeps a per-conversation canonical model of the message history keyed by content identity (message-hash.mjs: content hash + occurrence ordinal — position-independent, so repeated identical reminders stay distinct). Incoming volatile blocks are pinned to their first-seen serialization: when CC re-shapes an old reminder, the forwarded bytes keep the canonical form and the prefix survives. A history that stops matching the model (compaction, true rewrites) resets honestly rather than forcing a stale canon — pins survive the reset, order assumptions do not. Gated off by default: CACHE_FIX_INSERTION_NORMALIZE=1 enables normalization, CACHE_FIX_VOLATILE_PIN=1 the pinning. State persists under the state dir and survives proxy restarts. Measured on live traffic (513-request session, 2026-07-28): every observed splice/insert-mid pair forwarded with 0 re-billed bytes; the canonical-order invariant, cross-request stability and sequence gates all report 0 violations over 2.5 GB of captures. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 23346ac commit ebfc3ea

5 files changed

Lines changed: 2029 additions & 0 deletions

File tree

proxy/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"workflow-agent-id-synthesis": { "enabled": true, "order": 365 },
1616
"image-retry-circuit-breaker": { "enabled": true, "order": 370 },
1717
"read-dedupe": { "enabled": true, "order": 380 },
18+
"insertion-normalization": { "enabled": true, "order": 395 },
1819
"cache-control-normalize": { "enabled": true, "order": 400 },
1920
"messages-cache-breakpoint": { "enabled": true, "order": 410 },
2021
"ttl-management": { "enabled": true, "order": 500 },

0 commit comments

Comments
 (0)