Skip to content

Keep wait live after interrupt-with-follow-up - #858

Merged
TheGreatAxios merged 5 commits into
mainfrom
cl-7331-interrupted-workers-never-return-queued-follow-up-reports
Sep 10, 2026
Merged

Keep wait live after interrupt-with-follow-up#858
TheGreatAxios merged 5 commits into
mainfrom
cl-7331-interrupted-workers-never-return-queued-follow-up-reports

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • send_input(interrupt: true) leaves wait live until the queued follow-up settles, instead of freezing the mailbox as interrupted
  • Wait, list, and resume agree on running or queued while the follow-up is in flight, then surface the follow-up report as done
  • Close and interrupt wait overlays stay interrupted until collected, including when a follow-up later stamps the session completed

Verification

  • bun test src/subagent/agent-fleet.test.ts: 75 pass, 0 fail
  • bunx eslint on the touched subagent files: no errors (pre-existing warnings only)
  • First CI run on this PR: prettier, typecheck, and build-and-test succeeded; eslint failed on deferred<void> in a new test (fixed on the latest push)

Fixes CL-7331

@linear-code

linear-code Bot commented Sep 9, 2026

Copy link
Copy Markdown

CL-7331

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Critic · Comment

send_input(interrupt:true) still acks interrupted and keeps wait live until the follow-up report surfaces. Edge paths can still disagree or drop salvage.

Findings

  • src/subagent/agent-fleet.ts:260completeAfterInterrupt still deletes forceInterrupted. After this change only close_agent / interrupt_agent set that overlay, so a follow-up reply can undo a later close_agent overlay and freeze wait as done. Trigger: send_input interrupt, then close_agent, then the follow-up resolves before closeOne stamps shutdown.
  • src/subagent/lifecycle-tools.ts:385onFollowupReply is the only clearer for followupLive. A rejected follow-up never calls it (session-store.ts:822-828), so spawn settlement keeps swallowing original salvage.
  • src/subagent/lifecycle-tools.ts:404markQueued has no matching clearQueued when the follow-up begins running. projectedStatus then prefers queued over live running, so list status and lifecycle disagree.
  • docs/ARCHITECTURE.md:231 — still says send_input with interrupt:true sets the mailbox interrupt overlay so wait unblocks. That is the old contract this PR inverted.

Notes

  • interrupt_agent / close_agent still call fleetRecords.interrupt() at the call sites.
  • Happy-path tests in agent-fleet.test.ts cover wait-before-send and post-send timeout → done.
  • Stale comment at src/subagent/lifecycle-tools.ts:311 still claims the overlay flip is the same as send_input interrupt.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Primary · Comment

send_input(interrupt:true) keeps wait live until the follow-up settles on the happy path, but wait/list can still disagree and close/reject paths can drop the overlay or salvage. Cannot request-changes on our own PR; these should-fix items land in follow-up commits on this branch.

Findings

  • src/subagent/agent-fleet.ts:260completeAfterInterrupt still deletes forceInterrupted, so a follow-up reply can undo a later close_agent overlay and freeze wait as done instead of interrupted.
  • src/subagent/lifecycle-tools.ts:385 — follow-up rejection never clears followupLive, so spawn settlement swallows original salvage.
  • src/subagent/lifecycle-tools.ts:404markQueued has no matching clearQueued when the follow-up begins running, so list can show queued while lifecycle is running.
  • docs/ARCHITECTURE.md:231 — still describes the old interrupt-overlay contract this PR inverted.

Notes

  • Happy path holds: tool ack stays interrupted; wait/list/resume agree while the follow-up is running; follow-up report surfaces as done.
  • CI on this PR is green (prettier, eslint, typecheck, build-and-test).

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Critic · Comment

Follow-up commits close the prior overlay/salvage/queued holes. One remaining should-fix: an uncollected close overlay still loses to a successful follow-up completed stamp.

Findings

  • src/subagent/agent-fleet.ts:330projectedStatus returns terminal session status before forceInterrupted. Trigger: no in-flight wait; send_input interrupt; close_agent starts; follow-up complete()s while close is still held; later wait/list show done not interrupted. The new close-window test does not catch this because in-flight wait freezes interrupted first.
  • docs/ARCHITECTURE.md:231 — leftover “does not write a mailbox overlay” in the same bullet the follow-up edited.

Notes

  • Prior items 1–3 are closed with tests. interrupt_agent comment matches. New ARCHITECTURE sentence matches; the old sentence in the same bullet does not.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Primary · Comment

Follow-up commits on this branch close the review findings. Happy path still leaves wait live until the follow-up settles as done; close/interrupt overlays stay interrupted even if a follow-up later stamps the session completed.

Findings

None remaining from the prior should-fix list.

Notes

  • projectedStatus consults forceInterrupted before terminal session status.
  • Rejected follow-up clears followupLive so salvage can attach.
  • Queued overlay clears when the follow-up is admitted.
  • deferred<void> in the new tests is now deferred<undefined> so eslint --max-warnings does not fail CI.
  • bun test src/subagent/agent-fleet.test.ts: 75 pass.

An interrupt overlay freezes wait as interrupted, so a queued follow-up
never surfaces even after it completes. Mark the follow-up lane instead
and leave wait running until that turn settles.
A close or interrupt wait overlay must stay interrupted until collected,
even if a followup later stamps the session completed.

send_input interrupt does not set that overlay, so a happy-path followup
wait still collects done.
Main asserted the wait mailbox flipped to interrupted as soon as
send_input interrupt:true queued a followup. Wait now stays live until
that followup settles; the leftover interrupted stamp remains on the
session.
@TheGreatAxios
TheGreatAxios force-pushed the cl-7331-interrupted-workers-never-return-queued-follow-up-reports branch from dae5b48 to 58f9bab Compare September 10, 2026 01:19
@TheGreatAxios
TheGreatAxios merged commit 9382db0 into main Sep 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant