Repository navigation
fix: agent.wait can return error before the same run later ends successfully - #120606
Conversation
|
Codex review: needs changes before merge. Reviewed August 24, 2026, 9:40 AM ET / 13:40 UTC. ClawSweeper reviewWhat this changesThe PR makes ordinary retryable lifecycle errors provisional across Gateway waiters, session observation, and the embedded TUI until an authoritative same-run outcome arrives. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the new canonical classifier marks blocked and abandoned errors definitive, but Gateway Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherAgent lifecycle events feed a canonical terminal-outcome classifier, then Gateway waiters, session observation, and the embedded TUI each project that result. The change decides when an error may be superseded by a later completion versus when it must remain final. flowchart LR
A[Agent lifecycle event] --> B[Terminal outcome classifier]
B --> C{Definitive or provisional}
C --> D[Gateway agent wait]
C --> E[Session observer]
C --> F[Embedded TUI]
D --> G[Wait result]
E --> H[Session status]
F --> I[Visible chat state]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +320. Total +320 across 9 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: Make Gateway scheduling consume the same definitive classifier as the observer and TUI, then cover blocked and abandoned errors followed by a same-run successful end before grace expiry. Do we have a high-confidence way to reproduce the issue? Yes, from source: emit a blocked or abandoned lifecycle error, then a successful end for the same run before retry grace expires; Gateway’s fallback-only branch schedules the error and its merge accepts the later completion. Is this the best way to solve the issue? No. The classifier is the right owner, but Gateway does not consume it, leaving a separate terminal-policy path that violates the intended fail-closed invariant. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fb576e3518df. 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
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
e7b6c86 to
83282f6
Compare
689ae15 to
36d93ac
Compare
36d93ac to
39c3c99
Compare
60cd7d5 to
674008b
Compare
Normalize provisional retry failures at the canonical terminal-outcome owner and preserve authoritative Gateway, session observer, and embedded TUI completion across repeated retries. Co-authored-by: RileyJJY <[email protected]>
|
@clawsweeper re-review The current clean-room maintainer rewrite addresses both actionable findings and both rank-up moves from the earlier review:
Additional adversarial coverage proves that a second Validation is complete: 253 focused owner and cloud-worker sibling tests passed, changed-file type-aware lint and formatting passed, independent review and structured autoreview are clean, and production code is net -2 lines. A real 15-second production-emitter probe confirmed two waiters recover successfully. A separate clean Blacksmith Testbox ran the actual built Gateway, WebSocket-backed TUI, and real PTY successfully: https://github.com/openclaw/openclaw/actions/runs/32728522321 ( |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Keep retry failures provisional while preserving prior aborted-timeout facts, terminal run identity, and authoritative Gateway, observer, and embedded TUI completion. Co-authored-by: RileyJJY <[email protected]>
|
@clawsweeper re-review The current clean-room maintainer rewrite addresses both actionable findings and both rank-up moves from the earlier review:
Additional adversarial coverage proves that a second Validation is complete: 254 focused owner and cloud-worker sibling tests passed, both hosted-CI failures and their preceding adjacent Gateway case passed in the original source order, changed-file type-aware lint and formatting passed, independent review and structured autoreview are clean, and production code is net zero. A real 15-second production-emitter probe confirmed two waiters recover successfully. A separate clean Blacksmith Testbox ran the actual built Gateway, WebSocket-backed TUI, and real PTY successfully: https://github.com/openclaw/openclaw/actions/runs/32731156848 ( |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Retain canonical retry ownership across Gateway, observer, and terminal projections while keeping asynchronous regression-test state explicitly typed. Co-authored-by: RileyJJY <[email protected]>
|
Merged via squash.
|
…ssfully (openclaw#120606) * fix(gateway): preserve agent wait through late success * fix(gateway): keep timed-out agent waits fail-closed * fix(gateway): recover late lifecycle success across observers * fix(tui): preserve authoritative terminal outcomes --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
agent.waitcould returnstatus: "error"after a retryable lifecycle failure crossed its 15-second grace period even though the same run later completed successfully. The Gateway session observer and embedded TUI could also remain visibly failed after the authoritative result arrived.Fixes #120561.
Root cause and owner-boundary repair
Retry-grace expiry was incorrectly promoted to a definitive run outcome by three independent lifecycle owners. The canonical terminal-outcome owner now makes only an ordinary
failedlifecycle error provisional: exhausted fallback failures, blocked or abandoned runs, cancellation, and hard timeouts remain definitive.agent.waitpending across retry grace, does not expose a premature cached failure to newly arriving waiters, preserves existing sticky timeout/cancellation ordering, and records the final diagnostic only after the last waiter leaves. An error replacing an already-observed aborted lifecycle end still finalizes at the existing grace boundary.The original contributor patch added 113 production lines. This owner-level rewrite instead adds zero production lines overall while adding focused regression coverage.
ClawSweeper findings and rank-up moves
Both existing actionable review findings are resolved:
Independent adversarial review additionally found and resolved three related owner-boundary defects before landing:
Evidence
Failing regressions were recorded on trusted
mainbefore the clean-room repair. Focused owner and sibling coverage now passes 254 tests:Both hosted-CI integration failures also pass against the actual Gateway, including the two adjacent chat cases in their original source order:
After the hosted strict test-type stripe identified an uninitialized local in the new regression, the one-line test-only annotation was corrected. The actual TypeScript 6.0.3 compiler reproduced
TS2454before the change and reported zeroTS2454diagnostics afterward; the exact Gateway-owner test plus both affected existing Gateway flows passed again.Changed-file type-aware lint, formatting, and whitespace checks also passed:
The production event emitter and real 15,000 ms timer independently confirmed that the first waiter remained open, the canonical cache did not expose a provisional failure, and both the original and later waiter resolved successfully:
{"retryGraceMs":15000,"firstStayedPendingBeyondGrace":true,"noPrematureCachedFailure":true,"firstWaitStatus":"ok","laterWaitStatus":"ok","fixed":true}A separate clean Linux Blacksmith Testbox synchronized exactly the nine reviewed source/test files, built the real Gateway, connected the actual WebSocket-backed TUI, and passed the real PTY product test:
Testbox run: https://github.com/openclaw/openclaw/actions/runs/32731156848. The backing Actions lease step may display cancellation after intentional one-shot teardown; the wrapper's final timing JSON and exit code are the authoritative successful proof.
Independent adversarial review and the repository's structured autoreview both returned clean verdicts. Final diff: production net zero; tests +320 lines.
Thanks to @RileyJJY for the original report and contributor implementation.