Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR allows dedicated-worker destruction to proceed after a failed computer-session release and reports pending teardown as stopping without an available desktop. Example: A dedicated AWS Linux desktop worker's CUA session expires after 300 seconds idle and release returns DriverError.Tool.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current teardown defect that leaves paid dedicated workers running, preserves shared-host cleanup guarantees, and supplies relevant live evidence. No actionable introduced defect was found; CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway worker lifecycle receives Stop, reclaim, and destroy requests, joins transport cleanup, invokes the lease provider, and projects environment availability to clients. flowchart TD
A[Stop or reclaim] --> B[Worker lifecycle]
B --> C[Transport cleanup]
C --> D[Computer owner]
B --> E[Provider destruction]
E --> D
B --> F[Environment projection]
F --> G[Client status]
Technical reviewBest possible solution: Use the existing dedicated-machine teardown contract to restore working Stop while retaining cleanup custody until confirmed destruction. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the failing cleanup-before-destroy chain, and the contributor supplies live baseline reproduction using CUA idle expiry; this read-only review ran no target code. Is this the best way to solve the issue? Forwarding the existing provider teardown reason repairs the shared lifecycle boundary without weakening shared-host cleanup or treating an unconfirmed lease as released. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3f97b146a5aa. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +35, Tests +191, Docs +7. Total +233 across 10 files. Added test files: 2. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 10, 2026, 9:51 PM ET / October 11, 2026, 01:51 UTC (Revision 2). |
…uter driver is wedged Provider teardown passes provider-destroying/provider-destroyed to the node tunnel for dedicated machines only, but the attached-computer close joined the same teardown without the reason. One failed native release rejected stopOwner before destroyLease, so idle reclaim, Stop, and force retried for an hour, parked, and left the paid machine running. The computer owner now receives that reason: provider-destroying logs a failed release and keeps custody so a failed destroy stays retryable; provider-destroyed releases the owners. Shared and unknown hosts still require the release. A pending teardown also projects stopping without a desktop, matching desktop admission. Closes openclaw#166196
9792aa6 to
ba79978
Compare
Closes #166196
What Problem This Solves
Fixes: Stop, idle reclaim, and
environments.destroy { force: true }all fail and the paid machine keeps running when a dedicated cloud worker's attached computer-use driver can no longer release its session. Seen on native Windows after a UAC prompt stalled the agent; reproduced live on Linux below by keeping one turn's computer execution idle past the driver's 300 s idle TTL, after which every driver call, including the release, fails withauthorization context expired/DriverError.Tool.User Impact
User impact: a dedicated cloud worker whose computer driver is wedged is destroyed on Stop, reclaim, or force, instead of retrying for an hour and parking with "Run crabbox stop ". While its teardown is pending,
environments.listreportsstoppingand no longer advertises a desktop thatdesktop.observealready refuses. Shared and unknown hosts keep today's behavior: their stop still waits for the computer session to be released.Why This Change Was Made
Provider teardown already passes a reason (
provider-destroying, thenprovider-destroyed) to the node tunnel for dedicated machines only, so a machine the provider is about to destroy does not need the worker's own stop acknowledgement. The attached-computer close joined that same teardown later without the reason, so one failed__close_executionrejectedstopOwnerbeforedestroyLeaseon every attempt.The computer owner now receives the same reason:
provider-destroying: closing still fences local input; a failed native release is logged instead of blocking the destroy, and the owner keeps custody so a failed provider destroy stays retryable.provider-destroyed: the confirmed destruction releases those owners.The environment projection applies the existing desktop admission rule (
destroyRequestedAtMs) todesktopAvailable, and the summary maps a pending teardown to the existingstoppingstatus; recorded errors still reporterror. The desktop docs describe both.Evidence
Live before/after with the shipped Stop flow: Crabbox on AWS (Linux desktop worker, profile
class: small, dedicated), Gateway on a separate Linux host, modelxai/grok-4.7. Same config and steps on both builds; only the checkout differs (main4644b02 vs this patch at 9792aa67, which is patch-identical to the current head after the rebase below). Times are UTC; environment ids are replaced with<env>.Trigger, no fault injection: one agent turn takes a
computerscreenshot of the attached desktop, runsexec sleep 115three times, then takes another screenshot. The CUA driver session idles past its idle TTL (maxIdleTtlSeconds: 300ninextensions/cua-computer/src/driver-client.ts), so the second screenshot fails as in the issue, and the end-of-turn native release fails the same way:(The same on
@trycua/cua-driver0.32.0 directly: after the idle TTL an action returnspermission_denied: authorization context expiredandendSessionthrowsDriverError.Tool.)Then Stop (
environments.session.destroy) while an in-process client samplesenvironments.listfor 75 s, about 150 samples/s, printing only changes.main4644b02:The lease kept running until a manual
crabbox stop.This PR:
EC2 reports the lease instance terminated at 01:38:09 (
User initiated), from this Stop.Regression tests through the real owners (computer service + transport owner with a deterministic native close failure; worker environment service + node tunnel manager):
computer-service.test.ts: strict without a reason, non-blocking and retained onprovider-destroying, released onprovider-destroyed.provider-node-teardown.test.ts: a dedicated machine with a wedged attached computer reachesprovider.destroyanddestroyed; a shared host still rejects withAttached computer cleanup failedand never calls destroy; a pending dedicated teardown summarizes asstoppingwithoutdesktop.main(4644b02) the three new behavior tests fail with the reported chain (Attached computer cleanup failed<-Session computer cleanup failed<-DriverError.Tool) andexpected 'available' to be 'stopping'; the shared-host case passes on both.Cost (local, Node 24.21,
pnpm test <file> --maxWorkers=1): the newcomputer-service.test.tscase runs in about 0.07 s; the three newprovider-node-teardown.test.tscases take about 2.7-3.0 s each, in line with the file's existing cases that share its service fixture.Checks: the
pnpm check:changedplan for this diff (lanes core, coreTests, docs), run step by step: format, oxlint,tsgo:core,tsgo:core:test, import cycles, the SQLite worker, assertion-safety, mock-export and timeout ratchets, boundary and docs-config checks all pass.Regression run (
src/gateway/worker-environments, the computer tool, environments RPC, desktop, and the othersummarizeWorkerEnvironment/desktopAvailableconsumers): passing apart from the items below. One existing expectation changes on purpose: theenvironments.listfixture inenvironments.pool.test.tshasdestroyRequestedAtMsset and now reportsstoppinginstead ofavailable. The Control UI already mapsstatus: "stopping"(ordestroyRequestedAtMsin details) to its releasing pool state.Inherited on
main4644b02, reproduced without this diff and not changed here:check:max-lines-ratchetstep:OPENCLAW_* count 456 exceeds budget 455.lint:tmp:tsgo-core-boundary: advisoryui-e2e: 722 test roots exceeds the advisory 720 limit.tools/solid-lint/index.mjs,update-command-post-activation-inspections.ts,sessions-channel-fixture.test-support.ts).bootstrap.test.ts(npm archive bootstrap),workspace-sync-inventory.test.ts,placement-force-abandon.test.ts,local-workspace-template.test.ts, and theserver.app-sdk-composed-resources.test.tstimeout.worker-turn-execution.test.tsandlive-chat.test.tseach failed once in a heavily loaded parallel run and pass when run alone (live-chat 3/3).destination-authority.e2e.test.tsandinference-authority.e2e.test.tswere not run locally: their E2E runtime build did not complete on this host.Rebased onto
main3666e84 because the previous CI merge ref included #168635's lint and SDK-surface breakage (check-lint-core-2/-4insrc/plugin-state/plugin-state-observation-cache.tsandsrc/infra/sqlite-worker-plugin-comparison.test.ts,plugin-sdk-surface-report.test.ts), whichmainfixed in f9940dc. The patch is unchanged (samegit patch-id); on the rebased treecomputer-service.test.ts,provider-node-teardown.test.ts, andenvironments.pool.test.tspass (22 tests).Not changed here: the driver session expiring after 300 s idle inside one turn, after which later
computercalls in that turn fail.