Skip to content

fix(channels): replay a turn abandoned after a transient compaction failure - #11243

Merged
iamwhatever merged 2 commits into
mainfrom
fix/transient-compaction-retry-8256
Sep 21, 2026
Merged

iamwhatever merged 2 commits into
mainfrom
fix/transient-compaction-retry-8256

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What

A turn abandoned after a transiently failed compaction is no longer dropped on the two surfaces PR #8215 left out. When the ACP layer reports last_compaction_transient as True, nothing has been emitted this turn, and the surface's retry budget is unspent, the abandoned message runs again. A permanent verdict keeps the current give-up behaviour on both surfaces.

  • src/kiro_crew/slack/handler.py — the native Slack handle_message STOP_REASON_COMPACTION_FAILED branch.
  • src/kiro_crew/messaging/dispatch.py — drive_turn's STOP_REASON_COMPACTION_FAILED branch (the shared pipeline for Teams, Webex, WhatsApp, Feishu, iMessage, WeCom, Weixin).

Why

KAS runs summarization as a separate billed model call on the session's own model, so a MODEL_TEMPORARILY_UNAVAILABLE throttle fails the summarization, the backend abandons the turn, and the surface sees STOP_REASON_COMPACTION_FAILED. #8215 taught the dashboard to tell a throttled compaction from an overflowed one (compaction_failure_is_transient, last_compaction_transient on LLMProvider) and to re-queue the message for the former. Both of these sites still returned unconditionally after the reset, so on Slack and every channel on the shared pipeline a throttle the next attempt would clear silently ate the user's message.

Live evidence on the base (39e732b8a): slack/handler.py:4168 and messaging/dispatch.py:818 both reset and return with a "No re-queue" comment; neither reads the verdict.

How

Each surface replays through its own mechanics — neither is a port of the dashboard's _queue_recovery.

Slack (native handler). The replay is a nested handle_message call with every argument unchanged, made from the STOP_REASON_COMPACTION_FAILED branch after the reset. That is what makes it Slack's own replay rather than a re-dispatch: it resolves the same session (linked, pinned or self-owned), keeps the same activation (review mode stays private), runs while the outer task still owns the attachment temp files the text refers to (their cleanup is the dispatcher's task-done callback, which fires after the nested call returns), and needs no queue drain from whoever dispatched the original — the interaction paths dispatch handle_message with only a discard callback. The abandoned attempt sets _acquired = False (its permit died with the session the reset popped; the successor's belongs to the replay, whose own finally releases it), finalizes its own reaction ladder and stall watchdog, deletes its "Working…" block and any 💭 reasoning placeholder a thinking-only attempt left above where the answer would have gone, posts ⟳ Compaction failed — retrying… directly (visible, never persisted, never mirrored), and returns as soon as the nested call does — so the conversation log records the user's message exactly once, with the reply the replay produced. The budget travels with the message as _CompactionReplay.attempt (_COMPACTION_FAILED_RETRIES = 2, same count and reasoning as the dashboard); no per-thread state. The nested call receives the user's text as it arrived (_user_text, captured before the cancelled-turn preamble is folded into text for the model after a soft-cancel): the replay derives its own preamble from its own one-shot gate, and the conversation log records what the user typed, never a preamble a previous attempt prepended.

An earlier head of this PR did this through sessions.enqueue + the gateway's _on_done drain; the GPT lane's three fenced findings on that head — interaction-path dispatches have no drain, the requeue lost attachment ownership, and the notice was persisted as a completed turn — are all properties of the queue route, and the nested call removes the route rather than patching each.

Shared pipeline (drive_turn). The pipeline has no queue of its own — five of the seven channels riding it keep none at all — and a channel's renderer is one message's output surface that finalizes on its first DONE (_finalized latches in the WhatsApp/Teams renderers). So the replay happens inside the same drive_turn call, into the same renderer: the driver renders through _TransientCompactionRetryGuard, a Renderer that forwards every event to the channel's renderer via its own dispatch (so current_tool_name bookkeeping lands where the handlers read it) and holds back exactly one DONE — the abandoned attempt's, and only when the completion is STOP_REASON_COMPACTION_FAILED, nothing was emitted through it (text, tool call or permission prompt), the provider's verdict is True, and a retry is still available. The acquire→build→drive block becomes a loop bounded by that budget: on a held completion the session is reset and the message re-runs on a freshly acquired session (the finally's single release lands on the successor, as before). If the reset itself fails the held DONE is released so the channel finalizes the reply rather than hanging. Budget: per turn, _COMPACTION_FAILED_RETRIES = 2.

Everything else in the branch is unchanged: the reset still happens on every compaction-failed completion, and the post-turn bookkeeping (record_success, persist, notice, audit) runs once for the turn that landed — with the first acquire's is_new: a replay reacquires after a reset and may read is_new=True for a conversation that has existed for hours; that attempt-local value is right for building the replay's context (the fresh runtime needs the session-start injection again) and wrong for the new-conversation bookkeeping (title, dashboard surfacing), which would otherwise re-run over an existing conversation. "Emitted" also covers a consumed mid-turn steer: the backend folded a correction the replayed user_text does not carry, so a steered turn keeps the give-up behaviour rather than silently dropping the accepted correction.

A Stop during the reset gap keeps the message dropped (second commit). Between the abandoned attempt's reset() and the successor's get_or_create the key has no live session. A channel /stop (or Slack !stop) landing there found nothing to cancel, stop_turn recorded nothing for a session-less key, and the replay would have run the very prompt the user stopped — the GPT lane's fenced finding on the first head. The user's intent has to win over the recovery, the same way the dashboard's _stop_generation checks make it win there, so:

  • SessionManager gains note_stop(key), open_replay_gap(key), close_replay_gap(key) and await_replay_gap(key) (session_lifecycle.py). The gap does two jobs across the reset->reacquire window: Stops stay recordable, and every other task's get_or_create for the key waits until the gap closes (get_or_create awaits it before taking its reservation; the owning task passes through). Without the second job a newer message for the same key arriving in that window would claim the successor first and run -- and persist -- ahead of the older message's replay. The owner closes the gap only when its whole turn has settled and the permit is released -- not at the successor claim: a waiter admitted then would park on the successor's semaphore, and a further retry's reset would pop that session from under it, stranding the message until a gateway restart. So one gap spans the whole retry sequence, and a message that waited behind it finds an idle successor. close_all releases any waiter (their claim then meets the closing refusal), and a gap is also dropped on the per-key teardown paths. While a key sits in a replay gap, a Stop is recorded in stop_requests even though no session exists; outside one, a Stop on a session-less key still records nothing (the existing contract, kept so the dict grows only with conversations that exist, and its test still passes). stop_turn records through note_stop before its idle return. Gap membership and the session-less bucket are keyed canonically, so a Slack Stop issued under the bare thread ts and a turn reading under slack:<ts> meet in one bucket.
  • The channel Stop paths that cancel the provider directly instead of calling stop_turn now record first: stop_running_turn (Teams) and the Webex, WeCom and Weixin _handle_stop call note_user_stop (new, messaging/commands.py, probed with getattr like the rest of that seam) before their busy check. WhatsApp goes through stop_turn; Feishu and iMessage offer no Stop. Slack's two !stop handlers (events.py _route_message and the handler.py fallback) gate stop_turn on has_session / a registered task -- both false for a turn inside the gap that started from an interaction -- so they too call note_user_stop before those checks -- against the thread's owning session (get_session_for_thread(thread) or key, the way the OPTIONS expiry resolves it), because a linked thread's turns and their replay run under the dashboard session that owns it and that is the key the replay reads. A discovery tripwire in test_messaging_dispatch.py scans every */transport_dispatch.py that rides drive_turn and fails if one cancels directly without recording.
  • Both replay sites snapshot sessions.stop_generation(key) when they acquire their session, open the gap before the reset, close it once the successor exists (and defensively in the finally), and re-read the count as late as possible: drive_turn right before the replay's driver.run (the held DONE is released instead, so the channel finalizes the abandoned reply), the Slack handler inside the replay, right beside the existing early-cancellation check that precedes the prompt (the replay carries the first attempt's snapshot in _CompactionReplay.stop_gen_at_entry, closes the gap once it has acquired, and ends without a turn if the count moved). The residual window is the same one every fresh turn already has between its last check and the stream opening.

The same pre-replay look also covers supersession by /new: every channel on the pipeline persists the new conversation generation before acknowledging (reserve_new_generation -> SessionManager.reserve_generation), so drive_turn snapshots sessions.max_generation(bucket) for the key's bucket at its first acquire (session_conversation_generation, generation grammar from split_dm_session_key) and re-reads it before the replay; a change means the conversation the message belonged to is over, and the held DONE is released instead of running the retired prompt after the fresh-conversation ack. Keys without a generation grammar (Slack threads) and doubles without the reader read as 0 on both sides, so they can never manufacture a supersession. Slack has no /new; its session-removing commands (!agent, !ta, !project) change how the same thread continues rather than retiring it, so the nested replay simply runs under the new binding.

Tests

Both directions per surface, plus the budget and the failure edges. Red on the unmodified base for the positive direction (verified with a git archive main copy: 7 test_messaging_dispatch.py tests and 2 test_slack_handler.py tests fail there; the negative-direction tests pass on base, as they pin existing behaviour).

test/test_slack_handler.py::TestTransientCompactionRetry

  • transient → the message is streamed twice, one reset, a fresh session for the replay, the retry notice and then the answer posted, the conversation log carries the user row once and never the notice; the replay gap brackets the reset
  • permanent / no verdict attribute / output already emitted → one turn, reset only, no replay
  • budget is per message and bounded; the last attempt posts as before
  • a Stop recorded during the reset gap → the replay acquires, then ends without a prompt
  • the !stop fallback records the Stop on the manager before answering "Nothing running.", against the thread's owning session when linked (and test_slack_events_coverage.py pins both for the primary !stop handler)
  • a thinking-only abandoned attempt is replayed and its 💭 placeholder is taken down first
  • after a soft-cancel, the abandoned attempt's prompt carries the cancelled-turn preamble but the replay re-runs the user's text alone, and the log's user row is exactly that text (mutation-checked: red when the nested call is handed the mutated text)
  • a cancellation raised inside the reset still closes the replay gap
  • the replay carries every argument of the original (team, agent, display name, action context, activation, trusted-bot flag, voice flag) plus attempt=1
  • test_a_hook_reply_persists_only_after_the_replay_gap_resolves -- a hook auto-reply posts its canned answer at once, but its conversation-log row is written only after the key's open replay gap resolves (mutation-checked: red when the gap wait before the persist is removed)

test/test_cross_surface_stop_gate.py — a Stop inside a replay gap is recorded without a session (bare and canonical Slack keys share the bucket); a closed gap records nothing again; note_stop records against a live session; the existing “no session records nothing” contract still holds; a second task's get_or_create waits behind an open gap and lands after the owner's claim and release (order replay, then newer); close_all releases a waiter. A claimant parked on a busy permit completes after that session is reset (no restart-only hang), and lands behind the successor when the resetting turn reacquires first. The torn-down turn's late key-only release cannot unlock the successor a woken waiter holds. A stranger task's close_replay_gap leaves the owner's gap open; the owner's close releases the waiter.

test/test_messaging_commands.py — stop_running_turn records the Stop before its busy check.

test/test_messaging_dispatch.py

  • a Stop recorded during the reset gap → the message does not run again; the held DONE is delivered; the gap brackets exactly the reset→reacquire window
  • discovery tripwire: every pipeline channel Stop path records the Stop (Teams/Webex/WeCom/Weixin/WhatsApp covered)
  • transient → the message runs twice, one reset, two acquisitions, and the only DONE the channel sees is the replay's; post-turn bookkeeping once
  • permanent / no verdict attribute / output already emitted / a consumed steer → one run, the abandoned attempt's DONE goes through
  • the replay's reacquire reports is_new=True; persist still receives the first acquire's False and after_persist does not run
  • one gap spans the whole retry sequence and closes only after the permit is released (open, release, close), including across the full budget
  • a Stop or a /new during the reset gap -> the message does not run again, the held DONE is delivered, and nothing is recorded or persisted (successes == 0, persist never called); the generation reader is a no-op for Slack-shaped keys and reader-less doubles
  • budget bounded per turn; the last attempt's DONE goes through
  • failed reset releases the held DONE instead of replaying
  • the guard forwards whole events through the inner dispatch and marks emitted for exactly text / tool call / prompt choice
  • tripwire: the driver reaches its renderer only through dispatch and on_turn_start
  • two existing tests that asserted the driver's renderer identity now assert it through guard.inner
  • test_a_hook_reply_persists_only_after_the_replay_gap_resolves -- the hook auto-reply path renders TEXT_CHUNK, DONE immediately, then parks on the key's replay gap and calls persist only after it resolves; no session is acquired or released (mutation-checked as above)

Run: the four changed test files plus every channel dispatch/stop suite that rides drive_turn or stop_turn (teams/webex/whatsapp/feishu/wecom/weixin/imessage/spool/identity/memory/session_control/stop_addresses_linked_session/discord/telegram/slack_transport_dispatch): 2698 passed, 5 xfailed; plus every test/test_session*.py, test_subagent.py and the Slack/discord/telegram suites: 4959 passed. Lint: black, isort, flake8, mypy, check_black_formatting.py, check_subprocess_encoding.py, check_comment_history.py all clean.

Other

  • no-screenshots: backend-only; there is no UI surface in this change.
  • Not fixed here, intentionally out of scope (issue names two sites): the Slack transport path (slack/transport_dispatch.py, the default when messaging.use_transport is on) does not handle STOP_REASON_COMPACTION_FAILED at all — no reset, no retry. Also observed while tracing: a sessions.reset() discards any user messages already queued on that session (_unlink_session_queue), so on Slack a compaction-failed turn already strands queued follow-ups today; this PR does not change that.
  • reset() now wakes tasks parked on the popped session's turn permit (_wake_turn_waiters, session_lifecycle.py). Before, a message that found the key busy waited on that session's semaphore; popping the session left it there for good, because the permit stayed held by the turn being torn down and that turn's own release lands on the successor. That was baseline behaviour on the queue-less channels whenever a turn ended in a compaction failure, and the retry loop could reach it again through waiters admitted after a gap closed. The popped permit is released once in the same tick as the pop; the woken claimant's re-validation sees the session gone and -- the second half, in session_allocation.py -- re-enters get_or_create (bounded like the won-race retry it mirrors) instead of cold-starting in place, so it meets an open replay gap or the successor at the front door. Waking waiters promptly widens a documented hazard, though: release is key-only, so once a woken waiter has put a successor under the key, the torn-down turn's own late release would land on that successor and unlock a turn still in flight. So every acquire now records the holding task (_Session.turn_owner), reset remembers the holder of the permit it popped (orphaned_holders, keyed canonically), and release absorbs exactly that task's one owed release (absorb_orphaned_release); a task that resets and then reacquires the same key -- a replay -- has its record cleared at the successful claim (adopt_turn), so the release it makes for the successor is genuine. Three SessionManager tests pin it: a parked claimant completes after a reset; it lands behind the successor when the resetting turn reacquires first; and the torn-down turn's late release leaves the successor busy until its own holder releases (absorbed exactly once).
  • The Slack handler closes any gap it opened from its outer finally (after the release), so a cancellation landing in the reset await (!stop cancels the handler task) cannot leave the key waiting forever. That finally runs on every turn, so the call is probed with getattr like the rest of the seam (the focused session-manager doubles across the suite predate the method).
  • Hook auto-replies wait out the replay gap before they persist (await_replay_gap helper in messaging/dispatch.py, used by both the pipeline hook path and the Slack handler's). A hook reply never calls get_or_create, so the allocation-side wait did not fence it: arriving while an older message on the key sat between its reset and its replay, its record would have filed ahead of the replayed turn the reader saw first. The reply itself still goes out immediately; only the record waits. Probed with getattr like the rest of the seam.
  • Rebase onto current main folded in the post-compaction re-injection bookkeeping (consume_reinjection / rearm_reinjection) and Slack's deferred permit release (success booked after delivery). Two consequences handled here: the Slack finally defers the gap close together with the permit (_release_permit closes both), and a raise that leaves the turn body after a clean model completion -- a cancellation landing in the post-compaction reset -- releases the permit in the finally (_body_completed) instead of deferring it to a _release_permit that never runs. An attempt handed to a replay does not re-arm the one-shot re-injection flag: the replay cold-starts a new session whose first prompt carries the full session-start context.
  • close_replay_gap closes only when the calling task owns the gap. Both pipelines close from a finally that runs on every turn for the key, so a concurrent same-key turn (a hook auto-reply that never acquires a session, an interaction-originated Slack turn) would otherwise end the owner's gap early and let a newer message claim the successor ahead of the replay. Teardown paths and close_all keep the forced discard.
  • A replay that is stopped or superseded (/new) before it opens its prompt returns out of the turn after releasing the held DONE: nothing ran, so no record_success and no persist -- a cancelled message is not filed as a completed turn with an empty reply. The finally still closes the renderer, releases the permit and closes the gap.
  • chat_runner._session_stop_generation_for is the dashboard's copy of the defensive stop_generation reader; the shared pipeline's session_stop_generation (messaging/dispatch.py) is the same read for the channel surfaces. Folding the dashboard's onto it means touching chat_runner.py, which this PR does not; future cleanup.
  • Third transient-classifier marker list: not unified here. Neither site classifies anything — both read the verdict LLMProvider.last_compaction_transient that fix(acp): retry a turn abandoned after a throttled compaction #8215 already centralised — so there is no new list to fold; the existing three (compaction_failure_is_transient, llm_helpers.acp_error_is_transient, the chat-runner 5xx path) remain future work.
  • Slack stats: the abandoned attempt still counts record_success / inc_message_success once and the replay counts again, so a retried message shows as two successful turns in Stats — the same over-count the dashboard's recovery has; not changed here.

Pattern harvest

Rule candidate: grep
Pattern: a per-key state you open in one turn and close in a finally needs an owner check on the close -- the same finally runs for every concurrent turn on that key, and any of them can end your window early. Also: before replaying a message through a surface's queue, grep every dispatcher of that surface for the drain callback — a queue entry is only a replay where something drains it; when dispatch paths differ, a nested call of the handler with the original arguments is the replay that works on all of them.

Closes #8256

@CrysisDeu
CrysisDeu requested review from a team and Zedmor September 16, 2026 07:31
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 16, 2026
@CrysisDeu CrysisDeu added the no-screenshots PR has no visual delta; screenshot gate exempt label Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 151ab0395c68472c73d415534961235d4edcacfa — 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: CONCERNS

Discord and Telegram run their own turn loops and never read the compaction verdict — the same transient failure still eats messages there, unaddressed.

Not justified as shipped

  • Item 2 — symptom-level: the root cause (a surface that ignores the compaction verdict) has 2 counted unfixed siblings — grep for COMPACTION_FAILED hits 0 in both src/kiro_crew/discord/transport_dispatch.py (which states it "runs its OWN copy of the turn loop instead of going through messaging.dispatch.drive_turn") and src/kiro_crew/telegram/transport_dispatch.py, so a transient failure there still drops the message and never even resets the wedged session; the general fix (migrating both onto drive_turn) is genuinely larger, so this is accepted-and-deferred, not a demand.
    Clears when: the verdict check (or at minimum the reset) lands in those two loops, or a linked issue/RFC entry records their deferral.

What this change ships

Inventory (10 items) — 9 justified

Intent: stop silently dropping a user's message when a transient backend throttle fails compaction, on the two chat surfaces PR #8215's dashboard fix left out — a FIX.

  1. Slack retries a message abandoned by a transient compaction failure, posting "⟳ Compaction failed — retrying…" — justified
  2. The seven drive_turn channels retry it silently into the same reply — symptom-level: 2 sibling surfaces (discord, telegram) share the root cause unfixed
  3. A permanent verdict keeps the old give-up behaviour on both surfaces — justified
  4. A Stop issued anywhere, including while no session exists mid-retry, keeps the message dropped — justified
  5. /new issued mid-retry retires the message on pipeline channels — justified
  6. A newer message on the same conversation waits until the retry settles instead of overtaking it — justified
  7. Hook auto-replies still post at once but their transcript record waits behind an in-flight retry — justified
  8. A message queued behind a busy session no longer hangs forever when that session is reset — justified
  9. A torn-down turn's late release can no longer unlock the successor session mid-turn — justified
  10. New session-manager methods (note_stop, replay gaps, orphan-release absorption) — justified

[FIRST-PRINCIPLES-REVIEWED] 151ab03

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 151ab0395c68472c73d415534961235d4edcacfa — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Default Slack route (use_transport=True) gets no fix — transport_dispatch still drops the message and wedges the session; only the opt-out handler is covered.

Watch

  • config/loader.py:2852 defaults messaging.use_transport to True, so out-of-the-box Slack dispatches through slack/transport_dispatch.py, which the description concedes "does not handle STOP_REASON_COMPACTION_FAILED at all — no reset, no retry". A transient throttle there still eats the message and leaves the runtime counting a prompt in progress, strictly worse than the two sites fixed; this PR's Slack replay only runs for operators who opted back into the native handler, while the PR title reads as fixing Slack.
    Clears when: a tracked follow-up issue for slack/transport_dispatch.py's compaction-failed handling is filed and linked from the PR.
  • _wake_turn_waiters + turn_owner/orphaned_holders/absorb_orphaned_release change reset()/release() semantics for every reset on every surface, keyed on asyncio task identity — compensating machinery for release() being key-only rather than permit-bound. Load-bearing for the retry loop and pinned by tests, but it is core-allocation surface a regression in which hits all channels, shipped inside a channels fix.
    Clears when: a reviewer of the session-allocation seam signs off on the task-identity ownership model (or the permit-bound-release follow-up below lands and deletes it).

Suggestions

  • Follow-up (not here): make release permit-bound — release the acquired session object's permit instead of the folded key — which deletes turn_owner, orphaned_holders, absorb_orphaned_release and adopt_turn outright.

[DESIGN-REVIEWED] 151ab03

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 151ab0395c68472c73d415534961235d4edcacfa and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 151ab03

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 151ab0395c68472c73d415534961235d4edcacfa: <one-sentence reason>

@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 Sep 16, 2026
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 151ab0395c68472c73d415534961235d4edcacfa — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 151ab03

Verdict parsed from the review's SHA-scoped output markers for commit 151ab0395c68472c73d415534961235d4edcacfa.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 151ab0395c68472c73d415534961235d4edcacfa: <one-sentence reason>

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from e17cb4c to 543210d Compare September 16, 2026 08:32
@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 Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from 543210d to 8b4cede Compare September 16, 2026 08:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from 8b4cede to 6a7e1f8 Compare September 16, 2026 09:53
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from 6a7e1f8 to 7788ed3 Compare September 16, 2026 10:21
@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 Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from 3b8e483 to 784f90e Compare September 16, 2026 12:22
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from 784f90e to 24db81e Compare September 16, 2026 12:44
@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 Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from 24db81e to d5aa48c Compare September 16, 2026 19:14
@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 Sep 16, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from d5aa48c to 8702248 Compare September 16, 2026 19:35
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Sep 16, 2026
…ailure

Extend the transient-compaction retry to the two remaining surfaces. When
the ACP layer records `last_compaction_transient` as True, nothing was
emitted this turn and the per-surface budget is unspent, the abandoned
message runs again instead of being dropped; a permanent verdict keeps
the give-up behaviour.

Slack native handler: reset, respawn the session, and put the message
back on the thread's own queue (`sessions.enqueue`), which the gateway's
`_on_done` drain replays through `_dispatch_queued`. Budget per thread.

Shared messaging pipeline (`drive_turn`): the driver renders through a
guard that holds back the abandoned attempt's DONE, the session is
reset, and the message runs again into the same still-open renderer.
Budget per turn.

Closes #8256
… nested call

A Stop landing between the abandoned attempt's reset and the successor's
acquire finds no live session, so nothing recorded it and the replay
would run the prompt the user just stopped. The session manager now
records Stops for a key inside a "replay gap" the pipeline opens around
that window (`open_replay_gap` / `close_replay_gap`, `note_stop`), the
direct-cancel channel stop paths (Teams via `stop_running_turn`, Webex,
WeCom, Weixin) record before their busy check, and both replay sites
re-read the count right before running the message again.

The Slack replay is a nested `handle_message` call with every argument
unchanged instead of a queue entry: the interaction dispatch paths have
no queue drain, a queue entry loses the attachment temp files to the
outer task's cleanup, and the abandoned attempt must persist nothing so
the conversation log carries the message once. The retry notice is
posted directly and never recorded; the budget travels with the message.
@CrysisDeu
CrysisDeu force-pushed the fix/transient-compaction-retry-8256 branch from 8702248 to 151ab03 Compare September 21, 2026 03:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-screenshots PR has no visual delta; screenshot gate exempt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend the transient-compaction retry to Slack and messaging dispatch

2 participants