Skip to content

Comments

🤖 fix: cascade interrupt descendants without deleting workspaces#2539

Merged
ThomasK33 merged 11 commits intomainfrom
workspace-interrupt-ap4r
Feb 22, 2026
Merged

🤖 fix: cascade interrupt descendants without deleting workspaces#2539
ThomasK33 merged 11 commits intomainfrom
workspace-interrupt-ap4r

Conversation

@ThomasK33
Copy link
Member

Summary

Switch parent hard-interrupt cascade behavior from destructive termination to non-destructive interruption for descendant agent task workspaces.

Background

We recently added cascading interrupts from parent workspaces to descendants. The initial implementation removed descendant workspaces entirely, which made interruption destructive and prevented users from inspecting child workspace state after a stop.

Implementation

  • Keep the existing cascade entrypoint in WorkspaceService.interruptStream, but update behavior/logging to treat descendants as interrupted.
  • Update TaskService.terminateAllDescendantAgentTasks to:
    • stop descendant streams (abandonPartial: true)
    • reject pending waiters with Parent workspace interrupted
    • mark descendant task workspaces as taskStatus: "interrupted"
    • avoid calling workspace removal/deletion
  • Extend task status schemas/tool status enums to include interrupted.
  • Make waitForAgentReport fail fast with Task interrupted for interrupted tasks.
  • Guard handleStreamEnd to no-op interrupted tasks.

Validation

  • bun test src/node/services/taskService.test.ts -t "terminateAllDescendantAgentTasks|waitForAgentReport rejects interrupted"
  • bun test src/node/services/workspaceService.test.ts -t "interruptStream"
  • bun test src/node/services/tools/task_list.test.ts src/node/services/tools/task_await.test.ts
  • make typecheck
  • make static-check

Risks

  • Adds a new persisted task status (interrupted).
  • Any downstream logic that assumes only queued/running/awaiting_report/reported could regress if not schema-driven.
  • Mitigation: updated shared schemas/tool status enums and added targeted tests for interruption behavior.

Generated with mux • Model: openai:gpt-5.3-codex • Thinking: xhigh • Cost: $0.65

Switch cascading parent hard interrupts from destructive termination to
non-destructive interruption for descendant agent task workspaces.

- stop descendant streams and reject pending waiters
- mark descendant tasks as interrupted instead of removing workspaces
- keep descendant workspace metadata/session available for inspection
- update schemas/tool status enums to include interrupted
- make waitForAgentReport fail fast for interrupted tasks

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e2a403c19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Address Codex feedback for non-destructive interrupt cascades by restoring
interrupted descendant task workspaces to running on successful
sendMessage/resumeStream.

This ensures stream-end finalization runs normally for resumed tasks so
agent_report handling and task_await completion continue to work.

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5a80e3fc7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Only restore interrupted descendant task status to running when
resumeStream reports started=true. If started=false (session still busy),
retain interrupted state so task_await keeps fail-fast semantics.

Adds regression tests for started=true and started=false resume behavior.

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8836ea637

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Guard markInterruptedTaskRunning with a pre-check so it exits before
editConfig unless the workspace is actually an interrupted descendant
agent task.

This keeps send/resume hot paths from triggering unnecessary config writes
for normal workspaces.

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 608b7c2493

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Move interrupted descendant task transition to running before calling
AgentSession send/resume methods, and rollback to interrupted when send/
resume fails or resume starts no stream.

This preserves fail-fast interrupted semantics while allowing resumed
tasks to finalize through stream-end/report handling.

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a6a6b611b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

For interrupted descendant tasks, transition to running before queue checks
so queued retries don't bypass lifecycle restoration.

Also restore interrupted status on thrown send/resume failures to avoid
leaving tasks in phantom running state when no stream actually resumes.

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f805d68741

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Keep interrupted tasks from being auto-queued while still busy to avoid
flipping to running before a new stream can actually start.

Also retain rollback coverage for send/resume throw paths and add regression
tests for interrupted busy-task behavior.

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a60495cc2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- block busy interrupted resume attempts up-front in resumeStream
- preserve queued taskPrompt when cascading interrupts mark descendants interrupted
- add regression tests for busy interrupted send/resume handling and queued prompt preservation

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d55909727

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…ions

Keep taskPrompt intact when transitioning interrupted tasks to running so
failed/no-op resume attempts can restore interrupted state without losing
the original queued task intent.

---

_Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.65`_

<!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.65 -->
@ThomasK33
Copy link
Member Author

@codex review
Please take another look.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

const stopResult = await this.aiService.stopStream(id, { abandonPartial: true });
if (!stopResult.success) {
log.debug("terminateAllDescendantAgentTasks: stopStream failed", { taskId: id });

P1 Badge Prevent queued messages from restarting interrupted descendants

When terminateAllDescendantAgentTasks aborts each descendant via aiService.stopStream(...) but now keeps the workspace instead of removing it, any queued messages in that descendant session can still be auto-flushed on stream end (AgentSession calls sendQueuedMessages() in stream-end cleanup). In that case, a supposedly interrupted descendant can immediately start a new turn and continue spending tokens, which breaks the hard-interrupt cascade semantics. This occurs specifically when a child task had pending queued input at the time the parent was hard-interrupted.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33
Copy link
Member Author

@codex review\nPlease take another look at the queued-message interrupt path fix.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78a0a890e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33
Copy link
Member Author

@codex review\nAddressed the repeated-interrupt queued prompt preservation issue. Please re-review.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33 ThomasK33 added this pull request to the merge queue Feb 22, 2026
Merged via the queue into main with commit e2bfd19 Feb 22, 2026
23 checks passed
@ThomasK33 ThomasK33 deleted the workspace-interrupt-ap4r branch February 22, 2026 20:00
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