Skip to content

fix(runtime): accept heading-style compaction sections and join truncated summary turns - #97

Merged
lg2m merged 1 commit into
mainfrom
fix/compaction-summary-validation
Sep 21, 2026
Merged

lg2m merged 1 commit into
mainfrom
fix/compaction-summary-validation

Conversation

@lg2m

@lg2m lg2m commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Both compaction summary is missing required sections: Intent, Decisions and constraints, Work state, Files touched, Errors, User messages failures in the operator's live session store (runs 06f25227… 2026‑09‑21 and 3bac851d… 2026‑09‑11) carried complete, well‑formed summaries. Two harness defects combined to reject them, leaving /compact unusable on long sessions and (for auto‑compaction) wedging the next prompt as "already attempted".

Root cause

  1. Validator required Heading:. validate_compaction_summary stripped numbering/markup then required the remainder to start with :. The model answered the numbered instruction with markdown headings (## 1. Intent on its own line, body beneath), so all six sections were reported missing.
  2. 2 048‑token output reserve + mid‑token join. COMPACTION_OUTPUT_RESERVE_TOKENS = 2_048 forced every real summary through the output‑truncation continuation path (3 turns in the live run). The run loop joined continued turns with \n even 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 as ProviderOutputTruncated.

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 unclear does 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_budget subtracts 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 → policy failure, prior compaction retained); re‑prompting the summarizer on a malformed reply is left to RR6 in docs/plans/run-reliability.md.

Tests

  • compaction_summary_validation_requires_every_section_heading: adds the exact ## N. Heading\n\nbody shape from the live store, bold/closed‑atx/plain headings, and the prose‑continuation negative case.
  • New a_summary_split_across_truncated_turns_is_joined_without_a_seam: fake provider cuts the summary at Decis|ions and Fil|es across two truncated turns; compaction completes, the stored summary equals the original byte‑for‑byte, and the next prompt sees the joined text. New AutoCompactScript::Truncated in 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).

…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.
@lg2m
lg2m added this pull request to stack #98 September 21, 2026 04:49
@lg2m
lg2m merged commit 54e2b86 into main Sep 21, 2026
4 checks passed
@lg2m
lg2m deleted the fix/compaction-summary-validation branch September 21, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant