[task-service] 🤖 fix: prevent false workspace turn interruptions - #3915
[task-service] 🤖 fix: prevent false workspace turn interruptions#3915coadler wants to merge 9 commits into
Conversation
|
@codex review Please review the workspace-turn lifecycle changes. |
This comment has been minimized.
This comment has been minimized.
|
@codex review Please review the implementation. The prior response only contained the completed security review. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fbe142a01
ℹ️ 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".
|
Addressed both Codex findings in
Added regression tests for waiter preservation, handoff order, enqueue failure, and explicit cancellation. |
|
@codex review Both P1 findings are addressed in |
This comment has been minimized.
This comment has been minimized.
|
@codex review The security review completed, but no code-review approval appeared. Please run the code review for |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5674e42de
ℹ️ 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".
|
@codex review The CI unit test now matches the queued terminal continuation behavior in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07eba9212c
ℹ️ 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".
This comment has been minimized.
This comment has been minimized.
|
Addressed The terminal attention record is now persisted before the background continuation starts. The Added a regression test that invokes |
|
@codex review The final attention-ordering finding is addressed in |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3da714e8cf
ℹ️ 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".
|
Addressed the current Codex findings in
The fix also preserves delivery callbacks after correlation removal. Stable child generations now use generation-specific terminal queue keys. Local validation passed:
|
|
@codex review Please review commit |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5f36592d3
ℹ️ 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".
|
Addressed
Added a regression for a workspace-turn entry with no callbacks. Local validation passed:
|
|
@codex review Please review commit |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This comment has been minimized.
This comment has been minimized.
Prevent intentional report coalescing from canceling its owning workspace turn. Preserve correlation across machine-generated continuation rows. Allow exact correlated results to repair inferred uncorrelated interruptions. --- _Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$0.13`_ <!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=0.13 --> Co-authored-by: Mux <noreply@coder.com>
Queue the correlated terminal continuation before removing queued progress. Keep uncorrelated stream endings nonterminal while an exact continuation exists. Retain queued progress if the terminal continuation cannot start. --- _Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$0.13`_ <!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=0.13 --> Co-authored-by: Mux <noreply@coder.com>
Update the nested terminal report test for queued correlated continuation delivery. --- _Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$0.26`_ <!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=0.26 --> Co-authored-by: Mux <noreply@coder.com>
Persist terminal attention before a background terminal continuation can start. Mark it delivered during acceptance to prevent a duplicate idle drain. --- _Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$0.26`_ <!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=0.26 --> Co-authored-by: Mux <noreply@coder.com>
a64261f to
b11b7ea
Compare
|
@codex review Rebased onto current |
This comment has been minimized.
This comment has been minimized.
|
@codex review Please review the rebased commit. The prior automated response only reported the security review result. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b11b7eacea
ℹ️ 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".
|
@codex review All required CI checks now pass on |
This comment has been minimized.
This comment has been minimized.
|
Addressed both findings in
Validation:
|
|
@codex review Both new lifecycle findings are addressed in |
This comment has been minimized.
This comment has been minimized.
|
@codex review The security review for |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e8fde0fff
ℹ️ 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".
|
@codex review All findings are resolved and local validation passes. Please run the code review for |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e8fde0fff
ℹ️ 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".
--- _Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$1.44`_ <!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=1.44 -->
--- _Generated with `mux` • Model: `openai:gpt-5.6-sol` • Thinking: `xhigh` • Cost: `$1.44`_ <!-- mux-attribution: model=openai:gpt-5.6-sol thinking=xhigh costs=1.44 -->
|
@codex review The latest commits address all reported continuation and restart-recovery races. |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4616ece24
ℹ️ 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".
| onCanceled: () => { | ||
| this.releaseTerminalAttentionClaims(ownerWorkspaceId, pending); | ||
| this.scheduleTerminalAttentionDrainAfterIdle(ownerWorkspaceId); | ||
| }, | ||
| onAcceptedPreStreamFailure: async () => { |
There was a problem hiding this comment.
Preserve fallback delivery callbacks after correlation stripping
When this idle-only fallback queues behind a busy turn and user input is later prioritized ahead of it, MessageQueue.revalidateWorkspaceTurnCorrelations() strips onCanceled and onAcceptedPreStreamFailure along with the stale workspace-turn metadata. These callbacks also own the terminal-attention claims, so clearing the reordered entry or failing during pre-stream startup leaves the notifications permanently claimed and prevents subsequent drains from retrying them until restart. Pass the claim-release/re-arm work through the delivery callbacks, as the direct terminal-continuation path does.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| const correlation = this.buildWorkspaceTurnMuxMetadata(record); | ||
| if (this.hasConcreteSameTurnContinuation(event, correlation)) { |
There was a problem hiding this comment.
Settle deferred turns when monitor wakes are canceled
When an uncorrelated queue-cut stream-end reaches this branch while a bash-monitor wake is pending, it returns without settling the handle or recording a deferred event. That wake can subsequently be removed when its process is canceled or its output is shown, but the wake's cancellation callback only retires its own delivery record and never re-enters TaskService; no replacement stream-end then arrives, leaving the workspace-turn handle and its waiters running indefinitely. Re-evaluate the captured stream-end when the cancelable wake is removed, or only defer once the continuation is durably accepted.
AGENTS.md reference: AGENTS.md:L211-L211
Useful? React with 👍 / 👎.
| const WORKSPACE_TURN_UNCORRELATED_STREAM_END_ERROR = | ||
| "Workspace turn superseded by an uncorrelated workspace stream-end"; |
There was a problem hiding this comment.
Allow inferred interruptions to self-heal
Fresh evidence is that this newly introduced marker is documented as correctable by later correlated evidence, but isSelfHealEligibleSettledWorkspaceTurn() does not include it. If an uncorrelated stream-end settles the handle just before a correlated final becomes visible, the later final passes allowTerminalResettle: true but is rejected because the current interrupted record is not eligible; read-time reconciliation skips it for the same reason, leaving the handle and caller permanently stuck with the false interruption. Add this marker to the inferred/self-heal eligibility set while continuing to exclude explicit user cancellations.
AGENTS.md reference: AGENTS.md:L110-L110
Useful? React with 👍 / 👎.
Summary
Prevent false workspace-turn interruptions during nested child activity.
Background
Workspace
7b72901012showed several completed child turns as interrupted.Terminal reports intentionally replaced queued progress reports. The cleanup also invoked the cancellation callback.
Synthetic continuation rows could also hide the active workspace-turn correlation.
Implementation
Risks
This change modifies task and workspace lifecycle handling.
A regression could delay a real interruption or duplicate a terminal response. Exact correlation and durable claim checks limit this risk.
Generated with
mux• Model:openai:gpt-5.6-sol• Thinking:xhigh• Cost:$1.44