Skip to content

[Fix] Active task sandbox closes after a provider error - #984

Merged
mrubens merged 2 commits into
developfrom
fix/preserve-sandbox-provider-errors-3tdbl5k5id67h
Aug 2, 2026
Merged

[Fix] Active task sandbox closes after a provider error#984
mrubens merged 2 commits into
developfrom
fix/preserve-sandbox-provider-errors-3tdbl5k5id67h

Conversation

@roomote-community

@roomote-community roomote-community Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Opened on behalf of Matt Rubens. Follow up by mentioning @roomote, in the web UI, or in Discord.

What changed

  • Treat terminal model-provider errors as failures of the current turn instead of terminal failures of the task session.
  • Keep the task in waiting_for_prompt, preserve the visible error, and accept follow-up prompts without restarting the sandbox.
  • Use the ordinary idle keepalive before snapshot or standby retention, while explicit cancellation and failures without a usable runtime session remain terminal.
  • Preserve BullMQ's completed snapshot or standby result when the provider leaves the worker alive after a successful retention handoff.

Why this change was made

A provider error could immediately close the task and discard an otherwise healthy working environment. Model-turn failure and sandbox lifecycle should be independent so users can recover without losing workspace state.

Impact

Provider errors no longer force active task sandboxes to close or sleep immediately. Users can send a follow-up in the same task, inactive sessions retain their workspace through the normal idle lifecycle, and a completed retention handoff cannot be overwritten by a stale failed result.

@roomote-community

roomote-community Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

No new code issues found. See task

  • apps/worker/src/run-task/run-task.ts:2121 A successful retention handoff can be overwritten as Failed: BullMQ records a completed snapshot/standby, but if the provider leaves this worker alive, waitForExternalSleepAction returns and runTask still returns resolvedResult (Failed), so executeTaskRun calls taskRuns.done(Failed). Preserve the scheduler-owned completion or avoid returning a failed result after a successful handoff.

Reviewed bddc026

@roomote-community

roomote-community Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the scheduler-owned completion race. A completed snapshot/standby handoff now returns Completed, so the worker cannot overwrite BullMQ's completion with the stale pre-handoff Failed result. Regression coverage verifies both completed handoffs and failures without a retention deadline.

Commit bddc026 · See task

@mrubens
mrubens marked this pull request as ready for review August 2, 2026 03:43
@mrubens
mrubens merged commit e079e60 into develop Aug 2, 2026
19 checks passed
@mrubens
mrubens deleted the fix/preserve-sandbox-provider-errors-3tdbl5k5id67h branch August 2, 2026 03:43
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