Skip to content

perf(cognition): append-only history before churning grounding — tail order fix - #2416

Merged
joelteply merged 1 commit into
canaryfrom
fix/append-only-history-before-churning-grounding
Aug 23, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/append-only-history-before-churning-grounding

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

#2415's A/B failed at 20–22% cached: the churning trailing grounding rendered ahead of the append-only result history, re-prefilling it every act. New tail order: history → grounding → pinned newest. The history block now extends the KV prefix act-over-act. 94-test battery green; verdict rides the next round's prefill probes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…g — the tail order the A/B demanded

The #2415 A/B failed: 20-22% cached on 34-42k prefills, the old ceiling
wearing a new hat. Monitor data named why — in eval turns the
conversation barely grows; the prompt's bulk is the working-memory
result history, and the first cut placed the churning trailing
grounding (workspace-map/kanban) AHEAD of it, re-prefilling the whole
append-only history on every grounding change.

Order in the tail IS the fix: recent-results history (byte-stable,
growing head) → churning trailing grounding → pinned newest result.
The history block extends the reusable KV prefix act-over-act; churn
now costs only itself + the pinned tail. (recent_results pop_front
eviction rotates the head only once the window-derived cap fills —
append-only for most of a task on a big lane.)

Batteries: 94 green (deliberation, working_memory, rag_source_faculty,
ratchets).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply enabled auto-merge (squash) August 23, 2026 21:07
@joelteply
joelteply merged commit 9557cfa into canary Aug 23, 2026
5 checks passed
@joelteply
joelteply deleted the fix/append-only-history-before-churning-grounding branch August 23, 2026 21:19
joelteply added a commit that referenced this pull request Aug 23, 2026
…ff verdict (#2418)

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.


Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant