Skip to content

fix: agent.wait can return error before the same run later ends successfully - #120606

Merged
steipete merged 7 commits into
openclaw:mainfrom
RileyJJY:sunlit/fix/issue-120561
Aug 24, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
RileyJJY:sunlit/fix/issue-120561

Conversation

@RileyJJY

@RileyJJY RileyJJY commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

agent.wait could return status: "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 failed lifecycle error provisional: exhausted fallback failures, blocked or abandoned runs, cancellation, and hard timeouts remain definitive.

  • Gateway run ownership keeps every active agent.wait pending 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 session observer corrects a provisional failed digest with the authoritative same-run result, preserves monotonic digest revisions, and fences old run owners once another run starts on the same session. Existing bounded revision and supersession state is reused; no new tracker is introduced.
  • The embedded TUI distinguishes provisional diagnostics from final run state, preserves recovery across repeated attempt failures, immediately finalizes exhausted fallback failures, and takes the final visible reply only from the authoritative completed result.
  • The shared canonical lifecycle classifier also protects its existing cloud-worker terminal-projection sibling.

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:

  1. Repeated retryable errors no longer erase the session observer's ability to correct an already-published failed digest.
  2. Duplicate retryable TUI errors no longer consume the provisional terminal state needed for the final successful result.

Independent adversarial review additionally found and resolved three related owner-boundary defects before landing:

  • A later waiter must not observe a provisional failure from the canonical cache while an earlier waiter is still active.
  • A late completion from an older provisional run must not evict or overwrite a newer active session owner.
  • Lifecycle completion must not finalize stale or absent streamed text before the completed result supplies its authoritative reply; exhausted fallback failures must not wait another 15 seconds.
  • A prior aborted lifecycle end remains terminal-attempt evidence when a subsequent error replaces it, so existing waiters still settle at retry grace.
  • An existing adjacent Gateway integration test now selects its own settled run identity instead of racing a valid late event from the preceding test.
  • The new deferred-result regression explicitly models its initially undefined value, satisfying the exact strict Gateway test-type checker without weakening the assertion.

Evidence

Failing regressions were recorded on trusted main before the clean-room repair. Focused owner and sibling coverage now passes 254 tests:

OPENCLAW_VITEST_MAX_WORKERS=1 \
  OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-tui-issue-120606-vitest-cache \
  node scripts/run-vitest.mjs \
  src/agents/agent-run-terminal-outcome.test.ts \
  src/gateway/agent-turn/agent-job.timeout-fallback.test.ts \
  src/gateway/session-observer.terminal.test.ts \
  src/tui/embedded-backend.test.ts \
  src/gateway/worker-environments/live-events.test.ts

47 canonical outcome tests + 105 Gateway/observer/worker tests + 102 embedded TUI tests = 254 passed

Both hosted-CI integration failures also pass against the actual Gateway, including the two adjacent chat cases in their original source order:

OPENCLAW_VITEST_MAX_WORKERS=1 \
  OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-tui-issue-120606-vitest-cache \
  node scripts/run-vitest.mjs \
  src/gateway/server.chat.gateway-server-chat.test.ts \
  src/gateway/server-methods/server-methods.test.ts \
  --testNamePattern 'agent.wait ignores stale agent snapshots while same-runId chat.send is active|agent.wait ignores lifecycle completion while same-runId chat.send is active|lets a later lifecycle error replace a pending aborted timeout'

2 test files, 3 integration cases passed

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 TS2454 before the change and reported zero TS2454 diagnostics 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:

node scripts/run-oxlint.mjs --type-aware --tsconfig config/tsconfig/oxlint.core.json --threads=1 <nine changed files>
node_modules/.bin/oxfmt --check <nine changed files>
git diff --check

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:

node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --timing-json -- \
  CI=1 OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 OPENCLAW_VITEST_MAX_WORKERS=1 \
  node scripts/run-vitest.mjs src/tui/tui-pty-local.e2e.test.ts \
  --testNamePattern 'launches openclaw tui against a real Gateway through a real PTY'

provider=blacksmith-testbox
lease=tbx_01m0sya52jdk0y3jznf7c9vqcv
result=1 passed, 25 intentionally filtered
exitCode=0 runStatus=succeeded totalMs=99488
lease cleanup=stopped (completed)

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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Aug 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 24, 2026, 9:40 AM ET / 13:40 UTC.

ClawSweeper review

What this changes

The PR makes ordinary retryable lifecycle errors provisional across Gateway waiters, session observation, and the embedded TUI until an authoritative same-run outcome arrives.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep open: the new canonical classifier marks blocked and abandoned errors definitive, but Gateway agent.wait still schedules them as retryable and can accept a later same-run success.

Priority: P1
Reviewed head: 3cf9df6be2d04853e2b0ffb406a6d968cb70b7e6

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The reported late-success proof is strong, but the Gateway owner still permits a definitive error to be superseded.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies after-fix real-timer lifecycle output plus a Testbox run through a built Gateway, WebSocket-backed TUI, and real PTY; it does not, however, prove the remaining definitive-outcome case.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies after-fix real-timer lifecycle output plus a Testbox run through a built Gateway, WebSocket-backed TUI, and real PTY; it does not, however, prove the remaining definitive-outcome case.
Evidence reviewed 6 items Canonical classification changed: The PR classifies every error other than ordinary failed as definitive, including blocked and abandoned states.
Gateway bypasses that classification: Gateway still schedules every non-exhausted lifecycle error through retry grace, without consulting the canonical definitive classifier.
Late success can replace blocked or abandoned: The terminal merge protects cancellation and hard timeout, but otherwise returns the incoming outcome; a normal end received during grace therefore replaces a blocked or abandoned error.
Findings 1 actionable finding [P1] Apply definitive classification to Gateway waiters
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/agent-turn/agent-job.timeout-fallback.test.ts --testNamePattern 'blocked|abandoned'

Result: PASS (completed)

node scripts/run-vitest.mjs src/gateway/agent-turn/agent-job.timeout-fallback.test.ts --testNamePattern 'blocked|abandoned'
runner@runnervm76f27:/tmp/clawsweeper-live-proof-120606-9MUsHB/target$ node scripts/run-vitest.mjs src/gateway/agent-turn/agent-job.timeout-fallback.test.ts --t
estNamePattern 'blocked|abandoned'
node scripts/run-vitest.mjs src/gateway/agent-turn/agent-job.timeout-fallback.test.ts --testNamePattern 'blocked|abandoned'
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-120606-9MUsHB/target

 ✓  gateway-core  ../../src/gateway/agent-turn/agent-job.timeout-fallback.test.ts (30 tests | 28 skipped) 92ms

 Test Files  1 passed (1)
      Tests  2 passed | 28 skipped (30)
   Start at  13:41:03
   Duration  2.22s (transform 1.53s, setup 1.01s, import 751ms, tests 92ms, environment 0ms)

[test] passed 1 Vitest shard in 8.58s



































Assertions:

  • PASS expect_output: passed

How this fits together

Agent 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]
Loading

Before merge

  • Apply definitive classification to Gateway waiters (P1) - isDefinitiveRunLifecycle now treats blocked and abandoned errors as final, but agent-job.ts still sends every non-exhausted error into retry grace. A successful same-run end during that grace wins the merge, so agent.wait can return ok after a blocked or abandoned run. Use the classifier in Gateway scheduling and add both late-success regressions.
  • Resolve merge risk (P1) - Merging now leaves blocked or abandoned lifecycle errors able to become successful Gateway wait results when a later same-run end arrives during retry grace.
  • Complete next step (P2) - A narrow mechanical repair can make Gateway use the shared definitive-outcome policy and add the missing ordering regressions.

Findings

  • [P1] Apply definitive classification to Gateway waiters — src/agents/agent-run-terminal-outcome.ts:636
Agent review details

Security

None.

PR surface

Source 0, Tests +320. Total +320 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 103 103 0
Tests 5 321 1 +320
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 424 104 +320

Review metrics

Metric Value Why it matters
Production vs test LOC production +103/-103 (net 0); tests +321/-1 (net +320) The owner-level rewrite is production-neutral, but the current test growth does not cover the remaining Gateway fail-closed ordering.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/session-observer.terminal.test.ts, serialized state: src/gateway/session-observer.ts, unknown-data-model-change: src/gateway/session-observer.terminal.test.ts, unknown-data-model-change: src/gateway/session-observer.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120561
Summary: This PR is the candidate repair for the canonical same-run late-success lifecycle issue, but it still leaves a definitive-outcome sibling case unresolved.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Unify Gateway terminal classification (recommended)
    Use the canonical definitive-lifecycle decision before Gateway schedules a pending error, and prove blocked and abandoned outcomes cannot be replaced by a late same-run completion.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Route Gateway pending-error scheduling through the canonical definitive classifier and add blocked/abandoned late-success regressions.

Technical review

Best 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:

  • [P1] Apply definitive classification to Gateway waiters — src/agents/agent-run-terminal-outcome.ts:636
    isDefinitiveRunLifecycle now treats blocked and abandoned errors as final, but agent-job.ts still sends every non-exhausted error into retry grace. A successful same-run end during that grace wins the merge, so agent.wait can return ok after a blocked or abandoned run. Use the classifier in Gateway scheduling and add both late-success regressions.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fb576e3518df.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies after-fix real-timer lifecycle output plus a Testbox run through a built Gateway, WebSocket-backed TUI, and real PTY; it does not, however, prove the remaining definitive-outcome case.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: A definitive blocked or abandoned run can be reported as successful to active Gateway waiters.
  • merge-risk: 🚨 session-state: The PR changes terminal-state retention and supersession across Gateway waiters, observer state, and the embedded TUI.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies after-fix real-timer lifecycle output plus a Testbox run through a built Gateway, WebSocket-backed TUI, and real PTY; it does not, however, prove the remaining definitive-outcome case.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix real-timer lifecycle output plus a Testbox run through a built Gateway, WebSocket-backed TUI, and real PTY; it does not, however, prove the remaining definitive-outcome case.

Evidence

Acceptance criteria:

  • [P2] node scripts/run-vitest.mjs src/gateway/agent-turn/agent-job.timeout-fallback.test.ts.
  • [P1] node scripts/run-vitest.mjs src/agents/agent-run-terminal-outcome.test.ts.
  • [P1] node scripts/run-vitest.mjs src/gateway/session-observer.terminal.test.ts src/tui/embedded-backend.test.ts.

What I checked:

Likely related people:

  • steipete: Authored the current head that changes the canonical terminal classifier and the Gateway, observer, and TUI projections. (role: current lifecycle-repair author; confidence: high; commits: 3cf9df6be2d0, 80c4e3b8384a, 5f654b436e9e; files: src/agents/agent-run-terminal-outcome.ts, src/gateway/agent-turn/agent-job.ts, src/gateway/session-observer.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Route Gateway pending-error scheduling through isDefinitiveRunLifecycle.
  • Add blocked and abandoned error-then-success-before-grace regressions for agent.wait.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-10T12:57:38.388Z sha 83282f643fa791fe82065c1ca5b4e619c060db4d :: needs changes before merge. :: [P1] Exclude fail-closed outcomes from active-waiter retention
  • reviewed 2026-08-10T15:49:36.241Z sha 36d93ac763a16165435a65199de64c0a9fc874ed :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T05:36:26.136Z sha 36d93ac763a16165435a65199de64c0a9fc874ed :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T02:00:09.501Z sha 39c3c997820402976294f7f29526da286b81db21 :: needs changes before merge. :: [P1] Keep timed-out error lifecycles fail-closed
  • reviewed 2026-08-21T02:58:49.773Z sha de01d8b50ffa0bf2acabe291bfdbe3c5718140ac :: needs real behavior proof before merge. :: [P2] Unify late-success terminal handling across projections
  • reviewed 2026-08-21T05:37:28.742Z sha 60cd7d5f2a6aac7acd2bcbd1e7404d74d6e51c1a :: needs changes before merge. :: [P2] Preserve definitive TUI failures after a provisional error
  • reviewed 2026-08-21T14:02:08.521Z sha 674008b :: needs changes before merge. :: [P2] Retain observer recovery through repeated retryable errors | [P2] Keep the TUI provisional flag on duplicate retryable errors
  • reviewed 2026-08-24T13:20:31.292Z sha 80c4e3b :: needs maintainer review before merge. :: none

@RileyJJY
RileyJJY force-pushed the sunlit/fix/issue-120561 branch from e7b6c86 to 83282f6 Compare August 10, 2026 11:10
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 10, 2026
@RileyJJY RileyJJY changed the title [Bug]: agent.wait can return error before the same run later ends successfully fix: agent.wait can return error before the same run later ends successfully Aug 10, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P2 Normal backlog priority with limited blast radius. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 10, 2026
@RileyJJY
RileyJJY force-pushed the sunlit/fix/issue-120561 branch from 689ae15 to 36d93ac Compare August 10, 2026 15:38
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper-recovery-stuck and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 10, 2026
@RileyJJY
RileyJJY force-pushed the sunlit/fix/issue-120561 branch from 36d93ac to 39c3c99 Compare August 21, 2026 01:53
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 21, 2026
@RileyJJY
RileyJJY force-pushed the sunlit/fix/issue-120561 branch from 60cd7d5 to 674008b Compare August 21, 2026 13:56
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]>
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 24, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

The current clean-room maintainer rewrite addresses both actionable findings and both rank-up moves from the earlier review:

  • Observer repeated-retry recovery: repeated provisional lifecycle errors preserve the existing bounded digest revision state, and a later authoritative same-run completion changes the observer health from failed to done without allowing an older run to replace a newer session owner.
  • TUI repeated-retry recovery: duplicate provisional errors retain the closed provisional/final run state, and only the completed result owner emits the final reply. Separate regressions cover repeated errors, stale streamed drafts, and an authoritative reply that was never streamed.

Additional adversarial coverage proves that a second agent.wait arriving after retry grace never reads a prematurely cached failure, multiple waiters keep independent deadlines, the last waiter preserves the final failed diagnostic, exhausted fallback failures fail immediately, blocked/abandoned outcomes remain definitive, and hard-timeout/cancellation ordering stays unchanged.

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 (tbx_01m0swp71h9ts8m0k79j55td0g, wrapper exitCode=0; the one-shot backing lease was intentionally stopped afterward).

Thanks @RileyJJY; fixes #120561.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 24, 2026
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]>
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

The current clean-room maintainer rewrite addresses both actionable findings and both rank-up moves from the earlier review:

  • Observer repeated-retry recovery: repeated provisional lifecycle errors preserve the existing bounded digest revision state, and a later authoritative same-run completion changes the observer health from failed to done without allowing an older run to replace a newer session owner.
  • TUI repeated-retry recovery: duplicate provisional errors retain the closed provisional/final run state, and only the completed result owner emits the final reply. Separate regressions cover repeated errors, stale streamed drafts, and an authoritative reply that was never streamed.

Additional adversarial coverage proves that a second agent.wait arriving after retry grace never reads a prematurely cached failure, multiple waiters keep independent deadlines, the last waiter preserves the final failed diagnostic, exhausted fallback failures fail immediately, blocked/abandoned outcomes remain definitive, and hard-timeout/cancellation ordering stays unchanged. Existing aborted lifecycle ends still finalize replacement errors at retry grace, and an existing Gateway integration-test event race is fenced by the exact settled run identity.

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 (tbx_01m0sya52jdk0y3jznf7c9vqcv, wrapper exitCode=0; the one-shot backing lease was intentionally stopped afterward).

Thanks @RileyJJY; fixes #120561.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 24, 2026
Retain canonical retry ownership across Gateway, observer, and terminal projections while keeping asynchronous regression-test state explicitly typed.

Co-authored-by: RileyJJY <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 24, 2026
@steipete
steipete merged commit b8d6e79 into openclaw:main Aug 24, 2026
262 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: agent.wait can return error before the same run later ends successfully

2 participants