Skip to content

fix: native Codex turns fail with "settlement is closed" when they finish after 6 minutes - #185180

Merged
steipete merged 7 commits into
openclaw:mainfrom
Stronggenetics:fix/watchdog-runtime-owned-release
Nov 5, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
Stronggenetics:fix/watchdog-runtime-owned-release

Conversation

@Stronggenetics

@Stronggenetics Stronggenetics commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Related: #185121

What Problem This Solves

Fixes: a native Codex turn finishing after more than six minutes without OpenClaw-visible progress can lose its completed answer when the reply watchdog immediately stops settlement.

User Impact

Long native turns can finish, deliver, and persist their answers. A run that stays stuck after native ownership ends still stops after the existing six-minute semantic window. Explicit execution deadlines, the two-minute native settlement deadline, and Stop remain in effect. Ordinary collectors retain their existing revocation and stalled-read behavior.

Why This Change Was Made

The native runtime owns liveness while its turn is active. Previously the watchdog resumed its old semantic clock when that ownership ended, retroactively charging the whole native wait as inactivity. Only the native-turn wait now advances the observed semantic horizon while it is live; release lets finalization use the existing window. The integrated version preserves current main's pending backend-assessment logic.

This is the existing semantic budget applied at the ownership handoff, not a new timeout setting. An unexplained native liveness loss can consequently take up to one additional window to be reclaimed; the bounded stalled-finalization regression covers that tradeoff. No independent timer or recovery registry is introduced.

Production delta: +18 lines (47 added, 29 removed). The native wait uses its existing registration directly; wait and execution type declarations move beside the existing state types to keep the controller within its size limit. The remaining growth distinguishes native handoff from ordinary runtime-owned waits and records the observed horizon. Tests add 32 net lines, allocated separately without changing the shared baseline; documentation adds five lines.

Evidence

Independent secretless Linux proof restored current-main production beneath the regression and reproduced the erroneous stop on the release tick. The repaired runtime passes all 123 tests across the watchdog, run-attachment, collector, and question-recovery suites (124.62 s runner; compilation dominates). AWS Crabbox runs run_d71e02e754f7b5010dc4d2e5d7d05b94 and run_8a05738a83bb2c52297496b41a51fa4f; no credentials were forwarded. The follow-up cleanup stores the returned wait-close callback directly, removing the redundant temporary and wrapper; it preserves native opt-in and keeps runs.ts at its inherited size. The wait-close type now explicitly describes a standalone callback; both cleanup follow-up reviews found no actionable P0–P2 finding. A secretless follow-up run passes 39 run-attachment and liveness tests (66.89 s runner), with the line-cap check red before this cleanup. The final type-only correction passes targeted oxlint, oxfmt, and the line-cap check in run_ab74d82905678b896b8a100f5580607f.

Exact-head CI 41989298534 completes with only the test-line check and aggregate gate failing. Job 127118138846 reports 6,484,063 lines / ceiling 6,484,042, a 21-line deficit. Its merge base is e4333415f4e68198ede8c6d9501dd8fe933a3bf9; this PR adds exactly 32 lines and 32 allocation credit, so that base has the same deficit (6,484,031 / 6,484,010). All other jobs pass, including the repaired source line-cap gate. The classifier compares an older passing main run 41981222775 and explicitly does not compare scope; no unrelated test deletion or baseline increase was made.

The contributor's live Gateway/native-turn proof is retained with attribution: a 390,001 ms synthetic workload completed after 422,336 ms of raw semantic quiet, returned agent.wait: ok, delivered the exact final marker, and persisted it in history. The installed variant's relevant source hashes matched the submitted files; its full repository head differed. This lane does not independently repeat that credentialed native-model run; its secretless proof exercises the owning watchdog and production run-attachment boundary.

The native contract was checked against Codex source at be2951ea34f0d295ed0becf97079f92fa5f6950e: codex-rs/app-server/src/thread_status.rs:156 clears active state on completion, and thread_state.rs:195 records terminal events. OpenClaw receives the terminal event before asynchronous projection, starts its separate settlement deadline, and releases native liveness.

Four independent diff-scoped reviews found no actionable P0–P2 defect across the integration and cleanup. ClawSweeper re-review 41989366175 reviewed final head 3f5ce3476a3afbc0892041e04953d9af7daa1a59, reports zero findings, and confirms that the previous line-cap finding is resolved. Final main integration is 43d09522a4bb9b9f19bc8d730077631654ae5168; the changed runtime and tests are unchanged by that integration.

Thanks @Stronggenetics for the fix, regression coverage, and live Gateway evidence.

…window

A native Codex turn holds a runtime_owned watchdog wait while it owns
liveness. When the turn completed after more than six minutes without
OpenClaw-visible semantic progress, the release made the protected
interval count as stalled on the next tick. The watchdog stopped the
finished run, and the lane failed with "session placement turn
settlement is closed".

The native turn's wait now opts in to starting a fresh semantic window
when it releases. A run that then makes no progress is still stopped
after that window. Other runtime_owned waits, such as the agents_wait
collector, keep losing protection immediately.
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves the semantic stall allowance when native Codex releases liveness so completed answers can finish settling.

Example: A native Codex turn completes after 422,336 ms without OpenClaw-visible semantic progress.

  • Before: The expired semantic clock can immediately stop settlement and discard the completed answer.
  • After: The supplied Gateway run returns agent.wait: ok, delivers its final marker, and persists the answer.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with relevant live proof, distinct recovery coverage, and no remaining actionable finding; CI still needs disposition of inherited budget debt.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The retained contributor Gateway/native-turn proof exercises completion after 422,336 ms of semantic quiet, followed by successful agent.wait, exact final delivery, and persisted history; installed-source equivalence is distinguished from repository-head identity, and reported red-before/green-after owner-boundary tests cover delayed recovery.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A native Codex task can finish successfully yet lose its answer when the watchdog counts its protected native wait as inactivity.
Reason: This restores the documented completion contract, and the feature owner's integration retains the explicitly documented bounded reclamation tradeoff.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR repairs a current native-completion defect, and the previous line-cap finding is resolved; the remaining inherited test-line budget failure needs CI disposition.

Priority: P1
Reviewed head: 3f5ce3476a3afbc0892041e04953d9af7daa1a59

Before merge

None.

Findings

None.

Agent review details

How this fits together

The embedded runner registers native liveness with the session controller, whose watchdog combines progress and deadlines to allow settlement or request recovery.

flowchart LR
  A[Gateway turn] --> B[Session controller]
  B --> C[Embedded runner]
  C --> D[Native Codex]
  C --> E[Watchdog]
  D --> F[Terminal receipt]
  F --> G[Answer settlement]
  E --> G
Loading

Technical review

Best possible solution:

Land the native-specific handoff repair through the existing watchdog after resolving the inherited test-line gate.

Do we have a high-confidence way to reproduce the issue?

Current-main registration, terminal-receipt handling, and watchdog policy establish the false-stall transition; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch restores the documented native-completion contract with one native-specific distinction, preserves other wait policies, and resolves the previous finding without another module or increased allowance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e4333415f4e6.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +18, Tests +32, Docs +5, Other +2. Total +57 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 47 29 +18
Tests 2 33 1 +32
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 7 87 30 +57

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test growth Production +18 lines; tests +32 lines Growth records the native semantic horizon within the existing owner and covers bounded handoff recovery; test growth has an exactly matching allocation.

Root-cause cluster

Relationship: canonical
Canonical: #185180
Summary: This PR owns the native-completion handoff repair described in the author's closed report.

Members:

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

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Long native Codex turns can lose completed answers during settlement, breaking reported recurring jobs.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-26T23:56:17.148Z sha 5374b18 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-27T00:38:54.009Z sha 5374b18 :: blocked before merge. :: none
  • reviewed 2026-11-05T07:23:31.689Z sha a0a1765 :: needs changes before merge. :: [P2] Keep the runner within its inherited line allowance

Reviewed November 5, 2026, 2:51 AM ET / 07:51 UTC (Revision 4).

@Stronggenetics

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now includes a successful real Gateway/native Codex after-fix run: 422,336 ms (7m02.336s) without semantic progress before the native completed receipt, followed by successful settlement, exact local final delivery, and persisted history. It includes raw-clock methodology, exact-head/source equivalence, and redacted receipts. Reviewed head remains 5374b18239630999118aa5b7d8a9c849d9a67a5c; the live installed variant is explicitly distinguished.

The session-controller maintainer's decision on the full six-minute grace after native liveness ends, including unexplained liveness loss, is still requested. The successful live run does not replace that decision.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 28, 2026
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Nov 5, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 5, 2026
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@steipete
steipete merged commit 4d2081f into openclaw:main Nov 5, 2026
126 checks passed
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…nish after 6 minutes (openclaw#185180)

Advance the semantic horizon while the native runtime owns liveness so a completed native turn can settle instead of being stopped immediately. Preserve ordinary collector behavior, explicit deadlines and bounded stalled finalization.

The release-tick stop reproduces on base. Secretless proof passes 123 watchdog/liveness/question/collector tests and 39 follow-up attachment tests; lint, format and source line cap pass.

Related: openclaw#185121

Co-authored-by: Stronggenetics <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Release adaptation: retain the existing watchdog and native admission owners; carry only the runtime-owned release horizon and focused regressions. Current-authority checks, execution deadlines and bounded finalization remain unchanged. Scoped self-review found no additional owner or policy changes.

Proof: standalone production-watchdog regression fails on the base (stop rather than observe) and passes with the fix, including bounded eventual stall. Focused Vitest qualification still pending; earlier attempts stopped in cold compilation. Targeted lint blocked by declaration input escaping this shared-dependency checkout, not by a source finding. No gate waiver claimed.

(cherry picked from commit 4d2081f)

Co-authored-by: Stronggenetics <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[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 clawtributors PR from a clawtributor docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants