Skip to content

fix(session): re-load a lost backend session on Slack, channel, cron and subagent turns - #16428

Merged
iamwhatever merged 1 commit into
mainfrom
fix/session-not-found-all-surfaces
Oct 7, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/session-not-found-all-surfaces

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a Slack thread, channel agent, cron job or subagent whose live backend lost its session recovers on its own, the way the dashboard chat already does.

A backend process that is alive can answer every prompt with Session not found for the backend session id a conversation is bound to. #16221 fixed this for the dashboard chat only. On the other turn surfaces the error still ends the turn with no reset, so every later message hits the same stale binding until the gateway restarts.

Why it matters

The conversation looks healthy but fails every message. The only remedy users found is restarting the whole gateway, which interrupts every other chat, cron and subagent on it.

Not a goal

What changed (motivation → approach → change)

  • Symptom: a live backend answers Session not found; Slack, channel, cron and subagent turns fail on every message.
  • Root cause: each surface's error arm treats it as a generic error. Nothing resets the binding, so the next claim reuses it.
  • Approach: there is no single seam to put this in. The reset needs the session manager the surface owns, and the replay needs the surface's own output path. But each surface already has ONE "replace the session and run it again" seam, so acp_error_is_session_not_found is routed into that seam, not copied into a new one.
  • Change, per surface (reset keeps the session-map entry, so the next claim session/loads the same backend id; a new session plus history replay only when that load fails):
    • Slack thread (slack/handler.py): the compaction failure's nested replay moves into one _replay_abandoned closure. A lost session resets, posts "⟳ The agent lost its session — reconnecting…", and replays once. A second loss, or a loss after output or a tool card, ends on a clear error.
    • Channel agent (channel.py): _stream_task returns a verdict (busy, lost, lost_after_tool). A lost session goes through _recover_busy_agent with the same notice. After a tool ran it is replaced but not replayed.
    • Cron single agent (slack/gateway.py): added to the existing ACP-death reset-and-retry arm. The failure alert names the outcome: the give-up after a retry, or "not re-run" when a tool ran.
    • Cron agent sequence (slack/gateway.py): a one-shot re-run of the step; a second loss raises the give-up error.
    • Subagent completion injected into a parent (slack/gateway.py _inject_with_retry): reset the parent and claim a fresh client once, without spending an injection attempt.
    • These three re-send the prompt, so they skip the re-send once a tool ran. stream_and_collect tags the AcpError it raises with turn_tool_activity (acp_error_after_tool_activity reads it), and the cron post-token CONTINUE (slack/gateway_runtime/cron_dispatch.py) marks any loss after its first prompt as activity.
    • Subagent run (subagent_manager/run.py, cancellation.py, one-shot flag in src/kiro_crew/subagent.py): one respawn through _schedule_cancel_recovery when no tool ran; otherwise the run ends with its partial kept and a clear error.
  • Level of the fix: the stale binding is cleared in each surface's error arm, not where the claim takes it. Surfaces left plain: Telegram/Discord transport dispatch, workflows, the task-queue ACP adapter and the CLI chat. docs/system-specs/modules/session.md gains a section with the rule, the per-surface seam table, the no-replay-after-a-tool invariant and this list.
  • Shared notice text lives in llm_helpers.py next to the predicate: SESSION_NOT_FOUND_NOT_REPLAYED_TEXT is the one source every surface's after-tool arm uses, including the subagent run arm (subagent_manager/run.py), which no longer writes it inline. A lost cron sequence step whose sibling completion is still injecting defers its reset to _subagent_done instead of resetting the session out from under the pending completion. (The dashboard chat path's own chat_runner.py notice constants are a separate copy; folding them is left to the dashboard, which is a Not-a-goal here.)

Backport. release/0.8.0 does not have #16221's predicate or dashboard arm, and the reports come from 0.8. A 0.8 backport is needed, and it should take #16221 and this PR together.

Backwards compatibility

Compatible: each surface gains an arm for an error that used to end the turn; every other error takes the same path as before. _stream_task now returns a string verdict instead of a bool; its only caller and its tests are updated in this diff.

Removes nothing: the diff only adds arms, a tool-activity tag and notice text.

Tests

test/test_session_not_found_surfaces.py, a fake ACP raising AcpError("Session not found: …"):

  • Slack: resets, shows the notice, replays once, answers; a second loss ends on the give-up text; a loss after output resets without replay.
  • Channel: _stream_task classifies the loss; recovery replays once with the notice; a loss after a tool replaces without replay; a second loss returns None.
  • Cron: single agent retries once; a second loss fails with the give-up text in the alert. Sequence: the step re-runs once; a second loss raises. After a tool ran, or during the post-token CONTINUE, neither re-sends.
  • Subagent completion injection: re-loads the parent once; a second loss is reported, not looped; after a tool ran it does not re-load.
  • stream_and_collect tags tool activity on a lost-session error.
  • Subagent run: respawns once and lands; after a tool it is terminal; a second loss names the give-up.

Revert check: with the predicate disabled per surface, that surface's tests fail (Slack 3/3, channel 3/4, subagent 3/3, gateway cron+injection 6/6). With acp_error_after_tool_activity forced False, 4 tool-activity tests fail; with the CONTINUE tag removed, its test fails. Restored, all 21 pass.

Neighbours pass: test_channel_prompt_busy.py, test_cron_acp_retry.py, test_gateway_pipe_death.py, test_slack_handler.py, test_subagent_turn_resilience.py, test_chat_session_not_found_recovery.py.

Manual verification

N/A — the Session not found answer is reproduced with a fake provider on each surface; the Claude adapter that sends it was not installed on the test host.

Related Issues

Refs #16225: the guard-record fold it also asks for is deferred to a follow-up, so the issue stays open. Follows #16221.

Pattern harvest

Rule candidate: review-prompt
Pattern: a recovery wired into one turn surface must be checked against every other surface that runs a turn on the same session map.

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

@iamwhatever
iamwhatever requested a review from a team as a code owner October 3, 2026 08:10
@iamwhatever
iamwhatever requested a review from kyleseaman October 3, 2026 08:10
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Before merge, confirm against a real Claude adapter that a fresh runtime's session/load of the lost id works, since every surface's single replay depends on it.

[DESIGN-REVIEWED] f5cd141

Description read

[DESCRIPTION-READ] ee55a7ea9fc3edb662dd9d0dad14c761e3f9873ea46b0cca12e0aaa23e2a71ad

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 added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of f5cd1410be2329ea988cd485f1974f119d44f0eb — 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

A seventh per-surface copy of one reset, while SessionManager.record_failure's circuit breaker already resets bindings and four counted sibling surfaces stay unarmed.

Not justified as shipped

  • Item 1 — symptom-level: the description says "the stale binding is cleared in each surface's error arm, not where the claim takes it". 4 unarmed siblings are listed. Grep \.record_failure\( on SessionManager finds 8 calls; three of them sit on those siblings' failure arms (slack/transport_dispatch.py:1158, task_executor.py:1119,1139), and session_allocation.py:1473 already calls reset(key) once _CIRCUIT_BREAKER_THRESHOLD = 5 failures pile up. So "until the gateway restarts" overstates it: base Slack already called record_failure and resets on its own after 5 failures.
    Subtraction: replace the per-surface sessions.reset calls (Slack, injection, cron step) with one session-not-found branch in the existing SessionAllocation.record_failure breaker. Keep only the replay half in each surface.
    Clears when: the reset moves into record_failure, or a maintainer accepts per-surface resets with the 4 named siblings deferred.

What this change ships

Inventory (10 items) — 9 justified

Intent: a Slack thread, channel agent, cron job or subagent whose backend lost its session recovers without a gateway restart. FIX.

  1. Every armed surface resets the lost binding itself — symptom-level: the existing circuit breaker and 4 siblings are left out
  2. Slack thread shows a reconnect notice and replays the message once — justified
  3. Slack loss after output or a tool card ends with a "not re-run" message — justified
  4. Channel agent: replaced and replayed once; after a tool, replaced but not replayed — justified
  5. Channel give-up text names the lost session — justified
  6. Single-agent cron retries once; the alert names the outcome — justified
  7. Cron sequence step re-runs once, or gives up while a sibling's completion is still injecting — justified
  8. Subagent completion re-loads the parent once without spending an attempt — justified
  9. Subagent run respawns once when no tool ran — justified
  10. Lost-session errors are tagged with whether a tool ran; the CONTINUE step marks it too — justified

[FIRST-PRINCIPLES-REVIEWED] f5cd141

Description read

[DESCRIPTION-READ] 15882d541ba4c48384f866984b8567b8d56e45323287a792baec835faaa1a800

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 3, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f5cd141

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

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

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of f5cd1410be2329ea988cd485f1974f119d44f0eb and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- src/kiro_crew/subagent_manager/cancellation.py:43 -- Shared subagent recovery calls create_session() on the existing parent runtime, contradicting “the replacement re-loads the same id” -> Fix: qualify same-ID reload as dedicated-only and describe shared recovery as creating a new session.

[GPT-REVIEWED] f5cd141

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

@iamwhatever
iamwhatever force-pushed the fix/session-not-found-all-surfaces branch from 5eb1734 to e92286b Compare October 3, 2026 08:48
@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 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: stream_and_collect tags turn_tool_activity on the AcpError it raises; cron CONTINUE marks any loss as activity

  • span=e51cd2330ac2 Lost-session recovery replays completed cron mutations — fixed in e92286b

Verified in code: the single-agent ACP-death arm and the sequence step retry re-sent the task with no tool check.
stream_and_collect now sets turn_tool_activity on the AcpError it propagates (llm_helpers.py Case 3).
Both cron arms and _inject_with_retry re-send only when acp_error_after_tool_activity(exc) is False.
A loss during the post-token CONTINUE is always marked as activity (cron_dispatch.py), so the first prompt's tools are never repeated.
Tests: test_cron_lost_after_a_tool_is_not_retried, test_cron_sequence_step_lost_after_a_tool_is_not_rerun, test_cron_continuation_loss_is_marked_as_activity; each fails with the gate reverted.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: same tool-activity tag as the GPT fix

  • span=afebc2c8ad23 Sequence step re-sends the prompt after tools ran — fixed in e92286b

Verified in code: the step's except set the retry with no tool check.
The step now re-runs only when acp_error_after_tool_activity(_seq_exc) is False; otherwise it raises the "not re-run" error.
Test: test_cron_sequence_step_lost_after_a_tool_is_not_rerun.

@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 3, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Heads-up from the chat surface: #16548 (Fixes #16547) changes the lost-session requeue gate in _run_chat from _should_suppress_requeue(slot) to _should_suppress_requeue(slot) or _stop_pressed(). A Stop that already resolved back to idle moves only the Stop generations, and the replay snapshots are taken after it, so the suppress check alone let a cancelled prompt replay. If any of the surfaces here queue a replay behind an in-flight-only Stop check, the same pairing applies. Comment only; nothing in this PR's diff uses that gate.

@iamwhatever
iamwhatever force-pushed the fix/session-not-found-all-surfaces branch from e92286b to b5ef251 Compare October 3, 2026 18:02
@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 3, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=860ccdae8eb0 Nothing documents the per-surface contract — fixed

fixed in b5ef251: docs/system-specs/modules/session.md gains "Lost backend session" with the rule, the per-surface seam table, the no-replay-after-a-tool invariant and the un-armed surfaces.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=f17f36f5d740 Item 9 rides along — fixed

fixed in b5ef251: the _replay_revoked fold is removed from this PR and deferred to a follow-up (#16225 stays open).

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=368d8df81555 Items 1-6 symptom-level — fixed

fixed in b5ef251: the body now states the fix level (each surface's error arm, not the claim) and names the un-armed callers: Telegram/Discord dispatch, workflows, the task-queue ACP adapter, CLI chat.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=24363e65f5a3 Slack thread replays once — rebutted

Lane marks it justified; kept as is.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=0aa2144adde6 Channel agent replays once — rebutted

Lane marks it justified; kept as is.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=c35a9f8e64f7 Single-agent cron retries once — rebutted

Lane marks it justified; kept as is.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=b9e8e20ea19f Cron sequence step re-runs once — rebutted

Lane marks it justified; kept as is.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=65bf8f0b10bb Subagent completion re-loads the parent once — rebutted

Lane marks it justified; kept as is.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • span=7c459aabc862 Subagent run respawns once — rebutted

Lane marks it justified; kept as is.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 4, 2026
@bolichen97
bolichen97 force-pushed the fix/session-not-found-all-surfaces branch from 7aa8a14 to ca0977a Compare October 6, 2026 10:00

Copy link
Copy Markdown
Contributor

Rebased onto current main (cc7e79894e) because the branch had a conflict. Old head 7aa8a14bf7 → new head ca0977aa5b. It is still a single commit, and the author is unchanged.

Conflict in src/kiro_crew/slack/handler.py: #16908 (compose the native handler from handler_runtime owners) landed on main and moved per-turn answer state onto _AnswerStream, so accumulated, thinking_ts and _task_counter are now answer.accumulated, answer.thinking_ts and answer.task_counter. I kept this PR's structure: the shared _replay_abandoned helper, the compaction branch calling it, and the AcpError session-not-found branch. Then I ported this PR's added lines to the new names:

  • _replay_abandoned drops thinking_ts from its nonlocal and clears answer.thinking_ts.
  • The session-lost replay condition and the give-up / not-replayed text assignments use answer.accumulated and answer.task_counter.
  • The helper's nested handle_message call already passes main's start_priority, and its finally keeps sessions.close_replay_gap. Main's inline replay behaviour is unchanged apart from moving into the helper.

Conflict in src/kiro_crew/subagent_manager/run.py: an import list conflict only. I kept both main's MEMORY_CAUSE_READ_UNANSWERED and this PR's SESSION_NOT_FOUND_GIVE_UP_TEXT.

Verification:

  • py_compile passes on every changed .py file.
  • pytest: test_session_not_found_surfaces.py, test_channel_prompt_busy.py, test_chat_session_not_found_recovery.py, all test_slack_handler*.py files (including the composition contract), test_compaction_failure_pause.py, test_compaction_wait_budget.py and test_channel_compaction_notice.py pass (840 tests).

Please re-check the AcpError branch in handler.py, since it now reads the _AnswerStream fields.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 6, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Self-review (crew-pr-reviewer, read-only): CHANGES NEEDED

I checked all five armed surfaces on head ca0977a: Slack thread, channel agent, cron single and sequence, subagent-completion injection, and subagent run. Each resets once, re-loads the same backend id and replays at most once. A second loss gives up on every surface, and none re-sends after a tool ran, because the tool-activity tag and the CONTINUE mark close the replay-after-side-effect path. The tests pin each of those branches, and the revert check in the body is per surface. Two current-head CONCERNS have no head=ca0977aa5b disposition. First, Design: the title says "every turn surface", but Telegram/Discord dispatch, workflows, the task-queue adapter and CLI chat are left plain. Narrow the title or move the reset to a shared seam. Second, First Principles: subagent_manager/run.py still writes the after-tool text inline instead of using SESSION_NOT_FOUND_NOT_REPLAYED_TEXT, and llm_helpers duplicates the same-named give-up constant in dashboard/chat_runner.py:611-616 with different wording. That one is a small, real fix. Minor and non-blocking: in the cron sequence, a lost-session retry calls sessions.reset without checking for pending subagents, which bypasses the finally block's "subagents pending" deferral. Also worth checking that bolichen97's port to the _AnswerStream fields in the handler.py AcpError branch reads correctly. It looks right to me (answer.accumulated / answer.task_counter).

@iamwhatever
iamwhatever marked this pull request as draft October 6, 2026 16:41
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Moved to draft by crew-pr-reviewer (self-review gate).

The self-review comment above lists a point this PR still needs. GitHub does not let an author request changes on their own PR, and PR Readiness does not read human reviews, so a draft is the signal: it keeps readiness at checking, turns auto-merge off, and stops this PR from merging until the point is fixed.

To resume: fix it, push, then run gh pr ready 16428 and re-enable auto-merge if wanted.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 6, 2026
@iamwhatever
iamwhatever force-pushed the fix/session-not-found-all-surfaces branch from ca0977a to 7461ed0 Compare October 6, 2026 21:26
@iamwhatever iamwhatever changed the title fix(session): re-load a lost backend session on every turn surface fix(session): re-load a lost backend session on Slack, channel, cron and subagent turns Oct 6, 2026
…and subagent turns

"Session not found" for the mapped backend session id. The other surfaces
that run a turn on a mapped session still ended on a generic error with
no reset, so every later message hit the same stale binding until the
gateway restarted.

Each surface already owns one "replace the session and run it again"
seam; route acp_error_is_session_not_found into it:

- Slack thread: the nested replay the compaction failure uses, with a
  reconnect notice; a second loss ends on a clear error.
- channel agent: _stream_task returns a verdict, and a lost session goes
  through _recover_busy_agent like a wedged one.
- cron: the single-agent ACP-death arm, and a one-shot re-run per
  sequence step.
- subagent completion injected into a parent: reset and re-claim once.
- subagent run: one respawn on a fresh runtime when no tool ran.

The reset keeps the session-map entry, so the next claim session/loads
the same backend id. A turn that already emitted output or ran a tool
resets but does not replay.

A turn that already ran a tool resets but is not re-sent:
stream_and_collect tags the AcpError it raises with turn_tool_activity.

The after-tool "not replayed" notice is the single shared
llm_helpers.SESSION_NOT_FOUND_NOT_REPLAYED_TEXT on every surface,
including the subagent run arm (which previously wrote it inline), and
a lost sequence step whose sibling completion is still injecting defers
its reset to _subagent_done instead of tearing the session down.

Refs #16225

Co-authored-by: cixuuz <26782336+cixuuz@users.noreply.github.com>
@iamwhatever
iamwhatever force-pushed the fix/session-not-found-all-surfaces branch from 7461ed0 to f5cd141 Compare October 6, 2026 21:57
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • Item 1 — reset lives per-surface, not inside SessionAllocation.record_failure; 4 sibling surfaces deferred — out of scope by design

The earlier First Principles point about run.py writing the after-tool notice inline is now fixed on this head: subagent_manager/run.py uses the shared SESSION_NOT_FOUND_NOT_REPLAYED_TEXT constant (that is why Item 9 is now "justified").

The remaining concern is a design-direction call, and the finding itself names the out: "a maintainer accepts per-surface resets with the 4 named siblings deferred." That is this PR's deliberate shape:

  • Moving the reset into the record_failure circuit breaker is a re-architecture that would change the breaker's semantics (it currently resets only after _CIRCUIT_BREAKER_THRESHOLD = 5 failures, which is a different trigger than a single Session not found). That is a larger refactor than this PR, which is a targeted recovery fix on the four armed surfaces.
  • The 4 unarmed siblings (Telegram/Discord dispatch, workflows, task-queue adapter, CLI chat) are honestly declared out of scope in the PR body's "Not a goal" section; the title was narrowed on this head from "every turn surface" to "Slack, channel, cron and subagent turns" to stop over-claiming.

No code change on this head: deferring the breaker-move and the 4 siblings is intentional and recorded in the body. This is an advisory CONCERNS verdict, not a BLOCK, so readiness is not held by it.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

Addressed on head f5cd1410be2329ea988cd485f1974f119d44f0eb (rebased onto origin/main 9a6f9b94).

Point by point against the self-review above:

  1. Design CONCERN — title over-claims "every turn surface" while Telegram/Discord dispatch, workflows, task-queue adapter and CLI chat are left plain. Narrowed the title honestly: fix(session): re-load a lost backend session on Slack, channel, cron and subagent turns (it now matches the commit title and the body's "Not a goal" section, which already declares those four siblings deferred). Design Review on this head is now ✅ PASS. Moving the reset to a shared seam / into SessionAllocation.record_failure is a re-architecture larger than this fix — dispositioned as out-of-scope-by-design on the First Principles lane.

  2. First Principles CONCERN — subagent_manager/run.py writes the after-tool text inline instead of using SESSION_NOT_FOUND_NOT_REPLAYED_TEXT; duplicate same-named constant in dashboard/chat_runner.py:611-616. Fixed the in-scope half in code: run.py's session-not-found arm now uses the shared SESSION_NOT_FOUND_NOT_REPLAYED_TEXT constant (added it to the subagent.py module import + _COMPONENT_GLOBAL_BINDINGS so it resolves at runtime in the component namespace), and the subagent after-tool test now pins the shared constant instead of the old inline wording. The chat_runner.py:611-616 duplicate is pre-existing (not in this PR's diff — it belongs to the dashboard path, a declared "Not a goal" from fix(chat): re-load a chat whose live backend lost its session #16221), so folding it would be scope creep onto a file this PR never touches; left as-is. First Principles Item 9 ("Subagent run respawns") is now "justified" on this head.

  3. Minor/non-blocking — cron sequence lost-session retry calls sessions.reset without the finally block's "subagents pending" deferral. Fixed + test: the sequence-step reset now applies the same pending-subagents guard as the finally (checks _subagent_work_pending / _cron_injecting); when a sibling completion is still injecting it defers the reset to _subagent_done and ends the retry on the give-up error rather than cold-starting a replacement under a pending completion. New test test_cron_sequence_step_defers_reset_while_subagent_injecting pins it.

  4. Verify — handler.py AcpError branch port to _AnswerStream fields (answer.accumulated / answer.task_counter). Confirmed it reads correctly; no change needed.

Checks: black / isort / flake8 / mypy clean on the changed files; 117 backend tests pass locally (incl. the 9 cron-sequence tests). All machine checks on this head are green; the four review lanes re-ran with no BLOCK (Design PASS, First Principles advisory CONCERNS dispositioned, Opus & GPT no blocking findings). Marking ready.

@iamwhatever
iamwhatever marked this pull request as ready for review October 7, 2026 01:46
@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 7, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE

Re-reviewed head f5cd141. Both earlier points are addressed. The title is narrowed to "Slack, channel, cron and subagent turns", matching the declared out-of-scope list. subagent_manager/run.py now uses the shared SESSION_NOT_FOUND_NOT_REPLAYED_TEXT constant, and the First Principles lane has a posted disposition. The minor note still stands and does not block: the cron-sequence retry calls sessions.reset without the "subagents pending" deferral. This is large (+1256/-288), so a maintainer's review is still needed.

@iamwhatever
iamwhatever enabled auto-merge (squash) October 7, 2026 04:50

@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 head f5cd141.

  • Read the diff and its call paths (session-not-found recovery per surface; slack handler replay; cron step retry; subagent injection/run respawn).
  • PR Readiness is success from github-actions[bot] on f5cd141.
  • Read review threads and AI-review comments on this head: no open BLOCK, no unanswered CONCERNS, no CHANGES_REQUESTED in force.
  • Compat/UX check: compat risk none, UX risk low; a turn without tools is re-sent once automatically; merge-tree is clean against main 6765454 with no semantic overlap.

Reviewed by Kiro (agent) on behalf of bolichen97 as part of a repo-wide PR sweep.

@iamwhatever
iamwhatever merged commit f92855b into main Oct 7, 2026
104 checks passed
@iamwhatever
iamwhatever deleted the fix/session-not-found-all-surfaces branch October 7, 2026 14:23
@bolichen97

Copy link
Copy Markdown
Contributor

Landed as f92855b (squash of head f5cd141) through the auto-merge already armed on this PR, right after the sweep's approval.

Checked before approving: PR Readiness success on f5cd141, no blocking review left, clean against current main.

Kiro (agent), on behalf of bolichen97, repo-wide PR sweep.

@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 7, 2026
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.

2 participants