Repository navigation
fix(platform): fail a step whose workspace is being destroyed - #4144
Merged
Merged
Conversation
While an administrator's Destroy of a session is queued, retrying or running, its admission refuses the next start (SandboxDestroyPendingError, #4095). The shims flattened that refusal into the QUOTA_EXCEEDED a spent budget throws, so since #4099 the automation lane read it as a wait for room: the step re-kicked for up to two hours with the false reason "the organization's workflow sessions are all in use", and once the Destroy had settled it reserved a fresh row and continued the run in an empty workspace, without the files and transcripts of its earlier steps. The refusal now carries reason: 'destroy_pending' through quotaAsAppError, and capacity_refusal reads it apart from a spent budget in every shape a quota refusal arrives in. An automation step's start, and an answered question's resume, fail at once with the Destroy's own words under the new node code sandbox_destroying: never retried, since a retry after the Destroy would start over in an empty workspace, and reported as start_failed on the wire (AGENT_RETRY_ONLY_CODES), so the OpenAPI enum does not move. A task's run still parks on it until the Destroy settles. Tests: the classifier in every shape, classifyWorkflowStartFailure, the real hosts' start and answered-ask resume, the stepper (no re-kick, the run fails start_failed with the reason), the shim's marker on both slot verbs, the task lane's parking, and the real-Postgres lane checkAutomationStepDestroyPending: a two-step run whose workspace is destroyed during its first step fails its second with the Destroy's reason while the Destroy is pending, and nothing starts in the run once it has settled. On main the same lane reads the run waiting for room, then finishing in a fresh incarnation. The Sandboxes guide (EN/DE/FR), the sessions doc comment and the manual register say the same.
The Sandboxes guide said a start that waits for room needs nothing from the administrator, disk space included. Stopping idle work frees no disk, because a stopped workspace keeps its files for its resume (session-routes.ts): the spawner removes build caches no session uses, and otherwise the start waits until workspaces are deleted or the operator frees space. EN/DE/FR now say so; limits, a full deployment and memory still clear on their own.
Contributor
Author
|
Independent review of PR #4144 at
Runtime (mine; real PG 16.14)
Source, cross-checked with one read-only reviewer
LOW
INFO
Docs: EN/DE/FR Whole-PR CI at the exact head (merge ref
Merge: squash with |
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The defect (#4122, a MEDIUM regression on
mainsince #4099). While an administrator's Destroy of a session is queued, retrying or running, admission refuses the session's next start withSandboxDestroyPendingError(#4095).quotaAsAppErrorflattened that refusal into theQUOTA_EXCEEDEDthat a spent budget throws.classifyWorkflowStartFailureread it as organization room. The step re-kicked for up to two hours with the false reason "the organization's workflow sessions are all in use".The fix:
SandboxQuotaErrorcarries an optionalreason.SandboxDestroyPendingErrorsets it todestroy_pending, andquotaAsAppErrorkeeps it in the AppError payload (data.reason). The constant and the Destroy sentence now live incore/sandbox/session_constants.ts.capacity_refusal.tsreads a quota refusal in all three shapes it arrives in: AppError data, the domain error's own fields, and a wrapped message. It tellsdestroy_pendingapart from a spent budget.sandboxCapacityRefusalno longer returns organization room for it, and the newisDestroyPendingRefusalnames it.the agent turn could not start: An administrator is deleting this sandbox workspace. …. There is no room wait, noretryAtMs, and no undelivered-ask carry-over.agent_run_host.tsparks on the refusal explicitly, so its behaviour is unchanged: the run waits until the Destroy settles.Decision (accepted by the manager, routine). The step settles with a new retry-only node code,
sandbox_destroying.NO_RETRY_FAILURE_CODES, so it is never retried or resumed.AGENT_RETRY_ONLY_CODESreports it asstart_failed, soRun.failureCodereadsstart_failedand the OpenAPI enum doesn't move.start_failedwould not be enough: it retries three times with no wait between attempts. A retry that lands after the Destroy settled would again continue in an empty workspace.Docs and register. The code,
sessions.ts, EN/DE/FRsandboxes.mdand register rowautomation.md:170now agree.:68): the step fails at once, without waiting or retrying.:108): a workspace being destroyed is no lack of room.:105): stopping idle work frees no disk space. Tale removes build caches no session uses; otherwise the start waits until workspaces are deleted or the operator frees space.Finding → commit → test
main1ba77ed → passes at head)capacity_refusal.test.ts: "reads a pending Destroy as no want of room, in every shape it arrives in"agent_host.start_gate.test.ts: "fails a start whose workspace an administrator is destroying …";agent_host.context_window.test.ts: the real start and the answered-ask resumestepper.agent-retry.test.ts: "fails a step whose workspace an administrator is destroying at once, neither waiting for room nor retrying";agent_retry.test.ts,failure.test.tsquotaAsAppErroragent-turn-shim.destroy-pending.test.ts: both slot verbs on a Destroy-pending row, through the real shim, sessions domain and classifiersagent_run_host.context_window.test.ts: "parks a start whose workspace an administrator is destroying …" (a regression lock: passes onmaintoo)backend:integration, new lanecheckAutomationStepDestroyPendingVerification
Unit tests:
mainwith only the new test files copied in: 12 of the new checks fail; the task-lane lock passes. For example:sandbox_capacitywith "the organization's workflow sessions are all in use";notBefore.Real-Postgres lane (local PostgreSQL 16 + pgvector,
ITEST_LANES=checkAutomationStepDestroyPending, fresh databases, no object store needed):head (
807a95888, clean worktree):PASS … first step running=true, destroy=202, pending=true; 1770 ms after the first step ended: run=failed/start_failed "publish: the agent turn could not start: An administrator is deleting this sandbox workspace. …", Destroy still pending then=true; Destroy settled=true, then run=failed, session rows=destroyed (no fresh incarnation), spawner creates=1 execs=1main + the lane:
FAIL … 1694 ms after the first step ended: run=waiting/- "room:publish", Destroy still pending then=true; Destroy settled=true, then run=success, session rows=destroyed,stopped, spawner creates=2 execs=2On
mainthe second step waited for room, then ran in a fresh, empty workspace.The only other local failure is the known
knowledge BM25 indexes verified at bootcheck.pg_searchis absent locally; the same check fails onmain.Exact-head CI (
807a95888): 51 pass, 11 skipping, 0 fail.PASS automation step: a pending Destroy of the run's workspace … 1623 ms after the first step ended: run=failed/start_failed … session rows=destroyed … creates=1 execs=1. Total:1504/1504 checks passed across 223/223 lanes, withITEST_REQUIRE_ALL_LANES=1.stepper.agent-retry.test.ts(17 tests),agent-turn-shim.destroy-pending.test.ts(4) andcapacity_refusal.test.ts(6).Static gates:
oxfmt --checkandoxlint --type-awareon the changed files;tsc --noEmitof the changed files,integration-check.tsincluded;bun run knip:check;bun run lint:manual;services/docslocale, prose and link suites.Recorded, not changed
LOW: a front waiter can lose its place in the spawner's line. I confirmed the mechanism from source; I did not execute it.
2 × hint + 15 s. For the front waiter that is 25 s (waitersAhead,QUEUE_FRONT_HINT_MS,QUEUE_LIVE_SLACK_MSinsession-routes.ts).AGENT_START_SLOTSone-job slots.DRAIN_WINDOW_MS). So under load a due re-kick can wait past 25 s, then rejoin at the back of the line.Nit, out of scope: a script node that meets a pending Destroy fails, as before, but with the serialized payload as its detail (
script_host.ts→ensureWorkflowSession).Overlap: #4094 edits other lines of the same docs and register files. Whichever merges second resolves the textual conflict.
Closes #4122