Repository navigation
perf(cognition): message order monotone in stability — the byte-diff fix - #2418
Merged
Merged
Conversation
…ff verdict Consecutive-act prompt captures (always-on JsonlPromptCaptureSink) gave the byte-level verdict on why KV reuse plateaued at ~36% after #2415+ #2416: the system prompt is perfectly byte-stable (8,305 chars = the cached head), and the divergence is at MESSAGE #1 CHAR 0 — perception facts whose presence/wording flickers per act rendered ahead of the 21.8k append-only history block, so the prompt's dominant stable mass never extended the prefix. The message list's SHAPE changed act-over- act (8 parts vs 4). Fix: explicit assembly phases replacing insert-before-ask arithmetic — old turns → history (append-only) → trailing grounding (flickers) → facts (flicker) → ASK → pinned newest. Stable content is a strict prefix of the token stream; churn is behind it. Every prior lesson preserved by construction: facts stay before the ask and the ask after them (2026-07-20 parrot-loop bisect), pinned stays nearest generation (#392), grounding stays out of the system prefix (#205/#2415). Batteries: 130 green (deliberation, perception_facts, act_observe, working_memory, ratchets) — including the parrot-order pins. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The prompt-capture byte-diff found it: system is byte-stable (8,305 chars = exactly the cached head), and divergence is at message #1, char 0 — flickering perception facts render ahead of the 21.8k append-only history, so the stable mass never caches and reuse plateaus at ~36%.
Fix: explicit assembly phases — old turns → history → grounding → facts → ask → pinned. Stable content is a strict prefix; churn behind it; parrot-fix and #392 orders preserved by construction. 130-test battery green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo