Conversation
…on overflow
The note Codewhale leaves when it makes room used a prompt and header
taken from Codex's templates, and the header said "another language
model" had done the earlier work. The note had no fixed layout and no
rule to carry an earlier note forward.
- New prompt with fixed headings (Objective, User direction, Permissions
and limits, Done, Changed files, Still running, Verification left, Open
questions, Next action, Reference), a fold-in rule for an earlier note,
and one HANDOFF_SECTIONS list shared with the quality retry. "Still
running" leaves agents out; the agent topology message stays the only
source of agent state.
- New header ("Codewhale handoff note. ...") that says accurately what is
kept above (recent user messages and the latest round, the oldest
possibly shortened), and a closing that grants nothing new.
- Detection: a new checkpoint is recognised only structurally (header
prefix plus the provenance block). Substring matching is kept for the
two legacy markers only, so a user message quoting "Codewhale handoff
note" is no longer dropped. Old checkpoints with provenance still pass
the wire check and are replaced, not stacked. The bare-marker fallback
for system-prompt carriers is legacy-only too, so host text quoting the
new phrase is never truncated.
- Overflow retry: drop_oldest_history_messages never drops the newest
checkpoint or the instruction; when nothing else can go, the pass fails
with the provider's context error instead of summarizing without the
previous note.
- Removed the "ported from Codex" comments and the two stale lexicon
allowlist entries.
Verification:
- node crates/tui/src/compaction/validate_survival_contract.mjs:
ok 12 before, ok 14 after (structural fixtures, not a quality eval)
- scripts/dev-cargo.sh test -p codewhale-tui --lib -- <filter>:
compaction 158 passed; chat:: 147 passed; checkpoint 64 passed;
restore 161 passed; last_round 17 passed; runtime_handoff 19 passed;
survival_contract 5 passed; worker_compacts_past_its_context_window 1
- cargo fmt --all -- --check: ok
- clippy -p codewhale-tui --all-targets --all-features with CI flags: clean
- check-lexicon.py: 363 findings before and after, none in compaction.rs
- blocking-calls, dead-code, command-crate-boundaries, module_graph: 0
- changelog gates: sync, web derive, check-versions, contributor credit,
vitest public-copy 6 passed
No-Issue: original compaction handoff text
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The header claimed the latest round was kept above the note "as they were". It is not: replacement_messages keeps only the last two tool exchanges of a long round (plus the user's text), and bound_last_round shortens last-round tool results over 8 KB with a truncation marker. A model trusting the old header would assume it still had the whole round word for word. The header now says the last steps of the current round are kept, that long tool output is shortened and marked, that earlier steps of the round exist only in the note, and to rerun a command or reread a file when the full output matters. A new test, summary_header_matches_what_replacement_history_keeps, builds a three-step round with an oversized last result, checks the first step is dropped and the last result carries the marker, and checks the header describes both, so the two cannot drift apart again. Tests (CARGO_BUILD_JOBS=3 scripts/dev-cargo.sh test -p codewhale-tui --lib): - compaction: 159 passed, 0 failed - last_round checkpoint: 82 passed, 0 failed node validate_survival_contract.mjs: 14 fixtures ok cargo fmt --check ok; clippy -p codewhale-tui (CI flags) clean; blocking-calls, dead-code, command-crate-boundaries, module_graph: exit 0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Hmbown
force-pushed
the
feat/original-compaction-handoff
branch
from
September 27, 2026 02:55
8eacfac to
0bea70e
Compare
This branch has not been deployed
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.
When Codewhale makes room, it leaves a note for the next turn. That note's prompt and header were taken from Codex's templates, and the header told the model that "another language model" had done the earlier work. This PR replaces both with original text, gives the note a fixed layout, and fixes two ways the note or the user's own words could be lost.
What changed
The handoff text (
crates/tui/src/compaction.rs)HANDOFF_SECTIONSis one list shared by the first request and the quality retry.summary_header_matches_what_replacement_history_keeps) ties this wording to whatreplacement_messagesandbound_last_roundkeep. The closing says the note grants no new permissions.Detection
Overflow retry
drop_oldest_history_messagesnever drops the newest checkpoint or the trailing instruction.Where this differs from the approved design
LEGACY_V2_SUMMARY_HEADER, the full copied paragraph, for the wire check. This PR checksstarts_with(LEGACY_V2_COMPACTION_SUMMARY_MARKER)plus the provenance block. The provenance block is what makes the check safe, so the copied paragraph no longer needs to be in the source. Only the marker sentence stays, as a detection constant next toLEGACY_COMPACTION_SUMMARY_MARKER.strip_summary_textandextract_compaction_summary, because they read only engine-authored carriers. They do not: a runtime-thread carrier is the host's base system prompt with the summary section merged in. A project instruction that mentions "Codewhale handoff note" would have cut the system prompt short at that point. New carriers are always wrapped in the begin/end delimiters, so the bare-marker fallback now matches only the legacy markers. A test covers host text that quotes the new phrase.Verification
node crates/tui/src/compaction/validate_survival_contract.mjs: 12 fixtures passed on origin/main before the change, 14 after. The two new fixtures are a legacy-v2 checkpoint replaced by the new note, and a user quote of the new marker that must be kept. This check is structural only, not a quality eval.CARGO_BUILD_JOBS=3 scripts/dev-cargo.sh test -p codewhale-tui --lib -- <filter>:compactionchat::checkpointrestorelast_roundruntime_handoffsurvival_contractworker_compacts_past_its_context_windowNew tests:
cargo fmt --all -- --check: ok.clippy on codewhale-tui with the CI flags (
--all-targets --all-features --locked -D warnings): clean.scripts/check-lexicon.py: 363 findings before and 363 after, none incompaction.rs. The two stale allowlist entries are removed.check-blocking-calls-budget.py,check-dead-code-budget.py,check-command-crate-boundaries.pyandsplit/module_graph.py --checkall exit 0.CHANGELOG gates:
sync-changelog.shand the web derive scripts ran;check-versions.sh --range-audit-advisoryreports OK;check-contributor-credit.py v0.10.0reports every contributor credited;vitest lib/public-copy.test.ts: 6 passed.No paid provider calls were made.
Not done / risks
No-Issue: original compaction handoff text
🤖 Generated with Claude Code