Skip to content

fix(codex): prevent false stalls while app-server work progresses - #145121

Draft
metahacker wants to merge 2 commits into
openclaw:mainfrom
metahacker:fix/codex-channel-progress-liveness
Draft

metahacker wants to merge 2 commits into
openclaw:mainfrom
metahacker:fix/codex-channel-progress-liveness

Conversation

@metahacker

@metahacker metahacker commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #145120

What Problem This Solves

Healthy native Codex channel turns can receive a false “stopped making progress” interruption while the app-server continues producing activity. The original revision wired progress to the captured reply operation. A later recurrence exposed the separate diagnostic watchdog clock: that clock can remain stale while the reply clock advances.

The original real long-turn proof below remains valid for reply-owner freshness and final delivery, but did not cover the failing diagnostic embedded_run path. This revision explicitly tests that path rather than treating survival of a tool-heavy turn as universal acceptance.

Why This Change Was Made

Keep the original captured-reply callback and bind progress to the exact admitted backend handle at the existing host execution-binding seam. A synchronous host callback now updates diagnostic progress when that same owner is active and the diagnostic phase is an ownerless embedded_run. It is independent of the optional, queued, best-effort run.progress telemetry channel.

  • Capture the handle once; never adopt a replacement based on matching session/run strings.
  • Preserve existing admission, lifecycle generation, tool-authority fingerprint, and reply-operation/backend/route checks.
  • Revalidate after runtime status probes and diagnostic snapshot reads before updating either clock.
  • Reject late progress from stopped, aborted, replaced, closed, or returned attempts.
  • Do not use native transport traffic to renew a core model/tool phase or semantic argument-churn/repeated-request clock.
  • No new SDK exports, diagnostic owner, configuration, timeout change, persistent state, or permission grant.

The current-owner registry read validates the captured handle; it does not look up a successor to attribute delayed activity to. Tool authority itself is unchanged; its existing registration/active assertions bind this host-owned progress callback.

User Impact

Advancing native work refreshes both relevant liveness clocks. Runtime-owned waits retain their existing protection. Genuinely idle work remains recoverable, and stale callbacks cannot keep a successor or stuck tool alive.

Evidence — September 14 follow-up

Current upstream base: 6d586170048982bd6c5ebc3cdc08bbd003f47a1d. The original three-file patch reapplied unchanged (git range-diff reports =); the new bridge adds one production module change and a dedicated regression file.

  • Twelve new regression cases compose actual run admission, backend registration, reply operation, diagnostic heartbeat and stuck-session recovery. The watchdog runs enabled at accelerated test thresholds: active callbacks survive multiple recovery windows; a quiet runtime-owned wait survives; once that wait ends, actual recovery aborts and settles the idle run.
  • Negative coverage includes same-string replacement, admission closure, lifecycle rotation, stopped/returned callbacks, reentrant runtime probes, replaced reply operation/backend/route, and a tool phase whose clock must not be renewed by notification traffic.
  • Release-based focused proof: 206 unique tests passed across the new regression, existing authority, diagnostic, actual recovery, and run lifecycle suites. Final fixture typing/formatting and deterministic timer corrections are included in the submitted test.
  • Exact live-source baseline before/after: the final 12-case regression fails 11 / passes 1 without the bridge, then passes 12 / 12 with it. Current-main proof also passes the original callback test, 33 existing authority tests and the final 12-case regression (46 distinct cases; an earlier real-clock fixture race was corrected with deterministic test clocks).
  • Full current-main node scripts/check-changed.mjs --base 6d586170048982bd6c5ebc3cdc08bbd003f47a1d completed with exit 0, including core types, all core-test type graphs, formatting/lint, dead-code scans, import cycles and repository policy guards. Release-based targeted types/lint also pass; the release broad gate stops at its pre-existing fs-safe 0.8.5 patch allowlist guard, unchanged by this patch.
  • The isolated combined 9.4 deployment candidate completed its full build successfully in 5m24s, preserving the current production companion repair. All 28 combined diagnostic/cancellation-scope/registered-bridge tests passed. The candidate remains separate from production; activation and fresh real-channel acceptance are not yet claimed.
  • The prescribed autoreview helper was attempted with the configured model, but returned reviewer_unavailable/engine_failed because its model cache lacked base_instructions; it produced no verdict. A final independent native reviewer subsequently completed the full five-file source scope and affected registration, admission, reply, diagnostic, recovery, and native-notification contracts: scoped-clean for introduced P0–P2 findings. The reviewer verified actual watchdog enablement, exact handle capture and revalidation, core semantic-phase exclusion, and runtime-owned wait preservation. The earlier transport-blocked scope is now completed. This does not recast the failed helper attempt as a successful helper review. The original accepted patch remains unchanged; its range-diff and source composition were verified.

Causal limits and current readiness

The two-clock dependency and synchronous repair are demonstrated. The precise reason production telemetry failed to advance the clock in the reported recurrence is still unproven. An earlier local theory that exact-owner rejection caused those missed events was withdrawn: the local native handle did not have that diagnostic owner. Do not infer that every interruption has this cause.

This PR remains draft pending maintainer/security-owner review and fresh real-channel activation acceptance of the combined change. Historical 660-second native evidence validates the original callback, not the new diagnostic bridge. No production rollout, broad CI success, or universal stall-fix claim is made.

Historical original-patch native long-turn evidence — September 11

The acceptance used the actual source-runtime Gateway, the real QA channel plugin, native Codex execution, and supporting assets built from exact head 3b3b97e16535d28549d69bde0614faf40ff11cbf. The delivery surface was an isolated synthetic QA channel, not Slack, so no real user or workspace data was involved. This is a source-runtime proof with exact-built assets, not a packaged-install claim.

The harness transparently wrapped the captured reply owner's existing recordActivity method with a call-through observer that preserved its receiver and arguments. A clock advance was credited to this proof only when its immediate production caller was onRunProgress in the embedded candidate. Generic diagnostics and other owner writes were excluded, so survival alone was not treated as proof.

Redacted independent readback:

source_head = build_commit = 3b3b97e16535d28549d69bde0614faf40ff11cbf
native_work_elapsed_ms = 660000
native_work_progress_beats = 132
single_stable_reply_owner = true
causal_onRunProgress_calls = 483
causal_clock_advances = 477
causal_progress_span_ms = 669434
causal_advances_after_600000_ms = 70
fresh_native_progress_events_after_600000_ms = 70
max_causal_progress_gap_ms = 5001
max_running_owner_age_ms = 4408
owner_age_after_600000_ms = 6
recovery_events = 0
originating_thread_final_delivered = true
owner_completed = true
owner_cleared = true
isolated_process_and_ports_closed = true

The ordinary recovery diagnostics and thresholds remained enabled and unchanged: 120-second warning, six-minute active-abort threshold, ten-minute quiet takeover, and the normal 15-minute long-tool floor. The trace recorded repeated causally attributed activity beyond ten minutes, normal completion, exact-thread final delivery, and clean owner/process/port cleanup. No recovery interruption or owner replacement occurred.

This is positive after-fix evidence, not a claim that the previous revision would necessarily be aborted by this exact synthetic workload. No private runtime log, fixture path, credential, endpoint, model identifier, or user data is included.

@clawsweeper

clawsweeper Bot commented Sep 11, 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 channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser app: android App: android app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: copilot-proxy Extension: copilot-proxy extensions: diagnostics-otel Extension: diagnostics-otel extensions: llm-task Extension: llm-task extensions: lobster Extension: lobster extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb cli CLI command changes scripts Repository scripts labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Connects native Codex progress to the originating reply clock and an owner-checked diagnostic watchdog callback.

Example: A native Codex channel turn continues producing activity beyond six minutes.

  • Before: The reply or diagnostic clock can remain stale and trigger a false interruption.
  • After: Progress refreshes the captured active owner's clocks while genuinely idle work remains recoverable.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused patch has meaningful ownership and recovery coverage with no concrete introduced finding, but proof covers only part of the submitted behavior.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Healthy native Codex channel turns can be interrupted as stalled while work continues.
Reason: The repair addresses a concrete reported release failure without adding configuration, public API, or timeout policy.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR contains meaningful work for the still-open paired bug, and the merged watchdog fixes address different failure modes.

Priority: P1
Reviewed head: e14b584fa15fb8ea74ba7327fbb7e4cc809ba960

Before merge

  • Add real behavior proof - The historical native Gateway/QA-channel trace demonstrates the original reply callback and final delivery; the added diagnostic bridge has synthetic-handle watchdog coverage only, and its native acceptance remains explicitly pending. Add redacted terminal output or logs showing native notifications refresh that diagnostic clock and genuine inactivity still recovers; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Await maintainer action - Obtain approval from @openclaw/openclaw-secops for the final tool-authority.runtime.ts change under the enforced code-owner rule.

Findings

None.

Tests

  • Missing end-to-end proof: Provide native progress evidence through the added diagnostic bridge showing watchdog freshness during work and recovery after genuine inactivity.
Agent review details

How this fits together

Codex app-server notifications enter OpenClaw's embedded harness, which associates progress with the admitted backend and updates reply and diagnostic activity used by recovery.

flowchart LR
  A[Codex app server] --> B[Native progress callback]
  B --> C[Captured backend owner checks]
  C --> D[Reply activity clock]
  C --> E[Diagnostic activity clock]
  D --> F[Stall recovery]
  E --> F
Loading

Technical review

Best possible solution:

Preserve exact-owner progress attribution through the current session-controller watchdog while retaining idle recovery and Stop behavior.

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

Source confirms the missing channel progress callback and the supplied regression targets that boundary; no runtime reproduction was executed, and current main's redesigned watchdog complicates reproducing the exact interruption.

Is this the best way to solve the issue?

The submitted repair reuses existing activity owners and captures the exact backend rather than adopting a successor, but its integration must account for current main's controller-owned watchdog.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Harness execution authority keeps the original intent (e3ce08c: The existing host seam binds prepared policy to admitted execution and exact registered handles; the patch preserves those checks while binding progress.)
  • Channel embedded-candidate callbacks keeps the original intent (fix(auto-reply): deliver embedded fallback replies after CLI failures #121897: Existing preparation binds delivery to the actual embedded fallback; adding reply-owned activity preserves that delivery ownership.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e3ce08c adds src/agents/harness/tool-authority.runtime.ts:82 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e3ce08cd5ec1; files: src/agents/harness/tool-authority.runtime.ts)
  • joshavant: Raw commit 3cb3f1e adds src/auto-reply/reply/agent-runner-embedded-candidate.ts:380 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3cb3f1e4268a; files: src/auto-reply/reply/agent-runner-embedded-candidate.ts)

PR surface

Source +76, Tests +401. Total +477 across 5 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 2 78 2 +76
Tests 3 401 0 +401
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 479 2 +477

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.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #145120
Summary: This PR is the paired repair candidate; the merged native-ownership and settlement fixes are adjacent work.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: False stall recovery interrupts useful native channel turns and can prevent their answers from reaching users.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Resolve the reported conflicts by reconciling the bridge with current main's controller-owned watchdog rather than restoring the retired ownership arrangement.

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 (8 earlier review cycles)
  • reviewed 2026-09-11T18:07:01.402Z sha 38a196fd7b512b7586421ef5bc6df3b084dae9e4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-11T18:25:51.299Z sha 3b3b97e16535d28549d69bde0614faf40ff11cbf :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-11T21:31:29.251Z sha 3b3b97e16535d28549d69bde0614faf40ff11cbf :: needs changes before merge. :: none
  • reviewed 2026-09-14T18:53:10.733Z sha e14b584 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-14T19:06:08.140Z sha e14b584 :: needs real behavior proof before merge. :: none
  • reviewed September 23, 2026, 4:19 PM ET / 20:19 UTC (Revision 6) sha unknown :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T20:19:58.644Z sha e14b584 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-05T08:46:19.617Z sha e14b584 :: needs real behavior proof before merge. :: none

Reviewed November 11, 2026, 5:45 AM ET / 10:45 UTC (Revision 9).

@metahacker

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Thank you for the precise direction. I’ve added the requested redacted real after-fix long-turn evidence to the existing PR body, including causal owner-clock attribution beyond the recovery windows, normal completion, exact-thread delivery, and cleanup. The PR remains draft pending your review.

@clawsweeper

clawsweeper Bot commented Sep 11, 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:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant