Repository navigation
fix(gateway): preserve real agent failure and cancellation outcomes - #118331
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 8:39 PM ET / August 3, 2026, 00:39 UTC. ClawSweeper reviewWhat this changesThis PR consolidates Gateway pending terminal-event scheduling so Merge readinessKeep this PR open for landing. The patch corrects the Gateway terminal-state owner without changing protocol, configuration, persistence, or security boundaries; the submitted regression suite covers the previously divergent pending-error and pending-timeout paths, and the reported authenticated Gateway proof is consistent with the source. No blocking correctness finding was identified, but the protected Priority: P2 Review scores
Verification
How this fits togetherGateway receives lifecycle terminal events from agent and worker execution, temporarily holds retryable terminal observations, then returns a canonical result to flowchart LR
A[Agent or worker lifecycle event] --> B[Gateway event listener]
B --> C[Pending terminal records]
C --> D[Canonical outcome precedence]
D --> E[Agent wait resolver]
E --> F[Gateway RPC client]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -10, Tests +477. Total +467 across 2 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the focused owner-boundary repair after the exact reviewed head completes required checks; retain the shared terminal-outcome merger as the single precedence authority and keep lifecycle producers responsible for declaring definitive fallback exhaustion. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main sends all lifecycle errors through retry grace, while the existing worker contract marks exhausted fallback failure as definitive; the candidate’s focused fake-timer cases exercise the delayed and cross-phase precedence paths. The PR body also supplies an authenticated Gateway WebSocket after-fix run, but this read-only review did not execute it locally. Is this the best way to solve the issue? Yes. The patch repairs the lifecycle owner rather than adding a downstream response workaround: it reuses the existing canonical terminal-outcome precedence helper across both pending phase maps and leaves the public Gateway response shape unchanged. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 18c9f27e2de3. LabelsLabel changes:
Label justifications:
EvidenceWhat 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.
|
…penclaw#118331) * fix(gateway): finalize exhausted fallback failures without retry grace * fix(gateway): finalize exhausted provider timeouts immediately * fix(gateway): preserve pending terminal outcomes on finalization * refactor(gateway): unify pending terminal lifecycle ownership * fix(gateway): preserve sticky outcomes for short agent waits --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where agents and clients waiting for a run would see an ordinary queue timeout, a 15-second delay, or the wrong terminal reason after all provider fallbacks failed or an earlier cancellation was followed by a later provider timeout.
Why This Change Was Made
The Gateway terminal-state owner maintained separate phase-specific pending snapshots and discarded the authoritative earlier cancellation or provider outcome when a later lifecycle event arrived. This refactor gives pending error and timeout phases one canonical merge/scheduling path, immediately records definitively exhausted failures, preserves sticky cancellation precedence, and deletes obsolete phase-specific wrappers. Production code decreases by ten lines.
User Impact
Real
agent.waitclients immediately receive exhausted provider failures with the correct provider timeout details. Five-second waits consistently preserve earlier restart/RPC cancellations over later provider timeouts; retryable errors retain their existing retry grace. No protocol, public SDK, authentication, configuration, dependency, or persistent-state contract changes.Evidence
52a32c5aa71b6badf82a0b51b3017b36107594b4; unchanged parent/current-main owner:474c4e671e9f3dfa7785d068b5fdbfb2dad5772e.agent.waitRPC proves definitive provider failure returns immediately with real provider-phase metadata and that an ordinary five-second wait preserves the earlier cancellation after a later provider timeout.{"status":"PASS","head":"52a32c5aa71b6badf82a0b51b3017b36107594b4","distinctRootCauses":1,"transport":"authenticated-gateway-websocket","method":"agent.wait","parentFailed":10,"candidateTestsPassed":81,"changedGate":"PASS","productionBuild":"PASS","productionLocDelta":-10}autoreview --mode branch --base 474c4e671e9f3dfa7785d068b5fdbfb2dad5772e --engine codex --model gpt-5.6-sol --thinking high --max-priority P3 --no-web-search: clean; confidence 0.91; genuine checksum-verified TruffleHog 3.96.0 clean.Maintainer Landing Decision
@steipeteexplicitly delegated autonomous maintainer review and landing of individually verified low-risk QA refactors; this candidate has four independent exact-head approvals, a clean genuine whole-branch Sol review, authentic unchanged-parent failures, and real authenticated Gateway WebSocket proof. Final repository-native landing remains gated on all required exact-head hosted checks and the latest ClawSweeper review.047c016bdd025f4a01b153b733615ce869fddbb0for refreshed main4c66ed5615893313c657d75723c5e77a90abeb50and immutable reviewed head52a32c5aa71b6badf82a0b51b3017b36107594b4; both changed owner/test blobs are byte-identical to the exact reviewed and remotely validated candidate.git merge-tree --write-treecompletes without conflicts.node scripts/watch-pr-ci.mjs 118331 52a32c5aa71b6badf82a0b51b3017b36107594b4completedGREEN; GitHub independently reports zero pending substantive checks, zero failures, andMERGEABLE. The completed exact-head ClawSweeper source review identified no correctness findings.