Repository navigation
fix(cloud-workers): retry timed-out dispatches without reprovisioning - #121616
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 10, 2026, 10:54 AM ET / 14:54 UTC. ClawSweeper reviewWhat this changesThis PR lets identical cloud-session dispatch retries share the in-flight Gateway operation during provisioning, while rejecting conflicting session, agent, or profile requests. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep this PR open: the coordinator-level single-flight is the right repair for the provisioning retry race, but the new Cloud Workers guide contradicts the unchanged configuration reference on whether AWS SSH CIDRs are required. Priority: P1 Review scores
Verification
How this fits togetherCloud-session dispatch moves a Gateway session onto a managed worker. The Gateway validates the placement, coordinates reconciliation and provisioning, then returns the active placement to the requesting RPC or CLI client. flowchart LR
A[RPC or CLI dispatch request] --> B[Placement-state validation]
B --> C[Dispatch coordinator]
C --> D{Matching operation in flight?}
D -->|Yes| E[Share existing promise]
D -->|No| F[Reconcile and provision worker]
E --> G[Terminal placement result]
F --> G
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +28, Tests +85, Docs +2, Other 0. Total +115 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the coordinator-owned single-flight registry, then align the configuration reference with the guide’s optional fixed-CIDR guidance; the registry cannot be absorbed into the existing aggregate barrier state without losing identity-safe retry sharing. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main rejects provisioning before the coordinator, and the branch’s focused ordering test encodes the same retry sequence. No live reproduction was run in this read-only review. Is this the best way to solve the issue? Yes for the runtime defect: coalescing at the coordinator, before reconciliation can queue a retry, is safer than a leaf-dispatch workaround and preserves the existing state-machine owner. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5295f2578e1b. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…openclaw#121616) * fix(cloud-workers): coalesce dispatch retries Amp-Thread-ID: https://ampcode.com/threads/T-019feaaa-c7ed-769e-9f29-a3612bec72e7 * chore: lower environment variable count budget Amp-Thread-ID: https://ampcode.com/threads/T-019feaaa-c7ed-769e-9f29-a3612bec72e7 --------- Co-authored-by: Amp <[email protected]>
Closes #121612
AI-assisted: yes. The implementation and tests were inspected and validated before publication.
What Problem This Solves
Fixes an issue where users retrying cloud-session dispatch after an RPC or CLI timeout would receive
session cannot dispatch from placement provisioningeven though the original dispatch was still running server-side.Why This Change Was Made
Identical same-Gateway retries now join the one in-flight dispatch at the reconciliation coordinator, before any queued reconciliation barrier can delay the retry into a fresh operation. Requests with a different session identity, agent, or profile still reject, and active/draining/reconciling placements remain non-dispatchable.
The single-flight entry is identity-guarded and cleared after both success and failure. This location is important: coalescing inside the leaf dispatcher alone races with the outer reconciliation barrier and can still produce a fresh dispatch after failure.
The cloud-worker guide now documents request-time AWS SSH CIDR discovery, the read-only scope of
crabbox doctor, retry behavior, and the currently supported profile fields.Production LOC: +33/-5 (net +28) | Tests: +100/-15 | Docs: +9/-7. The production growth owns one process-local operation registry at the existing dispatch/reconciliation boundary; no second dispatch path or compatibility shim is added.
Provenance: the blanket nonlocal-placement gate was introduced by #107677 on 2026-07-14; code author and merger were @steipete. The surrounding cloud-worker dispatch coordinator originated in #106332.
User Impact
Operators can safely retry an identical cloud-session dispatch after a client timeout without allocating another worker or losing the original terminal result. Conflicting retries fail explicitly.
Evidence
node scripts/run-vitest.mjs src/gateway/server-worker-placement-startup.test.ts src/gateway/server-methods/sessions.dispatch.test.ts --reporter=dotpatch is correct(0.97), no accepted/actionable findings.openai/gpt-5.6-luna.ec2:ImportKeyPair; no instance was launched. Final authoritative AWS lease inventory was empty. VM bootstrap, remote tool execution, and workspace reconciliation remain blocked by that external IAM policy and are not claimed as passing.