Skip to content

fix(chat): continue replies interrupted by compaction - #20867

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
rubencu:fix/compaction-midturn-truncation
Oct 20, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
rubencu:fix/compaction-midturn-truncation

Conversation

@rubencu

@rubencu rubencu commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Finish dashboard replies automatically when an inline compaction interrupts them.

The Claude ACP adapter can emit a partial answer, compact its context, and end the turn without producing more answer text. The dashboard persists the partial text as a completed assistant bubble and leaves the request unfinished.

Why it matters

A user sees a sentence stop midstream after Compacting... and receives no answer unless they manually ask the agent to continue.

Not a goal

  • Changing manual /compact behavior.
  • Changing ACP compaction notice parsing or terminal synthesis.
  • Changing compaction thresholds or provider-owned context state.

What changed (motivation → approach → change)

A synthesized compaction terminal arrives at turn end, so the accumulated answer still contains text emitted before compaction. That old fragment made the dashboard classify the turn as answered and skip its existing continuation branch.

src/kiro_crew/dashboard/chat_runner.py records where the most recent compaction started in the current segment's text, and the continuation gate judges only the text after that point. Every pre-compaction chunk still streams, flushes and persists. A segment cut after the compaction starts (a tool call, an approval card, a steer) begins a segment that is wholly post-compaction, so the gate judges that segment whole: a turn that goes quiet after its last tool is continued, and any answer after the tool suppresses the continuation.

A refusal is the one stop reason judged on the whole turn's text: its explanation answers the turn wherever it streamed, so a refusal explained before a compaction still takes the streamed-explanation refusal path, whose card quotes it, rather than the no-text refusal branch. The tool-refusal recovery's answered flag also stays on the whole turn's text, deliberately: it picks the body that forbids restating what the user already saw, and a pre-compaction fragment is on screen.

Trade-off: a turn that finished its answer before a turn-end auto-compaction, and produced nothing after it, now gets the one continuation as well. The continuation tells the model the summary records the completed work, so the cost is one extra turn that may restate or close the answer. Judging the pre-compaction text instead is the stopped reply this PR fixes, and no text test can tell a finished sentence from an interrupted one that happens to end at a full stop.

This keeps compaction inside the provider and leaves the durable Kiro Crew transcript intact, as required by docs/request-for-change/rfc-append-only-session-transcript.md §2.

Backwards compatibility

Compatible: completed replies, compaction notices, and manual /compact turns keep their existing behavior.

Removes nothing: the change only classifies which already-preserved answer text belongs after the compaction boundary.

Tests

test/test_post_compaction_continuation.py drives the real dashboard runner through a Compacting... control notice, a synthesized completed terminal and turn end:

Test Locks in
test_runner_continues_a_pre_compaction_fragment the transcript and live chunk stream keep the fragment; an unfinished reply queues one continuation, and post-compaction answer text suppresses it
test_a_segment_cut_after_compaction_is_judged_on_its_own_text narration and a tool call after the compaction: a turn that ends silently after the tool is continued, and a short answer after the tool suppresses the continuation even though the pre-compaction fragment was longer
test_a_refusal_explained_before_compaction_takes_the_streamed_refusal_path a refusal whose explanation streamed before the compaction gets the streamed-explanation card, which quotes it, and no continuation

Each case fails alone when its mechanism is removed: without the production change, test_runner_continues_a_pre_compaction_fragment[-True] fails; with a post-compaction buffer that outlives a segment cut, test_a_segment_cut_after_compaction_is_judged_on_its_own_text[-True] fails; with an offset a new segment does not reset, its [Done.-False] case fails; routing a refusal by its post-compaction text again fails test_a_refusal_explained_before_compaction_takes_the_streamed_refusal_path.

On 264f59464d (one commit directly on 5c1746933c, a clean rebase of 196eb4d095 with every per-file patch ID unchanged; main now carries #22320's longer timeout for the tree-scan facade-mirror test that failed shard 2 on the previous head): the chat runner, chat_turn, control-notice and compaction modules passed (46 modules, 1,768 tests), the refusal, empty-response and segment modules passed (30 modules, 699 tests), and so did the repository-wide facade-mirror, link-screen and dashboard-files composition guards (139 tests). Main moved the turn's prologue into phases (#22150), and this change's offset declaration sat in the moved prologue: _compaction_text_offset is now declared in _run_chat right after it reads the turn's locals, and the compaction-start site keeps main's turn._compaction_started copy beside the offset store. Main hoisted the turn's closures into dashboard/chat_turn/ (#22057), so the two flush blocks call _flush_text_stream(turn) as main's do; every other hunk replays line for line. Black, isort, flake8, mypy, Comment History, Brand Name, Harness Parity, the file-line cap, the flake-pattern and wait-discipline ratchets and the single-commit push guard passed.

Determinism proof on the previous head: 20 serial repetitions and 10 -n 4 --dist loadgroup runs beside test_dashboard_chat_empty_response.py and test_dashboard_chat_segments.py passed, and the module passed in a shuffled order (seed 27183).

Manual verification

N/A — the unit test drives the production runner event loop and asserts both the persisted transcript and queued recovery request.

Screenshots / video

N/A — no frontend code or rendered string changes.

Related Issues

Closes #20863

Pattern harvest

Rule candidate: review-prompt
Pattern: a terminal synthesized at turn end cannot identify which accumulated output was produced after an earlier stream boundary.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@rubencu
rubencu requested review from a team and KiroCrewCaptain as code owners October 15, 2026 15:35
@rubencu
rubencu requested a review from bolichen97 October 15, 2026 15:35
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 264f59464d2423d7ee013ed9fb811ad859faab06 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 264f59464d2423d7ee013ed9fb811ad859faab06 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Before merging, a human should accept the declared trade-off: a reply that was already complete before a turn-end auto-compaction now gets one extra continuation turn.

What this change ships

Inventory (4 items) — 4 justified

Intent: when an inline compaction cuts a dashboard reply short, the reply finishes on its own and the user doesn't have to ask the agent to continue. This is a FIX (#20863).

  1. A reply that stops at Compacting... and has no text after it now continues automatically — justified
  2. A reply that was already complete before a turn-end compaction also gets one continuation turn — justified
  3. Any answer after a tool call that follows the compaction, however short, stops the continuation — justified
  4. A refusal explained before the compaction still gets the refusal card that quotes it, with no continuation — justified

[FIRST-PRINCIPLES-REVIEWED] 264f594

Description read

[DESCRIPTION-READ] ccf57df2601ad5d4689f210ba5f045b49a71a06c27e0ce8e3f5a036123ba0ab1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — 🟡 CONCERNS

Design-level review of 264f59464d2423d7ee013ed9fb811ad859faab06 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

A reply that finished before a turn-end auto-compaction now gets a continuation it does not need. That costs an extra billed turn and shows a card falsely saying the reply stopped.

Watch

  • Finished answers are treated as interrupted. The gate now reads only turn.assistant_text[_compaction_text_offset:]. Take a reply that ends before a compaction the adapter runs at turn end, with nothing after it. The gate sees empty text, so should_continue_after_compaction fires. The chat then shows "ℹ️ The context was compacted mid-turn and the response stopped there — continuing automatically." and queues _COMPACTION_CONTINUE_MSG. This repeats on every turn that crosses the threshold. A long session stays near the ceiling, so this is the normal case there, not a rare one. The description accepts it as "one extra turn that may restate or close the answer". The PR does not say how often the Claude adapter compacts after a finished answer versus during one, so the cost is unmeasured.
    Clears when: the PR shows how often the adapter compacts at turn end versus mid-reply (adapter source, or a captured event sequence). Alternatively, it limits the continuation to segments where the compaction start arrived before the terminal stop. If that bounding signal does not exist, it gets a follow-up issue.

Suggestions

  • Move the offset tracking and the choice between _branch_answer_text and _continuation_answer_text into one helper in chat_utils_turn_recovery.py, next to should_continue_after_compaction. Then the rule that a refusal is judged on the whole turn and everything else only on the post-compaction text sits beside the gate it feeds. Today it is three loose locals in _run_chat, which the tests can only pin by regex over the source.

[DESIGN-REVIEWED] 264f594

Description read

[DESCRIPTION-READ] 1900d6975bdd21c87bb58f5bd7e1f4123aef249a4d2badced8e1e30a21dc57d3

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 264f59464d2423d7ee013ed9fb811ad859faab06 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 264f594

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 264f59464d2423d7ee013ed9fb811ad859faab06 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 264f594

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 15, 2026
@rubencu
rubencu force-pushed the fix/compaction-midturn-truncation branch from f7ce7dc to ca57e04 Compare October 16, 2026 20:43
@rubencu

rubencu commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: compaction-start offset into the current segment, zeroed by the first chunk of a new segment

  • fixed span=e48125549479: the post-compaction buffer outlived segment cuts

Legitimate. The buffer kept text across the tool-call, permission and steer cuts that empty assistant_text, so a turn that compacted, narrated, called a tool and then went quiet took the answer branch and skipped both the continuation and the empty-response ladder.
Fixed in ca57e04: the gate reads assistant_text[_compaction_text_offset:]. The offset is set when a compaction starts and zeroed when a chunk lands in an empty accumulator, so every cut site is covered without each one clearing it, and a cut with no text after it leaves nothing to judge.
test_a_segment_cut_after_compaction_is_judged_on_its_own_text[-True] fails on f7ce7dc and passes on ca57e04; its [Done.-False] case fails if a new segment does not reset the offset.

@rubencu

rubencu commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author
  • answered: a reply that finished before an automatic compaction

Yes, that turn gets the one bounded continuation, and that is the gate's documented rule: should_continue_after_compaction continues only when "the turn produced NO answer of its own after the compaction". A real (observed) terminal applies the same rule, because the runner clears assistant_text at that boundary.
The runner cannot tell a finished pre-compaction answer from an interrupted one without guessing at prose, which this gate deliberately avoids. The cost is one continuation (compaction_continue_retries < 1) whose wording says not to re-run completed steps; the alternative is the reported mid-sentence stop.
Same on ca57e04, which judges a segment that starts after the compaction (a tool call, approval card or steer) as a whole.

@rubencu

rubencu commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author
  • answered: an answer that finished and only then auto-compacted

It gets one continuation, by the contract this PR implements: should_continue_after_compaction documents "the turn produced NO answer of its own after the compaction", and an observed terminal already judges only post-boundary text because the runner clears assistant_text there.
Telling a complete pre-compaction answer from a cut-off one would need a prose detector, which the gate rules out on purpose. The continuation is one-shot (compaction_continue_retries < 1) and tells the model not to re-run completed steps, so the worst case is one redundant reply rather than a reply that stops mid-sentence.
Same on ca57e04, where text after a tool call, approval card or steer that follows the compaction is judged as its own segment.

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ready yet, but close. The offset approach fixes the segment-cut problem from the previous head: a turn that compacts, narrates, calls a tool and then goes quiet is now continued, and test_a_segment_cut_after_compaction_is_judged_on_its_own_text pins both directions.

Head reviewed: ca57e04. Bots read: Design CONCERNS, First Principles PASS, UX skipped, Opus no blocking, GPT no blocking, readiness action required (backend shards and E2E were still running when I read it).

What I verified:

  • Every site that empties turn.assistant_text sets it to "", so a stale _compaction_text_offset can only slice an empty string. The first chunk of a new segment zeroes the offset. No site truncates the accumulator to a non-empty value.
  • A turn with no compaction keeps offset 0, so _continuation_answer_text == _answer_text and nothing changes outside compaction turns.
  • This head merges cleanly with current main. On the merged tree, test/test_post_compaction_continuation.py passes (58 tests).
  • Main has no other fix for #20863.

🟡 1 should-fix: a refusal explanation that streamed before the compaction now repeats in the refusal card. Reproduced with a scratch runner test, details inline. This is the second Design Review watch item; the disposition replies answer only the first one.

The answered point about a finished pre-compaction answer getting one bounded continuation is a reasonable trade, and I do not raise it again.

Comment thread src/kiro_crew/dashboard/chat_runner.py Outdated
)

if _answer_text:
if _continuation_answer_text:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 A refusal explanation streamed before compaction now prints twice

The answer branch now keys on post-compaction text only. A refusal whose explanation streamed before the compaction started has no post-compaction text, so it skips this branch and reaches the text-less elif _stop_reason == STOP_REASON_REFUSAL: branch. That branch builds the card without streamed_text, so refusal_card_text adds the explanation again.

        if _continuation_answer_text:
            _flush_text_stream()
            _flush_segment(state, slot, turn.assistant_text, broadcast=False)
            turn._reply_flushed = True
            if _stop_reason == STOP_REASON_REFUSAL:

I reproduced it with the _drive_compaction_turn helper from this PR: events are an explanation chunk, started, the Compacting... notice, a synthesized completed, then EVENT_COMPLETE with stop_reason=refusal and RefusalInfo(category="CYBER", explanation=<same text>). On main the card reads "Response declined by the model. Content filter: cyber. Try rephrasing...". On this head the card also contains the explanation, so the user reads it twice. No continuation is queued in either case.

Why it matters: small and rare, but it is a behaviour change the description does not list, and the refusal path is outside the stated goal.

Suggestion: judge a refusal on the whole turn. For example, compute the gate text once and use it at both the flush block above and this branch:

_gate_text = _answer_text if _stop_reason == STOP_REASON_REFUSAL else _continuation_answer_text

A parametrized case of the probe above pins it. If you prefer to keep the change and list it in the description, I will withdraw this.

Rule: PR goal is frozen (AGENTS.md); description and diff fidelity.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 17, 2026
@rubencu
rubencu force-pushed the fix/compaction-midturn-truncation branch from ca57e04 to 1128be3 Compare October 19, 2026 16:44
@rubencu

rubencu commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

This round's push is 1128be347c, one commit on 88914fd0d1. It rebases over main's hoisted turn closures (#22057): the two flush blocks call _flush_text_stream(turn), and every other hunk replays line for line.

  • Design c0412b237c5d (refusal before compaction): fixed. A refusal is judged on the whole turn's text, so an explanation streamed before the compaction still gets the streamed-explanation refusal card. A new test pins it.
  • Design f5dadf439b88 (finished answer before compaction): kept as a stated trade-off, now in the description. The cost is one bounded extra turn; the alternative is the stopped reply this PR fixes.
  • First Principles ask (refusal-recovery answered flag): it stays on the whole turn's _answer_text, deliberately. The flag picks the body that forbids restating what the user already saw, and a pre-compaction fragment is on screen. The compaction continuation never fires on a turn with tool refusals, so the two do not overlap.

The fork runs on 1128be347c need approval.

@rubencu

rubencu commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • Pre-compaction text no longer counts as an answer: kept, as a stated trade-off. The description of 1128be347c now names it.

A turn that finished its answer before a turn-end auto-compaction, and produced nothing after it, now gets the one continuation. The continuation tells the model the summary records the completed work, so the cost is one extra turn that may restate or close the answer.
Counting finished-looking text (sentence punctuation) as answered would bring back the stopped reply this PR fixes. A reply interrupted between two sentences ends at a full stop too, and no text test tells the two apart. The continuation stays bounded at one per turn (compaction_continue_retries < 1).

@rubencu

rubencu commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • A streamed refusal before compaction reaches the no-text refusal branch: fixed in 1128be347c. The refusal branch is now keyed off _answer_text.

_branch_answer_text is the whole turn's _answer_text when the stop reason is a refusal, and the post-compaction text for every other stop reason. So a refusal whose explanation streamed before a compaction takes the streamed-explanation path again: its card quotes the explanation, and no continuation is queued.
test_a_refusal_explained_before_compaction_takes_the_streamed_refusal_path pins this. Routing the refusal by its post-compaction text again turns that test red.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 19, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this addresses my earlier comment. The new head is a rebase onto current main plus one change: the branch gate now uses the whole turn's answer text for a refusal and the post-compaction text otherwise (_branch_answer_text), at both the flush block and the answer branch. A refusal whose explanation streamed before the compaction now takes the streamed-explanation refusal path, so the card no longer repeats it.

Head reviewed: 1128be3.

What I verified:

  • The incremental diff against the previous head (ca57e04) is only that gate change, the matching source-order test update, and the new test test_a_refusal_explained_before_compaction_takes_the_streamed_refusal_path.
  • test/test_post_compaction_continuation.py passes on this head (59 tests).
  • With the gate reverted to _continuation_answer_text, the new test fails, so it pins the fix.
  • Non-refusal turns are unchanged from the previous head, which I already reviewed.

Looks good to me. The remaining maintainer step is CI: the workflow runs on this head are waiting for approval, so readiness is not passed yet. I will approve once the checks are green.

@rubencu
rubencu force-pushed the fix/compaction-midturn-truncation branch from 1128be3 to 57d1e36 Compare October 19, 2026 20:36

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked at 57d1e36. This head is a clean rebase of 1128be3 onto current main: the PR's own changes to chat_runner.py and test/test_post_compaction_continuation.py are line-for-line identical, and the PR reports mergeable with base main. The refusal double-print fix and its pinning test still hold, so nothing new to raise.

Good to ship. Approval still waits on fork CI: the readiness label is readiness: action required because the required runs on this head are held for maintainer approval. Once those run and readiness turns passed, this can be approved and queued for merge.

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Oct 19, 2026
@rubencu
rubencu force-pushed the fix/compaction-midturn-truncation branch from 57d1e36 to 196eb4d Compare October 20, 2026 00:39
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 20, 2026
@rubencu

rubencu commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Round push: 196eb4d095, one commit directly on aa71296bd9.

Merge conflict with main, resolved. Main's #22150 moved the chat turn's prologue into phases. That move conflicted with this change in chat_runner.py, because the _compaction_text_offset declaration sat in the moved prologue. It is now declared in _run_chat right after the turn's locals are read. The compaction-start site keeps main's turn._compaction_started copy beside this change's offset store. Every other hunk replays line for line.

Validation. The focused module passes ten serial runs. The 38 chat-runner, chat_turn, refusal, empty-response and compaction modules pass (1,468 tests). The script gates and ratchets pass.

The two PASS punchlines:

  • Design: run it on a real Claude backend that auto-compacts mid-answer. I have not run that from this session. The tests drive the runner with event sequences shaped like the ACP client's: a compaction start, text, and the terminal that AcpClient synthesizes at turn end. What remains is a manual check by someone with a Claude backend: in a long turn that crosses the auto-compact threshold, the reply should finish without a manual "continue".
  • First Principles: a turn-end auto-compaction after a finished answer costs one continuation. That is correct. When the compaction starts after the answer has finished, no text follows the offset, so the continuation runs once and costs one more model turn. I can't measure how often from here. It happens only when the finished answer is what pushed the session over the backend's compaction threshold, not on every turn. If that cost is too high, a follow-up can skip the continuation when the pre-compaction text already ends the answer. I have not built that.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Oct 20, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at 196eb4d, incremental since 57d1e36.

This is a rebase onto main, where _run_chat now reads its turn state from the turn object. git range-diff shows every added and removed line of this PR unchanged; only surrounding context moved. The new _compaction_text_offset local is declared, reset, set and read inside _run_chat itself with no nested function in between, so it needs no mirroring onto turn.

Verified locally on this head: test/test_post_compaction_continuation.py (59 passed) and every test matching compaction across the suite (1076 passed, 4 skipped).

Looks good to ship. Not approving yet: the readiness signal is still checking and backend tests, lint, E2E and desktop builds are still running on this head. I will approve once readiness reports passed.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 20, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

The only red check on this head is Backend Tests (3.12, 2), which fails on the test_facade_mirror_guards 120s timeout (tracked in #22004). That timeout is fixed on main by #22320, which merged today.

Could you rebase onto current main and push? Once CI is green on the new head I can re-check and merge it. Nothing else in the change needs to move.

@rubencu
rubencu force-pushed the fix/compaction-midturn-truncation branch from 196eb4d to 264f594 Compare October 20, 2026 18:42
@rubencu

rubencu commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 Done. This is rebased onto 5c1746933c, which includes #22320, and the new head is 264f59464d. It's a clean rebase, so every per-file patch ID is unchanged and nothing else in the change moved.

Verified on 264f59464d:

  • the chat runner, chat_turn, control-notice and compaction modules (46 modules, 1,768 tests);
  • the refusal, empty-response and segment modules (30 modules, 699 tests);
  • the repository-wide facade-mirror, link-screen and dashboard-files guards (139 tests);
  • the 24 script gates, the flake and wait ratchets, and the single-commit push guard.

The fork's runs on the new head wait for a maintainer to approve them before they start.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 20, 2026
@rubencu

rubencu commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author
  • Finished answers are treated as interrupted: open. The trade-off is the merging maintainer's to accept, and the First Principles lane on this head asks the same of a human before merge.

The description states the trade-off. A reply that was already complete before a turn-end compaction now gets one continuation, which may restate or close the answer. In exchange, a reply that a compaction cuts mid-turn is no longer left unanswered. This head is a clean rebase of 196eb4d095, with every per-file patch ID unchanged, so it is the same trade-off bolichen97 reviewed there.
I have not measured how often it happens. For the Claude adapter, an automatic compaction shows up as its started notice, and AcpClient synthesizes the terminal at the turn's natural end (_settle_claude_compaction in acp/client_usage.py). Nothing on this head counts how many of those starts follow a finished reply rather than interrupt one.
Next step, either way:
(a) the merging maintainer accepts the trade-off as described; or
(b) a follow-up issue measures turn-end against mid-reply compactions from captured event sequences. If finished replies turn out to be common, it limits the continuation to compactions that started before the terminal stop, where the stream carries a signal that tells the two apart. I can file that issue.

@rubencu

rubencu commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author
  • Move the offset tracking and the answer-text choice into one helper beside should_continue_after_compaction: valid, and deferred to a follow-up. It is not done on this head.

The point stands. Several of this change's pins (test_the_answer_branch_tests_the_answer_not_the_raw_segment, test_a_notice_only_turn_is_still_flushed) read the shape of the decision from the runner's source, because the branch chain sits inside _run_chat. One helper in chat_utils_turn_recovery.py would let those become unit tests. The end-to-end cases that fail without each mechanism would keep covering the behaviour.
bolichen97 asked for this head to be a rebase with nothing else moved, so that he can merge once CI is green. A refactor push now would hold its runs again without changing behaviour, so the extraction belongs in its own follow-up PR.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 20, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving on head 264f594. Gates checked on this head: readiness label is passed, required PR Readiness is green, no failing or pending checks, the AI review lanes report no BLOCK, the branch merges cleanly into main, and the linked issue is tier T1. The rebase onto main left the patch unchanged from the version reviewed earlier. Enabling squash auto-merge.

@bolichen97
bolichen97 merged commit 47fd517 into kirodotdev:main Oct 20, 2026
102 of 110 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic compaction can strand a partial reply

2 participants