Skip to content

fix(codex): stop interrupting active turns during quiet native work - #134755

Merged
steipete merged 5 commits into
mainfrom
steipete/stalled-chat-debugging-038aff
Sep 2, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/stalled-chat-debugging-038aff

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #99272 — quiet native turns interrupted by competing idle watchdogs and no elapsed execution budget (reported by @obviyus).

Fixes #122233 — unconditional lane heartbeats hide elapsed execution time (reported by @ernestrolfson-design).

Additional instructions

This is an upstream, maintainer-editable branch. No deployment or production-session resumption is included.

What Problem This Solves

Fixes an issue where users running multi-step Codex tasks would receive an incomplete-turn error while native Codex was still working. Tool-argument generation can keep the native provider connection active without producing the app-server events OpenClaw's idle watchdogs expect. A successful tool result followed by a child-agent message could also replace the five-minute continuation allowance with the one-minute completion watch and interrupt the parent prematurely.

The affected workflow is ordinary Codex-backed chat, including the Control UI. Increasing the idle windows does not repair the ownership mismatch, and generic stuck-session/queue recovery could independently interrupt the same legitimate quiet wait.

Why This Change Was Made

Make native completion authoritative instead of predicting it from projected output. Codex owns native inference/transport continuation; OpenClaw owns its configured elapsed execution budget, cancellation, host requests/tools, result projection, and resource settlement.

  • Replace four inference-based watches with one elapsed execution deadline and one absolute two-minute settlement deadline. Progress resets neither; configured zero remains unlimited. Keep the five-second projection-drain grace after separately bounded native abort cleanup.
  • Hand shared recovery, steering, reply admission, and command-queue timeout ownership to the exact current live attempt. Recheck registration/lifecycle authority; do not introduce provider-name exemptions, fake heartbeats, or a second registry. Other runtimes retain their existing policy unless they explicitly participate.
  • Cover the complete post-terminal notification/checkpoint tail with settlement. Fence late projection and preserve healthy sibling leases on a shared app-server.
  • Delete apparent-answer-to-success salvage and obsolete completion/blocker bookkeeping. Preserve partial text/media alongside explicit, non-replayable timeout failure; do not automatically repeat potentially effectful work.
  • Remove the three shipped idle-timeout settings through the Codex Doctor contract, including malformed values, without translating idle durations into execution limits. No replacement setting, dependency, or storage/schema change.

A bounded adjacent fix normalizes synchronous process-inspector spawn failures through the existing actionable error type. The isolated macOS proof exposed this path; two failing-before regressions cover it without weakening process-identity validation.

Current runtime production LOC: +1177/-2334, net -1157. Tests/support and test tooling: +3645/-4289, net -644. Separately: plugin schema -30; docs/generated -24; ratchet -1. Total net -1856 across 131 files. Most deletions remove prediction-only watches/bookkeeping and tests of those retired paths; replacement tests protect the canonical ownership boundaries.

Built-in and shared ownership follow-up

The built-in OpenClaw harness now has one bounded/paused/unlimited/closed execution-deadline owner. Scoped approvals pause remaining execution time; one compaction grace remains; user questions do not pause the whole budget. Configured zero arms no execution timer. Provider liveness and cancellation/settlement bounds remain independent.

Attempts and tool-free finalizers receive fresh closure-bound queue controls. Old callbacks cannot renew or abort a successor, real queue expiry aborts execution, and the synthetic 15-second lane heartbeat is removed. Cold acquisition retains its existing pre-attempt budget boundary. Diagnostic recovery captures activity identity/generation before a stateful question-expiry probe and keeps that observation through logging reentry.

A live-discovered terminal projection defect is repaired at its producer: a final timeout now records the existing canonical error, and command/channel settlement preserves its actionable explanation and failure status. Earlier tool errors cannot replace the timeout message or reopen replay after the final timeout branch. Explicit public-safe/deferred guidance and successful-delivery early returns retain precedence.

Test-only landing corrections await asynchronous admission fixtures, use normal prebuilt Doctor plugin resolution, remove redundant forwarding helpers, and load execution modules during collection before cases own one-shot mock state. Current main already owns the improved stdin fixture type; that earlier carried fix is no longer part of this diff.

User Impact

Long-running native work no longer fails solely because OpenClaw sees a quiet interval. Finite Codex execution budgets now enforce actual elapsed time, even while progress is arriving. Explicit unlimited execution accepts an indefinitely active native turn until Stop or a real terminal failure; it does not disable bounded host settlement or request/tool deadlines.

If processing the result genuinely fails, the user retains available output and receives an explicit incomplete-turn error rather than silent success. A confirmed interruption preserves usable native context for a later explicit user turn. The obsolete turnCompletionIdleTimeoutMs, turnAssistantCompletionIdleTimeoutMs, and postToolRawAssistantCompletionIdleTimeoutMs keys are removed by Doctor; unrelated configuration is preserved.

Explicit Stop now reads the authoritative lane cancellation after user-message persistence, rather than depending on a callback that may correctly be fenced after revocation. The session remains cancelled/killed, usable partial output stays visible, and completed compaction facts survive. Shared direct-abort classification prevents a live caller signal from turning that deliberate cancellation into a generic failure.

Local documentation is updated for the Codex harness, its reference, and the agent loop.

Evidence

Landing-candidate verification

Published head: 7bd12290e95eae418607649d190f1d70c1aba357, based on inspected main 1cf0c31f305e5775405c73fe8fcf30955736fda5. Native review also inspected 8a8bf9cbfe6cd7ae930302fc14af698a044f1ae1; later overlap is limited to an independent browser assertion-ratchet shrink and additive agent.wait documentation, not runtime changes. Main integration preserves full authenticated compaction-hook context, ordinary/incognito policy ownership, and warm-session fixtures. The superseded narrow hook-context helper was deleted. The final refresh only regenerated the config digest and preserved adjacent startup tests; its range-diff changes no runtime repair logic.

Latest semantic-integration proof passed 537 tests across 10 files, runtime/SDK/Control UI build, focused lint and fresh two-chunk Codex P0 review. Final mechanical-refresh proof passed all 11 startup-process tests, including retired-key migration in 10.252s with the original bound, plus generated-digest and lint checks. Earlier repair/rebase proof passed 277 tests/16 files with 30 changed checks and 599 tests/12 files from cold cache. Full build and earlier 1,632-case ownership proof remain documented in the maintainer proof comment. Counts from overlapping runs are not added as unique tests.

Fresh real isolated Gateway/Control UI proof on the semantic-integration head 5d0c14fe93670f7bac8608ab42353e82266ad398 exercised explicit unlimited execution through 70,095ms, actual UI Stop, provider disconnect in 54ms, persisted killed/abortedLastRun:true/no active run, visible partial text, and a successful next user turn. The final mechanical refresh leaves the deadline/Stop implementation unchanged. All screenshots and video inspection frames were reviewed for behavior and sensitive content; owned servers are stopped. Zero page errors; one synthetic workspace-icon404. This uses deterministic local Responses data, not paid upstream inference. Earlier finite-budget proof observed 45,035ms despite five-second progress frames and showed full actionable timeout details. Original native-binary before/after proof is retained below with its historical provenance.

Maintainer decision — retired settings: this maintainer-authored simplification deliberately retires turnCompletionIdleTimeoutMs, turnAssistantCompletionIdleTimeoutMs, and postToolRawAssistantCompletionIdleTimeoutMs, with Doctor removing their values. Native Codex owns liveness; the existing agents.defaults.timeoutSeconds owns the elapsed limit. Old idle durations are not equivalent elapsed budgets and are not translated. This is the intended contract of the requested repair and landing, not an accidental compatibility loss or a request for new configuration.

Startup migration removes only those three keys while preserving custom command, URL, synthetic headers, other settings and timeoutSeconds:0; it releases the lease and is byte-idempotent. Current process tests also verify main's advisory-warning startup behavior. No runtime compatibility reader was added. This records the migration decision requested by the latest ClawSweeper review.

A test-only cold-import race was repaired without raising timeouts or weakening assertions: a timed-out row could resume after the next row reset its shared one-shot mock. Collection-time module initialization now precedes per-case ownership, preserving original restart-to-direct-Stop order. Interrupted/stale-dependency runs are not counted as passing. Fresh Codex reviews are P0-only, not all-priority certification.

The preceding exact-head CI exposed one further stale test fixture: a confirmed-stop resume used an unleased mock despite main's managed-process preflight. Local reproduction timed out in 120 seconds; observing the rejected run exposed the exact preflight error in 982ms. The final test-only commit uses the existing real managed-client/JSONL fixture, explicitly confirms native interruption, and preserves the no-replay and successful-next-turn assertions. The test passes in 2.4 seconds in its original full-file order; 399 tests across four lifecycle/resume files, all 19 canonical changed checks, and a fresh scoped Codex review pass. No production guard, timeout or assertion was weakened. Exact-head CI completed successfully, including required openclaw/ci-gate job 100108821838. The rollup watcher initially stopped on a cancelled auxiliary ClawSweeper dispatch; the actual CI workflow and enforced gate were independently verified green. The latest ClawSweeper review covers this exact head, reports no actionable finding, accepts the migration decision and rates readiness/proof/quality 5/6. Native prepare/merge is the remaining step.

Known boundaries: sidebar-only presentation work is independently owned and is not attributed to this PR. The distinct reported 26-second output-loss race in this issue is not closed merely because it mentions timeouts. No deployment, production Gateway restart, original-chat resumption, or release is included.

Real native before/after comparison

Two isolated development Gateways used the managed Codex CLI 0.151.0, real native Code Mode execution, ordinary dashboard owner authentication, and a deterministic local Responses provider. Each had separate state/HOME/workspace, synthetic credentials, a private port, and an OS-enforced loopback-only network boundary. No production state was copied or changed. This is real native-binary and UI proof, not paid live inference against OpenAI and not a fake app-server.

The provider observed the first real native tool output, then streamed the second tool's input in 65 valid deltas over 320 seconds. Only the second native tool output unlocked the final answer.

Variant Observed outcome
Baseline 8d9282414c6d943d814ac552d194458c38a9ceab OpenClaw interrupted at approximately 300 seconds while valid native input frames were still arriving; 60/65 deltas, no second tool output, visible incomplete-turn error.
Candidate Stayed active beyond the former cutoff, consumed all 65 deltas, completed both native steps, delivered the final answer, then answered a subsequent explicit user turn.

Before — premature interruption:

Before: active native work is interrupted and the chat shows an incomplete-turn error

After — native completion and a subsequent user turn:

After: both native steps complete and the next explicit user message receives a reply

The attached videos are the last 35 seconds of the corresponding real recordings, with a three-second hold on the real final frame for readability. The first video is before-native-cutoff.mp4; the second is after-native-completion.mp4. Screenshots and video contact sheets were inspected for the asserted behavior and incidental sensitive content. All proof services are stopped.

Earlier native publication proof

The native recording, build, full changed-check plan, and broad focused test batches below cover the pre-rebase repair snapshot (65e4aefccbd). The original publication rebased that repair onto d155fe40557a575ffee516918b1d60752cf1a04d; git range-diff confirms only upstream context changes and the union of a type-only queue import. The recording is not represented as a new run against the rebased head.

Publish-time checks: all additional post-rebase regressions pass: 348 tests across 10 files in four shards (44 process/queue, 19 embedded-agent, 22 embedded-run, 263 Codex/Doctor). The runner automatically retried the embedded-agent shard once after a no-output timeout; its retry passed. Core and plugin production types and the resolved import lint/format checks also pass. The earlier native-only head CI workflow completed successfully for be6bf339f4f2f5e4186a45dad947f5aef5c8c965. This completes the previously pending local proof.

  • The exact ordered successful-tool-output → child agent_message regression failed against the original code with an unexpected turn/interrupt at 60,001 ms, then passed unchanged through the actual JSONL client transport after repair.
  • Two additional settlement regressions failed before correction: a blocked same-turn projection queued after native completion, and a blocked SQLite transcript checkpoint. They now time out under the settlement owner while retaining partial output and keeping a healthy sibling client usable.
  • Focused native lifecycle, terminal-tool/yield, cancellation, permission replacement, queued-media drain, shared-client, Doctor, queue/admission/recovery, terminal-output, and built-in/Copilot sibling batches pass. Real payload-builder tests cover partial/completed-looking text and message-tool delivery on execution and settlement timeout.
  • pnpm build passes; no missing export or ineffective dynamic-import warning remains.
  • All 37 commands selected by the canonical node scripts/check-changed.mjs planner pass, executed in four non-overlapping groups: 26 preparation/type/format/owner gates, full core lint, full plugin lint, and nine script/architecture guards. Final command coverage was compared against the current plan; runtime import cycles: zero. git diff --check passes.
  • Independent Codex autoreview is clean at its P0-only scope. This is not an all-priority audit or a claim that the full repository test suite ran.
Focused regression entry points and native contract evidence

The committed regression entry points include:

  • extensions/codex/src/app-server/run-attempt.turn-watches.test.ts
  • extensions/codex/src/app-server/attempt-deadlines.test.ts
  • extensions/codex/src/app-server/run-attempt.settlement.test.ts
  • extensions/codex/src/app-server/run-attempt-thread-cleanup.test.ts
  • extensions/codex/doctor-contract-api.test.ts
  • src/agents/embedded-agent-runner/runs.liveness.test.ts
  • src/agents/embedded-agent-runner/run.terminal-timeout.test.ts
  • src/process/command-queue.deadline.test.ts

Direct sibling Codex source inspection was pinned to 86b1123ff6b5d089a146be4e603a324cf454223a:

  • codex-rs/codex-api/src/endpoint/responses_websocket.rs:676–799: transport idle handling wraps each incoming frame before parsing/filtering.
  • codex-rs/core/src/session/turn.rs:2372–2448 and codex-rs/core/src/stream_events_utils.rs:392–438: native custom-tool generation need not emit the typed item-start events the removed watches depended on.
  • codex-rs/app-server/src/bespoke_event_handling.rs:187–202: native completion settles pending thread requests before publishing completion.

That source snapshot is contract evidence, not an assertion of exact source provenance for the managed 0.151.0 binary. The live comparison covers a native post-tool visibility gap; the exact original child-message sequence is covered separately by the real-JSONL regression. The original introducing commit was not established; the baseline reproduction is not an attribution claim.

The force-release/same-thread-successor composition is supported by exact route-claim ordering and existing stale-release/pending-unsubscribe/sibling tests, but there is no single combined 30-second forced-release → delayed old cleanup → same-thread successor regression.

attachment-519534265.mp4
attachment-3035846354.mp4

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts agents Agent runtime and tooling extensions: codex size: XL maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete
steipete marked this pull request as ready for review September 1, 2026 03:48
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 11:14 PM ET / September 2, 2026, 03:14 UTC.

ClawSweeper review

What this changes

The PR replaces Codex app-server output-inference timeout watches with attempt-owned execution and settlement deadlines, and removes obsolete Codex timeout settings through Doctor.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No concrete introduced defect was found. Keep this protected maintainer PR open for the intentional retirement of three existing Codex timeout settings, which remains a compatibility decision despite the tested Doctor migration.

Priority: P1
Reviewed head: 7bd12290e95eae418607649d190f1d70c1aba357
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The repair has coherent lifecycle ownership and strong supplied regression and visible-flow evidence, with a deliberate compatibility choice remaining.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (recording): Focused lifecycle regressions and supplied exact-head Gateway/Control UI recording evidence exercise the changed owner boundary; the reviewer did not rerun those artifacts.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (recording): Focused lifecycle regressions and supplied exact-head Gateway/Control UI recording evidence exercise the changed owner boundary; the reviewer did not rerun those artifacts.
Evidence reviewed 8 items Current-main behavior: Current main still used output-inference idle watches that abort an attempt with a turn-specific idle-timeout reason; the PR replaces that approach rather than duplicating an existing main repair.
Attempt deadline owner: The introduced deadline owner derives an attempt-scoped execution deadline, replaces it with a bounded settlement deadline on terminal receipt, and disposes it at closure.
Core authority fencing: Deadline and cancellation callbacks require the current active owner, lifecycle generation, live authority, and un-aborted signal before they can affect a lane.
Findings None None.
Security None None.

How this fits together

The bundled Codex plugin turns native app-server events into OpenClaw embedded-agent lifecycle and session results. Native Codex owns stream liveness and terminal completion; OpenClaw owns the bounded attempt and settlement budgets it hands to the generic execution lane.

flowchart LR
  A[User turn] --> B[Codex app-server]
  B --> C[Native events and completion]
  C --> D[Attempt lifecycle owner]
  D --> E[Embedded-agent lane]
  E --> F[Session result]
  G[Doctor migration] --> D
Loading

Decision needed

Question Recommendation
Should OpenClaw retire the three Codex-specific timeout settings through the supplied Doctor migration? Retire with Doctor migration: Remove the obsolete independent controls and migrate profiles to the canonical shared timeout policy.

Why: This changes the upgrade contract for existing operator configuration and requires maintainer compatibility intent beyond the code-level correctness review.

Before merge

  • Resolve merge risk (P2) - Three existing Codex-specific timeout settings are removed rather than translated, so upgrading operators rely on the documented and tested Doctor migration.
  • Complete next step (P2) - This is an open protected maintainer PR with no identified contributor repair; compatibility intent for the retired settings is the remaining review action.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test delta production +1177/-2334 (net -1157); tests/support +3645/-4289 (net -644) The broad lifecycle repair is net-negative in both production and test-support code.
Retired configuration 3 removed, 0 added The PR consolidates existing Codex timeout controls and makes the upgrade effect reviewable.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/codex/doctor-contract-api.ts, unknown-data-model-change: extensions/codex/doctor-contract-api.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Retire settings with migration (recommended)
    Merge with the tested Doctor migration and documentation so existing profiles lose obsolete settings predictably.
  2. Pause configuration retirement
    Keep the existing settings until a different compatibility policy is explicitly chosen.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Retain the Doctor migration, updated timeout documentation, and exact-head lifecycle proof.

Technical review

Best possible solution:

Retain the explicit Doctor cleanup, aligned timeout documentation, and exact-head lifecycle evidence when maintainers approve the configuration retirement.

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

Yes, from source: current main still has the output-inference abort path and the PR contains focused ordering regressions; this review did not execute the harness.

Is this the best way to solve the issue?

Yes. Native terminal completion plus one attempt-owned elapsed budget removes competing inference watches while core receives only a generic deadline handoff.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The repair targets interrupted or lost Codex agent turns during active tool-assisted work.
  • merge-risk: 🚨 compatibility: Merging removes three existing Codex timeout configuration keys, with Doctor owning the upgrade cleanup.
  • 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. Sufficient (recording): Focused lifecycle regressions and supplied exact-head Gateway/Control UI recording evidence exercise the changed owner boundary; the reviewer did not rerun those artifacts.
  • proof: sufficient: Contributor real behavior proof is sufficient. Focused lifecycle regressions and supplied exact-head Gateway/Control UI recording evidence exercise the changed owner boundary; the reviewer did not rerun those artifacts.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. Focused lifecycle regressions and supplied exact-head Gateway/Control UI recording evidence exercise the changed owner boundary; the reviewer did not rerun those artifacts.

Evidence

Acceptance criteria:

  • [P1] Review the exact-head Doctor migration and lifecycle regression evidence.
  • [P2] Confirm compatibility intent for removing the three Codex timeout settings.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (6 earlier review cycles)
  • reviewed 2026-09-01T09:12:26.112Z sha be6bf33 :: found issues before merge. :: [P1] Reject retired timeout settings before strict parsing
  • reviewed 2026-09-01T19:28:43.098Z sha 48b900d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T01:32:14.539Z sha 096587001a02c13b77d55e02dac0ee80d9b1f340 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T02:12:03.675Z sha 5d0c14fe93670f7bac8608ab42353e82266ad398 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T02:24:43.803Z sha 19679f0 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T03:02:27.651Z sha 7bd1229 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/stalled-chat-debugging-038aff branch from be6bf33 to 48b900d Compare September 1, 2026 18:56
steipete added a commit that referenced this pull request Sep 1, 2026
Give built-in attempts and tool-free finalizers fresh closure-bound deadline
and cancellation controls. Preserve approval pauses and compaction grace,
honor unlimited execution without a sentinel timer, and remove synthetic
lane progress heartbeats. Capture diagnostic generation before question
expiry so stale observations cannot abort resumed or replacement work.

Record final timeout explanations at the terminal owner and carry them
through command and channel settlement without replacing them with earlier
tool errors or reporting success. This complements the native Codex
lifecycle repair in #134755 and addresses the blind heartbeat in #122233.

Prove retired Codex settings migrate at startup while retaining connection
settings and the execution budget. Carry the upstream stdin test-type fix
01129d7 and use canonical fixture exports
instead of redundant forwarding functions.

Validation: 1,632 owner/sibling tests across 52 files; 237 native fixture
cases rerun after cleanup; all 38 canonical changed-check commands; full
runtime, SDK declaration and Control UI build; fresh P0 Codex autoreview.
Live isolated Gateway/UI: 45,035ms execution timeout despite provider
progress, actionable error details, and a successful subsequent user turn.
No deployment, production-session resumption, or release.
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations labels Sep 1, 2026
@steipete steipete self-assigned this Sep 1, 2026
@steipete

steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Current landing candidate and maintainer decision

Published head: 7bd12290e95eae418607649d190f1d70c1aba357. Exact-head CI completed successfully, including enforced openclaw/ci-gate job 100108821838. The latest ClawSweeper review covers this exact head, finds no actionable issue, accepts the recorded retirement decision, and rates readiness/proof/quality 5/6. Ready for native prepare/merge; this is not yet a merge-complete claim. The first rollup watcher stopped on a cancelled auxiliary ClawSweeper dispatch, not failing tests; the actual CI workflow and required check were separately verified green.

Maintainer decision: deliberately retire turnCompletionIdleTimeoutMs, turnAssistantCompletionIdleTimeoutMs, and postToolRawAssistantCompletionIdleTimeoutMs through Doctor. This is the intended contract of this maintainer-authored simplification and requested landing: native Codex owns liveness, and existing agents.defaults.timeoutSeconds owns the elapsed execution limit. The independent idle thresholds are not preserved or translated into misleading elapsed budgets. Actual startup proof removes only those three keys, preserves custom command/URL/headers and unlimited execution, releases the lease, and verifies byte-idempotence. This addresses the retirement-decision Rank-up move in the latest ClawSweeper review; exact-head green CI remains the other gate.

Last CI correction is test-only. The preceding run had one timed-out confirmed-stop resume test and 410 passing tests in that shard. The fixture still used a naked mock for a resume path that now requires a managed native process. It failed before the first turn/start, but the method wait hid the rejected run. Local proof reproduced the 120-second timeout, then exposed the exact preflight rejection in 982ms without changing the fixture. Using the existing real managed-client/JSONL fixture, explicitly delivering the matching interrupted terminal, and closing the first physical client before constructing the second repairs the test. No production ownership guard, timeout, assertion, or no-replay requirement was weakened.

The corrected case passes in 2.4 seconds in its original full-file order. All 399 tests across four lifecycle/resume/cleanup files, all 19 canonical changed checks, and fresh isolated Codex P0-only autoreview pass. The last commit changes no runtime code. Main integration retained full authenticated compaction context and ordinary/incognito policy ownership, and deleted the superseded narrow context helper. The latest inspected main 8a8bf9cbfe6cd7ae930302fc14af698a044f1ae1 overlaps only independent browser ratchet shrink and additive agent.wait docs; no further runtime conflict was found.

Refreshed real Stop-flow recording: on the semantic-integration head 5d0c14fe93670f7bac8608ab42353e82266ad398, the built-in runtime stayed active for 70,095ms; actual UI Stop disconnected the deterministic provider in 54ms. Normal sessions.list reported killed, abortedLastRun:true, and no active run. Partial text remained visible, and a subsequent user turn completed. This is a real isolated Gateway/Control UI with synthetic state and local Responses data, not paid upstream inference. All six screenshots, the full-duration video storyboard and final frame were inspected. Zero page errors; one synthetic workspace-icon404. Both owned servers are stopped. Final metadata/test-only commits leave this runtime implementation unchanged. The appended video is this refreshed recording; earlier before/after media and provenance remain preserved below.

Runtime production +1177/-2334 (net -1157); tests/support including test tooling +3645/-4289 (net -644); schema -30, docs/generated -24, ratchet -1. Total -1856 lines across 131 files. Earlier gross counts classified test configuration/E2E tooling differently; production net is unchanged by the final fixture correction.

Exact latest validation commands

node scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt.turn-watches.test.ts extensions/codex/src/app-server/attempt-client-cleanup.test.ts extensions/codex/src/app-server/thread-lifecycle.binding.test.ts extensions/codex/src/app-server/run-attempt.test.ts
node scripts/check-changed.mjs -- extensions/codex/src/app-server/run-attempt.turn-watches.test.ts
node scripts/run-vitest.mjs src/commands/doctor-config-preflight.process.test.ts
pnpm build:ci-artifacts

The latest four-file run took 255.54s. The startup refresh passed all 11 process cases, including retired-key migration in 10.252s under the unchanged bound. Earlier semantic-integration proof passed 537 tests/10 files and the runtime/SDK/Control UI build. Earlier full build, finite-budget proof and native-binary before/after evidence remain below and in the PR body. Counts overlap and are not summed as unique tests. Native recordings predate rebases, with explicit provenance; no fresh paid inference or single all-composed forced-release/delayed-cleanup/successor test is claimed. No release, production Gateway operation or original-chat resumption is included.

Earlier published proof and media (preserved with original provenance)

Published CI repair and fresh Stop proof

The repaired candidate is now published as 096587001a02c13b77d55e02dac0ee80d9b1f340. Its production code is identical to the freshly built and live-tested e20a4ee879ee0228f00ae36067297fb414c0413e; the last commit changes test initialization only.

The four failed shards in run 33546630367 had three stale fixtures and one real Stop regression. Two fixtures still provided retired dispatch controls; the acquisition fixture asserted original signal identity instead of composed cancellation behavior. Those now exercise the real lane/admission controls and verify parent cancellation, queue expiry, original abort reasons, and callback cleanup.

The Stop failure was an ownership error: Gateway cancellation revokes authority and aborts the parent signal before the retained callback runs. Correctly fenced callbacks therefore cannot set a second cancellation flag. Normalization now reads the authoritative lane signal after persistence, preserves completed compaction facts, and deletes the duplicate flag. Shared direct-abort classification also preserves cancellation when the caller signal remains live, replacing a command-only special case. Retained callback fencing and internal-interruption warnings are unchanged.

Fresh live result: real isolated Gateway, built-in OpenClaw runtime and Control UI, synthetic credentials, and a deterministic local Responses provider. The run remained active for 70,375ms with fifteen progress frames. Actual UI Stop disconnected the provider in 97ms. Normal sessions.list RPC then reported status:"killed", abortedLastRun:true, and hasActiveRun:false; partial text stayed visible and the subsequent user turn completed. The earlier before-capture reported failed/false. The status comparison is RPC evidence, not a label visibly rendered in the screenshots. All six screenshots, the full-duration video storyboard and the final full-resolution frame were inspected; no real user data, credentials or private model identifiers were present. Both owned servers are stopped. Zero page errors; the one console error was an HTTP404 for the synthetic workspace-icon endpoint.

Validation: 277 owner/sibling tests across 16 files and all 30 incremental changed checks passed before the mechanical rebase. Final rebase verification passed 599 tests across 12 files from a fresh module cache, including real Gateway Stop, restart/direct cancellation ordering, skill/admission integration, queue liveness, and Codex side-question/thread/attempt/settlement paths. The full build, declarations, public SDK export check and Control UI build passed with lockfile-matched dependencies. Regenerated config digest and resolved-file lint also passed. Full-branch Codex P0 autoreview passed in two chunks; the final test-only change passed a separate scoped P0 review. These are P0-scope reviews, not all-priority certification.

A cold-import test failure was fixed without weakening assertions or deadlines: the first cancellation row installed a shared one-shot mock before importing the execution graph. Vitest can time out the row without terminating its async function, allowing it to consume the next row's mock. Loading the graph during collection now precedes per-case ownership; restart and direct Stop then passed in their original order. Earlier interrupted/stale-dependency runs are not counted as passing proof. The rebase required aligning @openclaw/fs-safe from the previously installed 0.5.6 to main's locked 0.7.0; source and lockfile stayed unchanged. The fresh local build was unusually slow but completed successfully in 1h08m43.8s.

Size: production +1,197/−2,356 (−1,159); tests/support +3,631/−4,290 (−659); manifest/schema −30; docs/generated −24; ratchet −1. Rebase preserved main's skill snapshot preparation and better stdin test type. Config generation removes exactly the three retired plugin keys, with no new option or schema change.

The latest ClawSweeper Rank-up move is exact-head CI. This update repairs its observed failures; green CI on the newly published head remains required before merge. The startup migration regression and previous native/finite-budget proof below remain part of the evidence. No release, production restart or original-chat resumption is included.

Exact final validation commands
pnpm build
OPENCLAW_VITEST_MAX_WORKERS=4 OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=.artifacts/pr-134755-proof/collection-test-module-cache node scripts/run-vitest.mjs src/gateway/server.chat-first-turn-binding.test.ts src/agents/embedded-agent-runner/run/attempt-normalization.test.ts src/agents/embedded-agent-runner/run/run-attempt-dispatch.owner.test.ts src/agents/embedded-agent-runner/run/run-attempt-dispatch.media.test.ts src/agents/embedded-agent-runner/sandbox-skills.test.ts src/agents/embedded-agent-runner/run/lane-controller.queue-liveness.test.ts src/auto-reply/reply/reply-turn-admission.test.ts src/auto-reply/reply/agent-runner-execution-lifecycle.test.ts extensions/codex/src/app-server/side-question.test.ts extensions/codex/src/app-server/thread-lifecycle.test.ts extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/run-attempt.settlement.test.ts
node --import ./scripts/tsx.mjs scripts/generate-config-doc-baseline.ts --check
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/embedded-agent-runner/run/run-attempt-dispatch.ts src/cli/models-cli.auth-login.integration.test.ts
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/auto-reply/reply/agent-runner-execution-lifecycle.test.ts
git diff --check d9af9d694b40559e7c7c50e11ac4c833009ed0e7

The live recorder used the normal dist-backed CLI for owner handoff and sessions.list, against task-owned state and ports 19480/19485. Provider responses were deterministic; this is not a paid OpenAI inference claim.

Earlier timeout and startup-migration proof (preserved)

Built-in/shared follow-up and fresh live proof

The repair now also covers the built-in OpenClaw harness: one execution-deadline owner, fresh closure-bound controls for attempts and tool-free finalizers, queue cancellation that actually aborts execution, and removal of the unconditional 15-second progress heartbeat. Diagnostic recovery captures the observed generation before expiring a pending question, so it cannot abort resumed or replacement work using a freshly borrowed generation.

The final-timeout producer records its existing canonical error. Command and channel settlement preserve that explanation and classify the run as failed instead of losing the message or allowing an earlier tool error to replace it. No new setting, timeout knob, dependency, or database/protocol change.

Fresh rebased live proof: an isolated real Gateway and Control UI, built-in runtime, synthetic SQLite credentials, and a local Responses provider emitting genuine bookkeeping frames every five seconds. With a 20-second provider idle limit and 45-second execution budget, lifecycle start→error was 45,035ms; the provider emitted nine progress frames, the complete actionable timeout explanation was visible, and the next user turn completed. This is real Gateway/UI proof with deterministic inference, not a live OpenAI inference claim. Zero page errors and one console error were recorded. The full recording and all screenshots were inspected for behavior and sensitive content; the two owned servers are stopped.

Attachments show the earlier before state (generic “Chat error”), the rebased after state (full timeout explanation), the successful next turn, and the complete fresh recording. The sidebar's generic “Unknown error” summary remains a separately owned follow-up and is not claimed fixed here.

ClawSweeper finding / Rank-up move

The requested retired-key-plus-valid-siblings startup regression now passes through the actual automatic startup Doctor path in 16.58 seconds, with the original 60-second bound. It verifies initial rejection of all three retired keys; automatic repair despite migrateLegacyConfig:false; preserved custom command, URL, synthetic headers and other valid settings; unchanged timeoutSeconds:0; persisted and runtime configuration; released migration lease; and byte-identical second-pass persistence.

The initial test forced source/Jiti plugin loading and timed out during Doctor module resolution. Removing that test override lets the normal resolver use the test wrapper's fresh built plugin artifacts; no timeout, assertion, or production behavior was weakened.

The finding's normal-upgrade premise does not hold: foreground/service startup requires a migration checkpoint; doctor-config-preflight.ts plans automatic repair and commits the existing plugin-aware Doctor migration under its lease before rereading configuration. Other invalid-config entry paths reject before registration. A private parser returning an empty object for a raw invalid input is not a supported-path reproduction. The migration remains in Doctor rather than adding a redundant runtime compatibility reader.

The original native-binary before/after recordings remain explicitly pre-rebase evidence. The managed Codex version is unchanged, and native rebase resolutions were fixtures and generated metadata, not a new native timeout policy. The complete final candidate passed fresh independent Codex autoreview at its P0-only scope.

The follow-up is published in 48b900df86a4e8f43521591bffb2bde1969ea5d9. Local validation covers 1,632 owner/sibling cases across 52 files, a further 237 native fixture cases after cleanup, and all 38 canonical changed-check commands. Exact-head CI remains the required next gate before merge.

The requested follow-up review was completed on September 1; its remaining Rank-up move is exact-head CI.

Before: a final built-in timeout loses its explanation

After: the complete actionable timeout explanation

A subsequent user turn completes

attachment-1022633767.webm

New Stop-flow media

Appended in order: earlier before recording, repaired after recording, preserved partial after Stop, and successful next user turn. Persisted status is established by the RPC comparison above, not a visible status label in the images.

attachment-1518113392.webm
attachment-2328822044.webm

After Stop: the partial reply remains visible

The subsequent user turn completes

Refreshed Stop-flow video

attachment-4065726882.webm

@clawsweeper

clawsweeper Bot commented Sep 1, 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.

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 1, 2026
steipete added a commit that referenced this pull request Sep 2, 2026
Settle definitive lifecycle errors through the canonical terminal classifier without provider retry grace. Cancel an older error timer before finalization so it cannot replace a subsequent successful run's status.

Preserve retryable provider errors and normal read-dismiss behavior. Add real SQLite/session-event regression coverage for the missing timeout reason and stale-timer ordering. Related: #134755.
steipete added a commit that referenced this pull request Sep 2, 2026
Use the shared isolated test-state owner so ordered timeout and exhaustion regressions close SQLite resources before deleting their fixtures. Restore genuinely buffered terminal coverage and compare the flushed delta's actual delivery order.

Document prompt sidebar timeout reasons and normal read dismissal. The production sidebar repair remains net-neutral and separate from the parent lifecycle work.

Related: #135466, #134755
@steipete
steipete force-pushed the steipete/stalled-chat-debugging-038aff branch from 48b900d to 0965870 Compare September 2, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant