Repository navigation
fix(runtime): accept heading-style compaction sections and join truncated summary turns - #97
Merged
Merged
Conversation
…ated summary turns Both `compaction summary is missing required sections: Intent, Decisions and constraints, Work state, ...` failures in the operator's live store carried complete, well-formed summaries. Two defects combined: - `validate_compaction_summary` required a colon after the section name, so a markdown `## 1. Intent` line with the body beneath it failed every heading at once. A heading line is now the section name followed by a colon or by nothing else; a line that continues into prose still does not count, so body text cannot satisfy a section. - The summarizer's output reserve was 2 048 tokens, so every real summary went through the output-truncation continuation path, and the run loop joined the continued turns with a newline even though the provider cut the previous turn mid-token (`Decis` + `ions and constraints`). Turns following a truncated turn are now appended verbatim, and the reserve is 8 192 (still bounded by the model's cap) so a long session's summary is one turn and continuation is the exception rather than the rule. Regression tests: the exact heading shape from the live store, the split-heading join across two truncated turns, and the effective output cap. `docs/design/tools.md` documents the accepted heading forms and the reserve.
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.
Summary
Both
compaction summary is missing required sections: Intent, Decisions and constraints, Work state, Files touched, Errors, User messagesfailures in the operator's live session store (runs06f25227…2026‑09‑21 and3bac851d…2026‑09‑11) carried complete, well‑formed summaries. Two harness defects combined to reject them, leaving/compactunusable on long sessions and (for auto‑compaction) wedging the next prompt as "already attempted".Root cause
Heading:.validate_compaction_summarystripped numbering/markup then required the remainder to start with:. The model answered the numbered instruction with markdown headings (## 1. Intenton its own line, body beneath), so all six sections were reported missing.COMPACTION_OUTPUT_RESERVE_TOKENS = 2_048forced every real summary through the output‑truncation continuation path (3 turns in the live run). The run loop joined continued turns with\neven though the provider cut mid‑token ("33 started-"⏎"+RR7","…sess"⏎"ions/execution.rs"), corrupting text and splitting headings across lines. Any summary > 4×2 048 tokens also failed asProviderOutputTruncated.Changes
sessions/compaction.rs: a heading line is the section name (optionally numbered / marked up) followed by a colon or by nothing else.1. Intent: …,## 1. Intent,**Intent**,### Errors ###all match;Intent was uncleardoes not, so body prose still cannot satisfy a section.sessions/execution.rs: turns that follow a truncated summarizer turn are appended verbatim; a newline separates only completed turns. Reserve raised to 8 192 tokens (still.min(model.max_output_tokens);summarizer_message_byte_budgetsubtracts it, so the input window shrinks accordingly).docs/design/tools.md: documents the accepted heading forms and the reserve.No schema, protocol, or persistence changes. Failure policy is unchanged (malformed summary →
policyfailure, prior compaction retained); re‑prompting the summarizer on a malformed reply is left to RR6 indocs/plans/run-reliability.md.Tests
compaction_summary_validation_requires_every_section_heading: adds the exact## N. Heading\n\nbodyshape from the live store, bold/closed‑atx/plain headings, and the prose‑continuation negative case.a_summary_split_across_truncated_turns_is_joined_without_a_seam: fake provider cuts the summary atDecis|ionsandFil|esacross two truncated turns; compaction completes, the stored summary equals the original byte‑for‑byte, and the next prompt sees the joined text. NewAutoCompactScript::Truncatedin the harness.compaction_sends_and_persists_the_effective_output_cap: updated for the 8 192 reserve, with the prior‑answer size derived from the configured cap so the prompt run overflows storage while the summarizer fits.Verification
cargo test -p qq-core(680 tests) ✅cargo test --workspace✅cargo fmt --all -- --check✅cargo clippy --workspace --all-targets --all-features -- -D warnings✅Impact
Compaction hot path only; no effect on prompt‑run latency. The summarizer request now reserves 6 144 more output tokens, so on window‑bounded models it reads slightly less transcript per step (bounded folding already handles multi‑step). Amplification per compaction drops from ~3 sends to 1 for typical long‑session summaries.
Tracking
Linear: the Executor Linear connection needs OAuth reauthorization (
invalid_grant), so I could not query/create the DEV issue from the agent; please link the issue once reconnected. Plan:docs/plans/run-reliability.md(pre‑RR6 hotfix; audit row R02).