Skip to content

fix(agents): CLI-backed agents stop replying when a long turn trips stuck-session recovery - #137372

Closed
anandnsharma wants to merge 7 commits into
openclaw:mainfrom
anandnsharma:fix/cli-backend-stream-liveness-watchdog
Closed

anandnsharma wants to merge 7 commits into
openclaw:mainfrom
anandnsharma:fix/cli-backend-stream-liveness-watchdog

Conversation

@anandnsharma

@anandnsharma anandnsharma commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #137263

What Problem This Solves

Fixes an issue where operators running a claude-cli-backed agent would see the
agent silently stop replying in a chat channel when a single turn ran longer than
about six minutes. The turn completes and its answer lands in the session
transcript, but no message is ever delivered to the channel. The only trace is a
WARN line — visible channel turn dispatched with no queued reply payloads ... cause=skipped:reply_operation_aborted — so from the chat surface the agent just
looks broken, which pushes operators toward resetting the session and throwing
away good history to "fix" a problem that was never in the session.

Reported from a live incident on 2026.8.2: a WhatsApp group agent hit this twice
in ~34 minutes on turns of 406s and 486s.

Why This Change Was Made

The stuck-session watchdog was making a kill decision from facts the CLI backend
never published, and then that kill overruled a turn that had already finished.

Three producer-side gaps, all fixed at the owner:

  1. Stream liveness was never published. classifySessionAttention aborts a
    model_call once lastProgressAgeMs >= 360s. The core runtime refreshes that
    clock per streamed chunk (model_call:stream_progress); the CLI backend
    counted stdout bytes for its own no-output watchdog but never published them
    as run progress, so the clock only advanced at tool boundaries. That is the
    lastProgress=tool:Agent:ended lastProgressAge=383s signature in the incident
    logs: a turn that is actively streaming looks frozen. The duplicated core
    implementation and the missing CLI one are now a single shared reporter, wired
    at consumeStdout so it covers every CLI backend, not just claude-cli.

  2. The backend's own deadline was preempted. For model calls the effective
    abort is max(360s, activeModelCallRequestTimeoutMs). Direct providers publish
    their request timeout there; the CLI backend published nothing, so a hardcoded
    360s overruled the no-output allowance the operator had already configured
    (~390-480s in the incident, which is why the CLI's own watchdog never fired).
    That resolved deadline now rides model.call.started as requestTimeoutMs and
    bounds the generic floor, matching the direct provider path.

  3. Recovery ignored the existing completion-wins seam. freezeAbort() marks a
    turn whose terminal outcome is committed and only delivery/finalization remains;
    supersede() honors it, but the stale-expiry path did not, so recovery could
    abort a turn that had already produced its reply. Recovery now reports
    keep_lane / terminal_outcome_committed and leaves that owner bounded by the
    existing finalization lease and terminal-settle timer.

Non-goal: no new configuration surface. The linked report asked for a tunable
stall threshold. This change instead makes the knobs that already exist
authoritative for this path — raise agents.defaults.timeoutSeconds (or the
backend's reliability.watchdog settings) and the stuck-session watchdog follows
it. The retired diagnostics.stuckSessionAbortMs key stays retired.

Scope boundary. This is the CLI-backend liveness path. #137263 reports the same
outward symptom on the direct provider path, where model_call:stream_progress is
already firing and the model call is instead never marked complete — a different
root cause that this PR does not claim to fix.

User Impact

CLI-backed agents no longer go silent on long-but-healthy turns. A turn that keeps
streaming output is no longer treated as stalled, a backend that declares its own
liveness deadline owns recovery timing inside that deadline, and a turn that has
already produced its answer is not killed while the reply is being delivered.
Operators who need a longer allowance raise the existing agent/backend timeout
instead of hitting an undocumented 360s constant, and a retained turn is now
visible as a distinct keep_lane / terminal_outcome_committed recovery outcome
rather than an indistinguishable abort.

Production diff is +160/-70 (net +90), which buys one canonical stream-progress
reporter replacing two divergent implementations, liveness publication for every
CLI backend, backend-deadline publication, and the recovery guard.

Evidence

Four regression tests, each confirmed to fail on pre-fix code (stashed the
corresponding production file, reran, observed the failure):

Test Covers
src/agents/cli-runner/execute.supervisor-capture.test.ts — "publishes streamed stdout as run progress so a live turn is not reclaimed" streamed stdout reaches the freshness clock
src/logging/diagnostic-run-activity.test.ts — "surfaces a non-core backend request timeout in the activity snapshot" backend deadline reaches activeModelCallRequestTimeoutMs
src/logging/diagnostic.test.ts — "defers stale model call recovery to a longer backend-declared deadline" generic floor no longer preempts the backend deadline
src/logging/diagnostic-stuck-session-recovery.runtime — "keeps the lane once the turn committed its terminal outcome" recovery does not abort a finalizing turn

Plus reply-run-registry.test.ts — "reports a committed terminal outcome only
while delivery is still finalizing" — pinning the new predicate to the
freezeAbort() → complete() window.

Real behavior proof: the bug reproduced and fixed on a live gateway

Isolated gateway profile (own state dir, own port, never the operator's gateway), real claude-cli backend, same prompt both sides. The only difference is src/agents/cli-runner/execute-process.ts at the merge base versus this branch.

Before — the reported failure, reproduced on demand. A real 380s streaming turn is classified stalled and killed:

age=141s reason=active_model_call_without_progress classification=long_running
  activeWorkKind=model_call lastProgress=model_call:started lastProgressAge=140s recovery=none
age=291s reason=active_model_call_without_progress classification=long_running
  activeWorkKind=model_call lastProgress=model_call:started lastProgressAge=290s recovery=none
age=381s reason=active_work_without_progress classification=stalled_agent_run
  activeWorkKind=model_call lastProgress=model_call:started lastProgressAge=381s recovery=checking
stuck session recovery: age=381s action=abort_embedded_run aborted=true drained=true released=0
stuck session recovery outcome: status=aborted action=abort_embedded_run activeWorkKind=embedded_run
cli turn: provider=claude-cli model=claude-sonnet-5 durationMs=380599 outBytes=<70K>

The client received status: "timeout", summary: "aborted", stopReason: "aborted" — 380 seconds of real streamed output, killed at the 360s floor. lastProgressAge tracks the whole turn because nothing on the CLI path refreshes it.

After — the same workload crosses the same threshold and is left alone. Runs of 312s, 339s and 365s, the last past the 360s abort floor, all completing and delivering:

age=140s reason=active_work classification=long_running
  activeWorkKind=model_call lastProgress=model_call:stream_progress lastProgressAge=0s recovery=none
age=290s reason=active_work classification=long_running
  activeWorkKind=model_call lastProgress=model_call:stream_progress lastProgressAge=0s recovery=none
cli turn: provider=claude-cli model=claude-sonnet-5 durationMs=365775 outBytes=<83K>

Zero recovery=checking, zero stuck session recovery, zero abort_embedded_run across every after-fix run.

Note on log cadence: long-running attention warnings back off to max(last + 120s, last * 2), so after the 290s line the next would land at 578s, longer than these turns. The absence of any recovery line is the load-bearing evidence and is not subject to that backoff: recovery arming is evaluated on every 30s tick and logs unconditionally, as the before-run shows at 381s.

Why recovery cannot arm after the fix: the abort predicate keys off lastProgressAgeMs, not session age. Streaming pins that near zero, so total turn length stops being the trigger.

Local validation:

node scripts/check-changed.mjs                      # exit 0
pnpm build                                          # exit 0, 0 INEFFECTIVE_DYNAMIC_IMPORT
node scripts/run-vitest.mjs src/logging src/auto-reply/reply \
  src/agents/cli-runner src/agents/embedded-agent-runner
#   -> 599 files, 10875 tests passed, 1 skipped
node scripts/run-vitest.mjs src/channels/turn src/infra/diagnostic-events.test.ts \
  extensions/diagnostics-otel                       # passed
autoreview --mode uncommitted --engine claude       # scoped-clean, no findings

Known proof gaps, stated plainly:

  • No live channel delivery. The live proof above runs through a real
    gateway and a real CLI backend, but delivery is the local agent route rather
    than a chat channel; the >360s abort itself is not reproduced, only the
    progress signal that prevents it.
  • Pre-existing unrelated failure: extensions/codex/src/app-server aborts with
    "Worker exited unexpectedly". Confirmed to reproduce identically on clean
    origin/main with these changes stashed, so it is not introduced here.
  • A test-file split was required along the way: adding a case pushed
    diagnostic-stuck-session-recovery.runtime.test.ts past the 1000-line
    max-lines limit, so its mock preamble moved to a shared harness and its cases
    into two suites. No test bodies were changed by the move.

https://claude.ai/code/session_0122p4qSQzsjwFgYUCDNrwMK

@anandnsharma
anandnsharma marked this pull request as ready for review September 3, 2026 15:27
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@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. 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 Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 4, 2026, 7:17 AM ET / 11:17 UTC.

ClawSweeper review

What this changes

The branch shares stream-progress reporting between model backends, propagates CLI quiet allowances into stuck-session recovery, and preserves replies while their delivery finalizes.

Merge readiness

⛔ Blocked before merge - 6 items remain

Keep open: the prior P1 remains because the CLI quiet allowance is published only after first stdout, leaving a silent child eligible for the generic watchdog abort. The supplied real-gateway logs prove streamed liveness, but not post-recovery channel delivery for the new committed-outcome guard.

Priority: P1
Reviewed head: b6b00eccf2f484359a4c2b81cf21cb483ad1d751

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair has useful live liveness evidence, but the unresolved P1 pre-output hole and incomplete delivery proof prevent merge readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The PR body contains real isolated-gateway logs showing streamed CLI output prevents the over-threshold abort, but it explicitly lacks channel delivery evidence and exercises the changed committed-reply recovery guard only with mocks. Add a redacted dispatcher/mock-gateway verdict or live delivery trace after recovery is attempted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body contains real isolated-gateway logs showing streamed CLI output prevents the over-threshold abort, but it explicitly lacks channel delivery evidence and exercises the changed committed-reply recovery guard only with mocks. Add a redacted dispatcher/mock-gateway verdict or live delivery trace after recovery is attempted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Deadline is coupled to first stdout: The branch constructs the backend liveness deadline but invokes its reporter only inside consumeStdout, so a silent child does not register its configured allowance.
Reporter is the sole deadline writer: The reporter records backendLivenessTimeoutMs only when called; it also refreshes progress, so initial allowance registration needs a separate non-progress path.
Recovery falls back before the allowance exists: Both stalled model-call and embedded-run recovery use the generic floor when no backend liveness deadline was recorded.
Findings 1 actionable finding [P1] Publish the CLI quiet deadline before first stdout
Security None None.

How this fits together

CLI-backed agent turns feed output and timeout facts into diagnostic activity; stuck-session recovery uses those facts to decide whether to abort active work. Completed replies then pass through finalization before channel delivery.

flowchart LR
  A[CLI process] --> B[Diagnostic activity]
  B --> C[Stuck-session watchdog]
  C --> D[Recovery decision]
  D --> E[Reply finalization]
  E --> F[Channel delivery]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body contains real isolated-gateway logs showing streamed CLI output prevents the over-threshold abort, but it explicitly lacks channel delivery evidence and exercises the changed committed-reply recovery guard only with mocks. Add a redacted dispatcher/mock-gateway verdict or live delivery trace after recovery is attempted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Publish the CLI quiet deadline before first stdout (P1) - This remains the prior finding: backendLivenessTimeoutMs is recorded only from consumeStdout. A child that remains silent within its configured no-output allowance therefore has no allowance in diagnostic activity and can be reclaimed at the generic floor. Register the deadline at process activation without falsely marking stream progress, then cover the silent-child case.
  • Resolve merge risk (P1) - A silent CLI child with a configured allowance longer than the generic watchdog floor can still be aborted early because the allowance is absent until stdout arrives.
  • Resolve merge risk (P1) - The committed-reply guard has mock-only boundary coverage; a delivery-path regression would still be invisible to the supplied proof.
  • Resolve merge risk (P1) - GitHub currently reports this PR as dirty, so it needs a rebase and exact-head validation after the repair.
  • Complete next step (P2) - Register the CLI quiet allowance before first stdout, add silent-child coverage, provide redacted post-recovery delivery proof, and rebase the repaired head.

Findings

  • [P1] Publish the CLI quiet deadline before first stdout — src/agents/cli-runner/execute-process.ts:153-167
Agent review details

Security

None.

PR surface

Source +99, Tests +308, Other 0. Total +407 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 12 148 49 +99
Tests 8 1408 1100 +308
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 21 1557 1150 +407

Review metrics

Metric Value Why it matters
Production versus test delta production +99 net; test/support +308 net, including a 1,100-line test split The shared reporter replaces duplicate direct-provider code, while the remaining production growth adds timeout state and recovery handling.

Merge-risk options

Maintainer options:

  1. Repair the pre-output watchdog gap (recommended)
    Publish the resolved quiet allowance before waiting for output, add a silent-child regression, rebase, and validate the exact repaired head.
  2. Pause for proof
    Keep the PR unmerged until a dispatcher/mock-gateway verdict or live trace demonstrates delivery after recovery sees a committed reply.

Technical review

Best possible solution:

Register the resolved CLI quiet allowance at process activation through a path that does not refresh stream progress, cover a silent child beyond the generic floor, and prove that recovery preserves and delivers a committed reply.

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

Yes: the source establishes that a configured allowance cannot exist before stdout, while watchdog recovery can run during that interval; the submitted gateway logs independently demonstrate the streaming portion.

Is this the best way to solve the issue?

No: shared stream reporting is appropriate, but timeout publication must be decoupled from first output so the configured allowance also protects a silent startup.

Full review comments:

  • [P1] Publish the CLI quiet deadline before first stdout — src/agents/cli-runner/execute-process.ts:153-167
    This remains the prior finding: backendLivenessTimeoutMs is recorded only from consumeStdout. A child that remains silent within its configured no-output allowance therefore has no allowance in diagnostic activity and can be reclaimed at the generic floor. Register the deadline at process activation without falsely marking stream progress, then cover the silent-child case.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The PR targets a silent-reply failure on long CLI-backed agent turns, and the remaining hole can still abort valid work.
  • merge-risk: 🚨 availability: The changed watchdog determines whether active agent work is aborted or retained.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body contains real isolated-gateway logs showing streamed CLI output prevents the over-threshold abort, but it explicitly lacks channel delivery evidence and exercises the changed committed-reply recovery guard only with mocks. Add a redacted dispatcher/mock-gateway verdict or live delivery trace after recovery is attempted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/agents/cli-runner/execute.supervisor-capture.test.ts src/logging/diagnostic.test.ts src/logging/diagnostic-run-activity.model-call-deadlines.test.ts.
  • [P1] node scripts/run-vitest.mjs src/logging/diagnostic-stuck-session-recovery.runtime.test.ts.
  • [P1] node scripts/check-changed.mjs -- src/agents/cli-runner/execute-process.ts src/logging/diagnostic-model-stream-progress.ts src/logging/diagnostic-run-activity.ts src/logging/diagnostic.ts.

What I checked:

Likely related people:

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

Rank-up moves

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

  • Register the quiet allowance before output and add a regression for a silent child whose allowance exceeds the generic watchdog floor.
  • Add redacted post-recovery dispatcher/mock-gateway or live channel-delivery proof, then update the PR body for automatic re-review.

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-09-03T16:49:44.893Z sha 65f3cd33525257cfa601c096e85da0c3058524a6 :: needs real behavior proof before merge. :: [P1] Publish deadlines for every CLI backend
  • reviewed 2026-09-04T03:54:43.844Z sha 9c3dac3831cd8effeff3705fd82c847ce762aaa6 :: needs real behavior proof before merge. :: [P2] Scope the CLI deadline to its active fallback candidate
  • reviewed 2026-09-04T04:45:03.332Z sha e8c27bee720202beb4840aca6ebe0b5bf47fee14 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T04:59:34.773Z sha b735d4648d9ddb5eb785209d4105532a30030f73 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T05:22:16.357Z sha f2579d68b0893b5303015f24eb293ec3f8f19054 :: needs real behavior proof before merge. :: [P1] Publish the CLI quiet deadline before first output
  • reviewed 2026-09-04T05:44:03.394Z sha fb8ef28540ac49c122725258f20e02762238ad75 :: needs real behavior proof before merge. :: [P1] Publish the CLI quiet deadline before first stdout | [P2] Re-enable the CLI diagnostic regressions
  • reviewed 2026-09-04T05:57:57.540Z sha 623d2655147f43562c87e0905916e387bc0b8b4d :: needs real behavior proof before merge. :: [P1] Publish the CLI quiet deadline before first stdout
  • reviewed 2026-09-04T10:57:33.953Z sha 3d3ee15 :: needs real behavior proof before merge. :: [P1] Publish the CLI quiet deadline before first stdout

@anandnsharma

anandnsharma commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks — the P1 caught a real defect in my test, and I've fixed that. I do want to push back on part of the conclusion, with evidence.

Where the finding is correct

The deadline test drove markDiagnosticModelStartedForTest, which calls recordModelStarted(params, undefined, true) — the coreRequestForTest argument that bypasses the active-owner gate an ordinary start hits. So it proved nothing about the production path. That was a bad test.

Fixed in 65f3cd33525: the case now emits the real trusted model.call.started and is verified by reverting diagnostic-run-activity.ts, diagnostic-run-activity-snapshot.ts, and diagnostic-events.ts to the merge base (fails there, passes with the change).

Where I read it differently

The added requestTimeoutMs never reaches the production snapshot for an embedded CLI turn.

The gate is !provenance && !coreRequestForTest && hasDiagnosticActivityOwner(activity), and hasDiagnosticActivityOwner is only true once an owner is registered via markDiagnosticEmbeddedRunStarted({ owner }) (diagnostic-run-activity.ts:502). That owner comes from handle.diagnosticOwner (runs.ts:1406), which is populated only on the direct-provider attempt path (attempt-stream-prepare.ts:547, owner created at attempt-execution-phase.ts:79) and the compaction path (compaction-session-execution.ts:331).

A CLI-backed turn does not run through that attempt path — it dispatches via src/auto-reply/reply/agent-runner-cli-dispatch.ts, which registers no diagnostic owner. So for the CLI turn this PR targets, the gate does not fire and the deadline is recorded.

Direct check — register an embedded run the way the CLI route does, emit the real ownerless start, read the snapshot:

activeWorkKind: "model_call"
activeModelCallRequestTimeoutMs: 480000

The originating incident agrees: its stalled session: lines report activeWorkKind=model_call, which is not reachable if the CLI start were being dropped — a dropped start leaves activeWorkKind=embedded_run.

The residual gap, now pinned

There is a narrower version of the concern, and I had not covered it either. When an owner-bound attempt (direct provider or compaction) holds the same session activity, an ownerless CLI deadline is suppressed and the generic floor still governs:

activeWorkKind: "embedded_run"
activeModelCallRequestTimeoutMs: undefined

65f3cd33525 adds that as an explicit test in diagnostic-run-activity.model-call-deadlines.test.ts so it is a recorded, reviewable gap rather than an unexamined assumption. Routing CLI lifecycle starts through the owner-bound provenance channel would close it, but CoreModelRequestLifecycleProvenance is documented as core-only authority, so that looks like a maintainer decision rather than something to fold into this fix. Happy to take direction either way.

Real behavior proof

Understood and in progress; I'll update the PR body when I have it.

Unrelated CI failure

checks-node-changed-extensions-config-48 is red on this PR, but it is not from this change: extensions/qa-lab/src/live-transports/slack/slack-live.runtime.test.ts times out at 120s on the same shard, same test, same line for the unrelated PR #137374 (fix/schtasks-launcher-redirect-argv) — run 33772995622, job 100708031775. I reconstructed that shard's 78 files locally and all 1509 tests pass on macOS, so it looks Linux-runner specific and I could not reproduce it to root-cause. Flagging rather than masking it with a timeout bump.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 3, 2026
@anandnsharma
anandnsharma force-pushed the fix/cli-backend-stream-liveness-watchdog branch from 9c3dac3 to e8c27be Compare September 4, 2026 04:39
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 4, 2026
A CLI-backed agent turn that ran longer than ~6 minutes could be killed by
stuck-session recovery while it was still streaming, and its completed reply
was then never delivered to the channel.

Three producer-side gaps, all in how liveness facts reach the watchdog:

- The CLI backend counted stdout bytes for its own no-output watchdog but
  never published them as diagnostic run progress, so the freshness clock only
  advanced at tool boundaries. The core runtime already publishes per-chunk
  stream progress; the two implementations are now one shared reporter, and
  every CLI backend publishes through it.
- The CLI backend never published its resolved no-output deadline, so the
  generic 360s model-call floor preempted a backend allowance the operator had
  already configured. That deadline now rides `model.call.started` as
  `requestTimeoutMs` and bounds the generic floor, matching the direct
  provider path.
- Stale-expiry recovery ignored the `freezeAbort()` completion-wins seam that
  `supersede()` honors, so it could abort a turn whose terminal outcome was
  already committed and only delivery remained. Recovery now reports
  `keep_lane / terminal_outcome_committed` and leaves that owner to the
  existing finalization lease.

No new configuration surface: `agents.defaults.timeoutSeconds` and the
backend's `reliability.watchdog` settings now govern this path.

Claude-Session: https://claude.ai/code/session_0122p4qSQzsjwFgYUCDNrwMK
…he turn

Stdout keeps flowing on the CLI protocol stream while a parsed tool is open.
Publishing that as model-stream progress would refresh the same clock
blocked-tool recovery reads, so a wedged tool could never age into its
15-minute window. Mirror the core sibling, where stream progress is only
observed on model response chunks: skip the progress mark while a parsed tool
owns the turn.

Claude-Session: https://claude.ai/code/session_0122p4qSQzsjwFgYUCDNrwMK
The deadline test drove markDiagnosticModelStartedForTest, which passes
coreRequestForTest and bypasses the active-owner gate that ordinary starts
hit, so it proved nothing about the production path. Drive the real trusted
event instead, and pin the companion case where an owner-bound attempt holds
the same session activity and an ownerless deadline is dropped.

Claude-Session: https://claude.ai/code/session_0122p4qSQzsjwFgYUCDNrwMK
The no-output deadline rode claude-cli's model-call diagnostics, and that
factory returns for every other backend id, so a supported non-Claude CLI
backend published no allowance and its configured quiet window could still be
preempted by the generic 360s recovery floor.

Carry the deadline on the stream-progress update every CLI backend already
reports, record it on the session activity, and let both the embedded-run and
model-call recovery predicates extend their floor to it. This replaces the
claude-cli-only requestTimeoutMs field on model.call.started, so the ownerless
start gate no longer gates the allowance either.

Claude-Session: https://claude.ai/code/session_01VhcCrpA9PB6VWSWAkFoLgY
The deadline reaches recovery through the shared stream path rather than the
Claude-only model-call diagnostics, so pin that at the execution boundary with
a backend whose diagnostics helper never arms.

Claude-Session: https://claude.ai/code/session_01VhcCrpA9PB6VWSWAkFoLgY
The new CLI diagnostics cases enabled diagnostics process-wide, started run
activity tracking, then forced both off at teardown without draining the event
queue. The agents-support lane runs `--isolate=false`, so those globals and the
listener leaked into every later file in the same worker.

Restore the prior enabled value, drain queued events, and reset the event state
before handing the worker on.

Claude-Session: https://claude.ai/code/session_01VhcCrpA9PB6VWSWAkFoLgY
@anandnsharma
anandnsharma force-pushed the fix/cli-backend-stream-liveness-watchdog branch from 623d265 to 3d3ee15 Compare September 4, 2026 10:49
openclaw#138157 removed docs/clawhub/publishing.md because ClawHub pages are authored
upstream and mirrored at publish time, but left this scenario referencing the
deleted file, so the catalog check fails for any change set that runs the
qa-lab config shard. Reference the OpenClaw-owned plugin CLI guide that commit
names as the home for this guidance.

Claude-Session: https://claude.ai/code/session_01VhcCrpA9PB6VWSWAkFoLgY
@openclaw-barnacle

Copy link
Copy Markdown

PR CI Sweeper closed this PR to re-fire a dropped CI run but could not reopen it. Please reopen manually.

@anandnsharma

Copy link
Copy Markdown
Contributor Author

Continued in #138280.

The PR CI Sweeper closed this PR to re-fire a dropped CI run and could not reopen it. Reopening is refused from both the GraphQL and REST APIs (Could not open the pull request / HTTP 422), including after restoring the exact recorded head commit on the branch, so the same branch has been rebased onto current main and reopened as #138280.

Nothing about the change itself was rejected: the ClawSweeper findings addressed here, the reproduce-and-fix gateway evidence, and the review discussion above all carry over to #138280.

obviyus added a commit that referenced this pull request Sep 5, 2026
Publish real CLI stream progress and the backend's existing quiet allowance through the exact current diagnostic owner. Release only the settling attempt, reject stale observations after closure or replacement, and keep active-tool recovery independent.

Preserve committed replies under the existing bounded finalization lease. Remove the separate session-ref deadline store and share the model stream-progress reporter.

Continue the contributor work from #137372. This does not claim to fix the distinct direct-provider issue #137263.

Co-authored-by: Anand Sharma <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
Publish real CLI stream progress and the backend's existing quiet allowance through the exact current diagnostic owner. Release only the settling attempt, reject stale observations after closure or replacement, and keep active-tool recovery independent.

Preserve committed replies under the existing bounded finalization lease. Remove the separate session-ref deadline store and share the model stream-progress reporter.

Continue the contributor work from openclaw#137372. This does not claim to fix the distinct direct-provider issue openclaw#137263.

Co-authored-by: Anand Sharma <[email protected]>
Co-authored-by: Ayaan Zaidi <[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 extensions: qa-lab merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

2 participants