Skip to content

fix(session): rescue queued follow-ups from a mid-turn reset - #3753

Closed
adiarora06 wants to merge 1 commit into
kirodotdev:mainfrom
adiarora06:fix/session-reset-preserves-queued-messages
Closed

adiarora06 wants to merge 1 commit into
kirodotdev:mainfrom
adiarora06:fix/session-reset-preserves-queued-messages

Conversation

@adiarora06

@adiarora06 adiarora06 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3752

Problem / Motivation

Goal: Preserve accepted follow-up messages and their cancellation state when a mid-turn reset replaces the live session.

When reset() tears down a session during an active turn, queued follow-up messages live on the removed session object. The reset path then unlinks their temporary files and discards the queue, so messages accepted moments earlier can disappear without delivery.

Why it matters

The queue acknowledges user input before reset runs. Silently dropping that acknowledged work breaks the messaging contract and can also make channel receipts disagree with what the agent eventually processes.

What changed

  • Rebased and manually ported the implementation onto current main and the current split session architecture.
  • Publish a removed session's queue and cancellation markers into manager-owned orphan storage before reset bookkeeping awaits.
  • Fold canonical and legacy Slack aliases across orphan storage so a cold start cannot miss a rescued queue.
  • Let enqueue, dequeue, cancellation, scoped clear, detach/restore, stop, destroy, and discard paths account for rescued entries.
  • Restore an adopted queue and its cancellation markers if session registration is cancelled or fails before commit.
  • Adopt any remaining orphan during a later cold start, while preserving current-main queue partitioning, replay-gap handling, teardown cleanup, and child cancellation behavior.
  • Unlink temporary image files only when an entry is truly dropped.

Not a goal

This does not change message ordering, provider reset policy, or when a reset is triggered.

Tests

  • Focused session/queue/eager-spawn regression run: 31 passed.
  • A broader eager-spawn run reached 101 passing tests; three unrelated dashboard tests lack the local pathspec dependency.
  • black, isort, flake8, and git diff --check are clean on all changed files.

Pattern harvest

Rule candidate: lifecycle state moved out of a live session must be published before the first teardown await, restored on every registration rollback, and resolved through the same alias set as live state.

Screenshots

N/A — session queue lifecycle correction with no visual UI change.

@adiarora06
adiarora06 requested a review from a team August 15, 2026 05:54
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Aug 15, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed
  • ## Tests

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@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 Aug 15, 2026
@adiarora06 adiarora06 changed the title Rescue queued follow-up messages from a mid-turn session reset fix(session): rescue queued follow-ups from a mid-turn reset Aug 15, 2026
@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 Aug 15, 2026
@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — 🔴 changes requested (blocking)

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

1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands.

BLOCKING -- src/kiro_crew/session_lifecycle.py:1463 -- Stale compaction cleanup deletes rescued attachments
self._orphaned_queues[key] = session.queue
Native Slack delivery fails at the circuit-breaker threshold while auto-compaction waits → reset() rescues the shared deque and wakes the compactor → shutdown makes compaction fail, and _restart_held() → _recycle_held() unconditionally unlinks attachments still queued for the successor.
Anchor: residual/crash-data-loss-corruption
Fix: Transfer deque ownership by assigning the removed session a fresh empty deque immediately after publishing its rescued queue, before any await.

[BLOCK-MERGE] 5dd60f8
[GPT-REVIEWED] 5dd60f8

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1: An irreversible-loss class finding. The superseded path is real. session_compaction.py:911-913 sends a session that reset() already popped into _recycle_held, and session_compaction.py:812 then runs unlink_session_queue(session) on it with no further check. The patch puts that same session.queue deque into _orphaned_queues at session_lifecycle.py:1463 (patch line 380) and does not swap in a fresh one. So the cleanup deletes temp attachments for follow-ups a successor will later adopt. A reset that lands while compaction is running is an ordinary timing case, not a contradictory one, and the loss is silent. I could not build the rarity record a FLAG needs.

[ADJUDICATION] 5dd60f8f2b96805ee005ef639183235f4eadf9da total=0 uphold=0 downgrade=0
[GPT-ADJUDICATED] 5dd60f8f2b96805ee005ef639183235f4eadf9da

[ADJUDICATION-FENCED] 5dd60f8f2b96805ee005ef639183235f4eadf9da fenced=1 flagged=0
UPHOLD-FENCED F1 src/kiro_crew/session_lifecycle.py:1463 -- reset() aliases the live deque into _orphaned_queues without detaching it, and the superseded-compaction path (session_compaction.py:911-913 → 812) unconditionally unlinks that same deque's temp attachments, silently destroying images owed to the successor under a plausible reset-during-compaction race.
[GPT-ADJUDICATED-FENCED] 5dd60f8f2b96805ee005ef639183235f4eadf9da

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — 🟡 CONCERNS

Design-level review of 5dd60f8f2b96805ee005ef639183235f4eadf9da 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

The rescue ignores ends_conversation and has no expiry, so follow-ups can replay into a different conversation or sit in orphan storage indefinitely.

Watch

  • A reset that ends the conversation still saves the queue. The PR drops the rescue in discard_conversation because "replaying it into the fresh one would land follow-ups with no context to follow up on". But reset() publishes the rescue whenever session.queue is non-empty (rescued_queue = bool(session.queue)) and never checks ends_conversation. That flag is how callers like dashboard/handlers_channel.py:652, taskrunner.py:2258, cron.py:1382 and workflows/agent_pool.py:230 say the conversation is over. In those cases the next cold start picks up the queue and sends those follow-ups into the new conversation, which is the harm the PR itself names.
    Clears when: reset(ends_conversation=True) drops the queue through _drop_orphaned_queue, as destroy does, and a test pins this.
  • Rescued queues have no expiry. A rescued queue is only adopted by a later cold start or drained by dequeue. If neither happens, orphaned_queues keeps the entries and their temp images for the life of the process. Nothing in the patch bounds it, expires it, or drops it in close_all.
    Clears when: the patch names a path that always drops an unadopted rescue (shutdown, or the idle/TTL sweep), with a test.
  • The spec is not updated. docs/system-specs/modules/session.md documents reset, the queue helpers and stop_turn's queue clear (around line 1547). This PR changes all three: reset now keeps the queue, and stop with no live session now clears the rescued queue. The spec is not touched.
    Clears when: session.md describes the orphan-queue lifecycle in this PR.

[DESIGN-REVIEWED] 5dd60f8

Description read

[DESCRIPTION-READ] ac0b345b72358fd205e62570424ac95b6768b239b2cebe673a0861c293aa0962

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 Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — 🟡 CONCERNS

Premise-level review of 5dd60f8f2b96805ee005ef639183235f4eadf9da 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: CONCERNS

The fix covers only reset(), while the cause is that each follow-up queue is stored on the session process object. That cause also loses queues in 3 other recycle paths, and the patch adds a second, parallel queue store.

Not justified as shipped

  • Item 1 — symptom-level: the queue is declared as queue: deque on _Session (session.py:1110), so any teardown that keeps the conversation alive still throws the queue away. I counted 8 unlink_session_queue call sites in src/. Of the 4 that recycle a session and keep its conversation, this PR fixes 1. The other 3 are unchanged: _recycle_held (session_compaction.py:812, a recycle while a turn holds the lock), _evict_stale_session (session_allocation.py:1184) and the stale eviction in get_or_create (session_allocation.py:2236).
    Subtraction: delete orphaned_queues, orphaned_cancelled, rescued_queue_adopted, the adopt/rollback logic and every if not session: check orphaned branch. Replace them with one queue stored per key, which every session for that key reads.
    Clears when: the queue is stored per key, or the description says this is a fix to the mechanism in reset() only and names the 3 unfixed siblings.
  • Item 5 — symptom-level: putting the queue back in remove_if_unclaimed is only needed because a speculative cold start adopts a rescued queue. That problem exists only because the patch keeps two separate stores. The subtraction under Item 1 removes it.
    Clears when: the per-key queue lands, or the description gives a reason a speculative start has to adopt the queue.
  • Item 8 — undeclared: the diff deletes the comment "cancelled is deliberately LEFT ALONE … clearing it here would un-cancel somebody else's cancel request". The new rescued-queue branch then runs self._owner._orphaned_cancelled.pop(key, None) on a scoped clear, which goes against what that comment decided.
    Subtraction: delete that pop from the scoped (owned_by) branch and keep the comment.
    Clears when: the pop is removed, or the PR shows evidence the decision in that comment was wrong.
  • Item 9 — undeclared, rides along: the comment in remove_if_unclaimed explaining why a shutdown that raises must not skip cancelling child sessions is deleted, and the PR doesn't say why.
  • Item 10 — undeclared, rides along: tests in test_message_queue.py that this PR doesn't change are reformatted.

What this change ships

Inventory (10 items) — 5 justified

Intent: make sure follow-up messages a user already sent are not lost when a session is reset mid-turn. FIX (#3752).

  1. Follow-ups queued behind a turn that a reset tears down now run on the next session — symptom-level: 3 recycle paths that lose queues are unfixed
  2. Cancellation markers (for example, a deleted Slack message) travel with the rescued queue — justified
  3. Rescued follow-ups can be taken off the queue, cancelled, stopped or cleared before any new session opens — justified
  4. destroy and discard_conversation also drop a queue that an earlier reset rescued — justified
  5. A resume prefetch that adopts a rescued queue and is never claimed hands the queue back — symptom-level: only needed because there are two stores
  6. Temporary image files behind queued follow-ups survive a reset and are deleted only when the entry is actually dropped — justified
  7. Stop with no live session now clears a rescued queue — justified
  8. A scoped clear that empties a rescued queue also drops its cancellation markers; the comment explaining the old rule is deleted — undeclared
  9. A comment in remove_if_unclaimed is deleted — undeclared, rides along
  10. Unrelated tests in test_message_queue.py are reformatted — undeclared, rides along

[FIRST-PRINCIPLES-REVIEWED] 5dd60f8

Description read

[DESCRIPTION-READ] d135bc4e7cbe53e81b46cc839829fa684308dd88b8cac90ab297f6201339a84f

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.

@adiarora06
adiarora06 force-pushed the fix/session-reset-preserves-queued-messages branch from cd9cff5 to 705d706 Compare August 15, 2026 06:31
@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 Aug 15, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed
  • ## Tests

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@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 Aug 15, 2026
@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 5dd60f8

@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 Aug 15, 2026
@adiarora06
adiarora06 force-pushed the fix/session-reset-preserves-queued-messages branch from 705d706 to db77b89 Compare August 15, 2026 07: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 Aug 15, 2026
@adiarora06
adiarora06 force-pushed the fix/session-reset-preserves-queued-messages branch from db77b89 to 10c6c54 Compare August 15, 2026 09:53
@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 Aug 15, 2026
@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 labels Aug 15, 2026
@adiarora06
adiarora06 force-pushed the fix/session-reset-preserves-queued-messages branch from f3a39ad to 72e9e27 Compare August 15, 2026 15:31
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Aug 15, 2026
@adiarora06
adiarora06 force-pushed the fix/session-reset-preserves-queued-messages branch from 72e9e27 to c13b4d7 Compare August 15, 2026 16:31
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Aug 15, 2026
@adiarora06

Copy link
Copy Markdown
Contributor Author

Responding to GPT 5.6 Review's [BLOCK-MERGE] finding at session.py:4293 ("Orphan draining drops deferred Discord and Telegram messages"): confirmed real by tracing _drain_queue() in both discord/transport_dispatch.py and telegram/transport_dispatch.py — the collapse loop's capped-remainder re-enqueue() (force=True) returns False with no live session, exactly the state mid-drain, and the remainder was silently dropped with no home to land in.

Rather than the suggested fix (revert the no-session orphan-draining branch in dequeue()), I kept that branch — it's what makes the normal end-of-turn drain redispatch a rescued message on its own, the core point of this PR — and closed the actual gap instead: enqueue() gained an orphan_fallback parameter that appends to _orphaned_queues instead of returning False when there's no live session. Not the default, since Slack's own pre-session orch._pending_queue fallback relies on the plain False return; only the two remainder re-enqueue call sites opt in. New tests in TestResetPreservesQueuedMessages cover both the default-unchanged case and the capped-remainder round-trip, verified failing against the pre-fix code and passing after.

@iamwhatever

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew [operator: iamwhatever]: This PR has been inactive for 5+ days. I reviewed the blockers but they require your input:

  • GPT 5.6 BLOCKING, Design: BLOCK, and Opus 4.8 BLOCKING on the rescue path (src/kiro_crew/session.py ~:2966/:2968 and :3629 remove_if_unclaimed) — rescued messages bypass deletion cancellation. You've already responded in-thread proposing to keep the scoped fix and defer the larger _orphaned_queues → manager-level-per-key refactor to a maintainer. That maintainer scope decision is exactly what's blocking here: land the narrow fix as-is, or take the storage-location refactor now? A maintainer needs to make that call.
  • Also a blocking note that a fix PR writes a release-only CHANGELOG entry — please confirm that's intended.
  • The branch is behind main and conflicting; a rebase will be needed once scope is decided.

When you've addressed these, the pipeline will re-assess on its next cycle.

@chenmingwei23

Copy link
Copy Markdown
Contributor

Scope recommendation from triage of #3752: land the narrow _orphaned_queues rescue as-is and defer the queue/cancelled-to-manager-level refactor to its own PR.

Rationale: the narrow fix closes the user-visible data loss (queued follow-ups silently dropped on reset) with a small reviewable diff; the manager-level move changes ownership semantics across every teardown path and deserves its own review rather than riding a bug fix. The branch currently shows CONFLICTING against main, so it needs a rebase either way -- rebasing the narrow version is the fastest route to green.

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

Description / code mismatch

The Description asserts a green local lint-and-type gate for exactly the files this PR changes, and the type-check gate is red on the head SHA for errors these lines introduce.

1. "mypy clean on touched files" is contradicted by the diff's own lines and by the red Backend Lint & Type Check run

The Description says —

flake8 / isort / mypy clean on touched files (mypy's 3 pre-existing hooks.py Linux-xattr errors are unrelated and present on unmodified main).

The code does — mypy is not clean on the touched files. Running the repo's pinned mypy under its own pyproject config against the head tree yields five errors that are absent at the merge base: src/kiro_crew/session_lifecycle.py:382, :384, :670, and :672. The cause is that the rescue hunks read and write session.queue through the _SessionEntry Protocol that types the _sessions mapping, and that Protocol declares no queue member (src/kiro_crew/session_lifecycle.py:382; the Protocol itself is at src/kiro_crew/session_lifecycle.py:33-38 in the head blob, and at :43-48 with _sessions at :79 in current main). The flake8 and isort half of the sentence is accurate — all three touched source files are clean at head — so the inaccuracy is confined to the mypy claim.

Risk — mypy src/kiro_crew is a blocking gate in this repo, and Backend Lint & Type Check (3.10) is failure on the head SHA. Because the Description pre-attributes mypy's output to three known unrelated hooks.py xattr errors, a maintainer reading it would take the gate as satisfied and treat the red job as this repo's documented environmental noise. It is not environmental: the errors are on the lines this PR adds, and the fix is one line.

The same paragraph's suite claims (307 passed, 436 passed, 2165 passed) and the ticked Existing tests pass checklist item sit against Backend Tests (3.10, 3), Backend Tests (3.12, 3), and Backend Tests (Windows) (3) all reporting failure on the head SHA while shards 1, 2, and 4 plus the namespace-sandbox shard are green on all three platforms. One shard index failing on three different runners and operating systems is the signature of a deterministic failure rather than a flake. The failing test cannot be named from the cached check-run data, so this half is corroboration for the mismatch rather than an independent finding.

Required change — Either add queue to session_lifecycle._SessionEntry with its concrete type so the two rescue hunks type-check (and address the Optional narrowing at src/kiro_crew/session_lifecycle.py:384), then re-run mypy src/kiro_crew and the failing shard; or remove the mypy word from the claim and the passing-suite counts from the Description, and state what is red on the head SHA.

@bolichen97

Copy link
Copy Markdown
Contributor

@adiarora06 Thanks for this one. Issue #3752 is still open and the bug is still live on main: reset() in src/kiro_crew/session_lifecycle.py unlinks the popped session's queue unconditionally, and the queue accessors in src/kiro_crew/session_allocation.py (dequeue, cancel_queued, clear_queue) all return early when there is no live session. No orphan-queue concept exists anywhere in src/ or test/ on main, so we want to keep this PR rather than close it.

The only neighbouring work that landed is #3776 (for Issue #3768), which unlinks temp files for live queue entries; your branch correctly reuses unlink_queued_temp_paths in its own drop paths. The rescue itself, the manager-side orphan store, the cold-start adoption and the stop_turn clearing are all still missing on main, and that is the scope worth keeping.

Two asks before it can land. First, please rebase: at the sha we audited (ff20351) the branch was 685 commits behind main, and main's session code has since been split across session.py, session_allocation.py and session_lifecycle.py. Second, at that same sha several things the description claims were absent from the diff: orphan-aware dequeue(), the _orphan_key()/canonical-key helper, enqueue(orphan_fallback=...), the CHANGELOG entry, and two named tests. You have pushed since (b1c7b8d), so please confirm which of those are actually in and narrow the description to the code that is really here.

One conflict to expect: open #7161 rewrites the same get_or_create cold-start region and touches the same Protocols, so whichever lands second needs a manual merge there.

Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong.

@adiarora06

Copy link
Copy Markdown
Contributor Author

Rebased and manually ported the queue rescue onto current main and the present session lifecycle/allocation split. The PR is again one commit. The earlier protocol typing failure is resolved; mypy is clean on all three changed source files, and 484 focused session, queue, and eager-spawn tests pass locally alongside isort, flake8, and diff checks.

@adiarora06

Copy link
Copy Markdown
Contributor Author

Follow-up: main advanced again during verification and introduced the new cross-surface Stop request counter in the same lifecycle state. I rebased once more, preserved that behavior alongside the orphan queue store, and reran the complete focused verification: 484 tests pass and mypy, isort, flake8, and diff checks remain clean.

@adiarora06

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and resolved the new lifecycle/allocation conflicts manually. This refresh also addresses both blocking GPT findings from the prior head: orphan lookup now folds canonical/legacy aliases against orphan storage, and registration rollback restores an adopted queue before re-raising. The port preserves current main’s scoped queue clearing and teardown-finally behavior. Focused verification completed with 170 passing tests; the only three test failures were imports of the newly required pathspec package in unrelated dashboard eager-spawn tests.

Copy link
Copy Markdown
Contributor

Triage pass (2026-10-05) against origin/main @ af1eb612da. Head 31161e47f8 is 666 commits behind the merge base 746028435c, and git merge-tree reports conflicts in src/kiro_crew/session_allocation.py and src/kiro_crew/session_lifecycle.py. Please rebase.

Relationship: DISTINCT. Nothing on main or in any open PR covers this. main still has none of the following: no orphan-queue store; reset() still unlinks the popped session's queue; dequeue/cancel_queued/clear_queue return early when there's no live session. Issue #3752 is still open. Keep this PR.

What to expect when rebasing:

  • Since fix(compaction): decline Stop during auto-compaction, never recycle on a user cancel #14850, clear_queue on main takes only= and the soft-stop path uses detach_queue/restore_queue. This PR's clear_queue rewrite and the stop_turn reorder have to be re-ported on top of that. The orphan store also needs the same only= handling.
  • The description still doesn't match the head diff. It says the "normal dequeue path drain[s] an orphan" and "enqueue … account[s] for rescued entries", but at 31161e47f8 both dequeue() and enqueue() are unchanged (session_allocation.py:1546-1550 still returns None with no live session). That is the open GPT blocking F1, so the end-of-turn drain still can't see a rescued follow-up. GPT F2 is also still open: reset() publishes the rescue only after await record_session_ended, and session.cancelled isn't carried over. Either implement both or narrow the description.

These issues are already flagged in the existing reviews, so I'm not adding another change request.

@adiarora06

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and force-pushed the repaired implementation. This update preserves main’s detach/restore and scoped clear_queue(only=...) behavior, publishes rescued follow-ups before reset bookkeeping awaits, lets enqueue/dequeue operate during the orphan window, and carries cancellation markers through adoption and registration rollback. Focused regression coverage is green (31 passed), with Black/isort/flake8/diff checks clean.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks for this one, @adiarora06 — the root-cause framing (reset() discarding session.queue) was spot on.

While this was in review, main landed a fix for the same bug through PR #17164 ("carry queued follow-ups across a recycling reset"). It rescues the queue on reset via _park_reset_queue / adopt_parked_queue (a bounded module-level parked-queue drained onto the successor cold start), so queued follow-ups are no longer lost. That mechanism is incompatible with this PR's _orphaned_queues approach, so there's nothing left to carry forward here.

Flagging for a maintainer to close as superseded by #17164. Leaving it open for now.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you @adiarora06 for this fix and for the clear root-cause write-up (reset() dropping session.queue).

Closing this as fixed on main. The same bug was fixed by #17164 (ebf647989), which parks the queue across a reset via _park_reset_queue (session_lifecycle.py:1678, called at :1518). Its mechanism replaces this PR's _orphaned_queues approach, so there is nothing left to carry over (see this note).

Your branch is kept. If you see a case #17164 misses, please reopen this or open a follow-up.

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) merge conflict Branch has merge conflicts with its base — author must resolve before merge needs-author-decision PR blocked on author input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session: queued follow-up messages are silently dropped when reset() tears down a mid-turn session

4 participants