Skip to content

fix(claude-cli): preserve active foreground Agent calls past 15 minutes - #157248

Merged
obviyus merged 3 commits into
openclaw:mainfrom
Olli0103:fix/claude-agent-subagent-progress-157209
Sep 27, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
Olli0103:fix/claude-agent-subagent-progress-157209

Conversation

@Olli0103

@Olli0103 Olli0103 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes foreground Claude CLI Agent/Task calls being killed after 15 minutes even while their subagents are working, losing the in-flight work and final reply.

Fixes #157209.

User Impact

Long foreground Agent calls can finish while their attributed subagents continue making semantic progress. A genuinely silent tool still reaches the existing 900-second recovery floor. No configuration or migration is needed.

Why This Change Was Made

Only semantic child records attributed to an active parent Agent/Task call renew its progress clock. Tool calls, tool results, and completed assistant snapshots count; raw stdout, partial deltas, system chatter, mismatched parents, and non-Agent tools do not. The parser still drops child content before parent dispatch, preserving #125621. Output-budget behavior is unchanged and remains separate from this fix.

Evidence

A synthetic Claude executable was driven through executePreparedCliRun, the real process supervisor/child adapter, streaming parser, tool-event handlers, and diagnostic heartbeat. Time was advanced with fake timers at the diagnostic boundary; the production 900-second floor was not changed. The recovery callback aborted the actual child through the run's AbortController. Preparation/admission used the existing executor fixture, so this is CLI-runner boundary proof, not full Gateway E2E. No real Claude or paid provider was used.

  • Current-main baseline 74469f58f38: parent Agent starts; attributed child tool results arrive every 240 simulated seconds. Semantic progress stays at tool:Agent:started; recovery requests active abort at 900 seconds and the executor returns AbortError: CLI run aborted.
  • Candidate: the same child records renew tool:Agent:subagent_progress; at 960 seconds the parent completes with parent-complete, exit 0, and no recovery request. The tool summary contains only one Agent call; child results never appear in parent events.
  • Silent Agent control: abort at 900 seconds, with no attributed records.
  • Non-Agent Bash control: attributed child-shaped records do not renew progress; abort at 900 seconds. Parent events contain no child content.
  • Focused parser, executor, and backend-liveness suites plus the temporary real-child proof: 117 tests passed across three shards in 28.99 seconds. The temporary proof is not added to routine CI. Existing coverage also rejects mismatched parent IDs and partial deltas and checks that progress followed by silence eventually aborts.
  • Type-aware lint on all nine changed files passed. Focused core-test-agents-root, core-test-agents-other, and core-test-state-logging type graphs passed (9.4s, 9.4s, 6.4s). Formatting and git diff --check passed.

The earlier contributor evidence additionally records an installed Claude Code 2.1.243 foreground Agent run lasting 991 wall-clock seconds: 19 child Bash calls, 59 accepted semantic-progress callbacks, exit 0, and final marker PROOF-COMPLETE-157248. That earlier harness manually established the active tool; the synthetic executor proof above exercises that connection without a paid provider.

Semantic subagent records attributed to the active Agent or Task call renew the stuck-session clock. Raw stdout, partial deltas, and mismatched parents still do not. Parent-lane isolation stays.

Fixes openclaw#157209
@clawsweeper

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

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 7:53 PM ET / 23:53 UTC (Revision 4).

ClawSweeper review

What this changes

The Claude CLI runner now credits meaningful child Agent records to an active parent Agent or Task call so long-running work can continue without being mistaken for a stalled tool.

Regression provenance

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

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still lacks this progress path, and the branch has a bounded fix with credible production-boundary proof. I found no actionable patch defect.

Priority: P1
Reviewed head: ece01794fcf35eb4bcee880ab3f118cae720f26f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong boundary proof and a focused patch support the fix; ordinary exact-head checks remain in progress.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed CLI runner and diagnostic owner were exercised through a real child-process boundary with injected child records: the reported baseline aborted at 900 seconds and the candidate completed at 960 seconds, while silent and non-Agent controls still aborted. A separate installed Claude Code run reportedly completed after 991 seconds. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed CLI runner and diagnostic owner were exercised through a real child-process boundary with injected child records: the reported baseline aborted at 900 seconds and the candidate completed at 960 seconds, while silent and non-Agent controls still aborted. A separate installed Claude Code run reportedly completed after 991 seconds. No stored-data contract changes.
Evidence reviewed 7 items Introduced progress path: The PR connects attributed child records to the active parent tool and the diagnostic owner's progress clock.
Current-main necessity: Fetched main has no attributed-subagent progress callback or diagnostic method; its CLI parser options end after the existing usage callback.
Recovery boundary: The diagnostic owner requires the current run, matching active tool-call ID, and Agent or Task name before renewing semantic progress. Recovery otherwise still uses elapsed progress and tool age.
Findings None None.
Security None None.

How this fits together

OpenClaw parses records from the Claude Code subprocess and tracks tool activity for the current agent run. Diagnostic recovery uses that activity to decide whether to wait for a reply or abort a stalled run.

flowchart LR
  A[Claude Code subprocess] --> B[JSONL parser]
  B --> C{Attributed child record?}
  C --> D[Active parent Agent call]
  D --> E[Current run progress clock]
  E --> F{Recovery decision}
  F --> G[Continue or abort run]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +105, Tests +228. Total +333 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 6 105 0 +105
Tests 3 228 0 +228
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 333 0 +333

Review metrics

Metric Value Why it matters
Code and regression coverage production +105 lines, tests +228 lines The added code is concentrated in record classification and owner-held recovery checks; the tests cover parser isolation, runner wiring, and the recovery floor.

Technical review

Best possible solution:

Retain current-run and matching-parent checks, preserve silent-tool recovery and parent-lane isolation, and handle the separate stream-budget problem in its own work.

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

Yes. The contributor reports a baseline run through the process and diagnostic boundary that aborts at 900 seconds despite attributed child results; fetched main retains that same relevant path. I did not execute it in this read-only review.

Is this the best way to solve the issue?

Yes. The patch credits only attributed records for an active Agent or Task call while retaining recovery for silence and keeping child content out of the parent conversation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Active foreground Agent work can currently be aborted after 15 minutes, losing the in-flight turn and final reply.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed CLI runner and diagnostic owner were exercised through a real child-process boundary with injected child records: the reported baseline aborted at 900 seconds and the candidate completed at 960 seconds, while silent and non-Agent controls still aborted. A separate installed Claude Code run reportedly completed after 991 seconds. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed CLI runner and diagnostic owner were exercised through a real child-process boundary with injected child records: the reported baseline aborted at 900 seconds and the candidate completed at 960 seconds, while silent and non-Agent controls still aborted. A separate installed Claude Code run reportedly completed after 991 seconds. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Peter Steinberger: 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 (3 earlier review cycles)
  • reviewed 2026-09-24T11:40:43.107Z sha 68c76c7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-24T13:01:24.169Z sha 68c76c7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-24T13:09:36.755Z sha 68c76c7 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Sep 24, 2026
@Olli0103

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 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 24, 2026
@Olli0103

Copy link
Copy Markdown
Contributor Author

CI handoff for head 68c76c74af after ClawSweeper marked the proof sufficient:

  • Shard 33 failed in src/infra/outbound/delivery-queue.reconnect-drain.test.ts with two assertions and state-read-admission teardown errors.
  • Shard 44 failed in src/gateway/server-restart-sentinel-notice.test.ts with one assertion and a state-read-admission teardown error.
  • Runtime topology architecture reports failure, but its Run additional check shard step was cancelled; no failed-step log was available. ci-gate is red as the aggregate.

Neither failing test file is changed by this PR. I ran those two complete files locally on the PR head with node scripts/run-vitest.mjs src/infra/outbound/delivery-queue.reconnect-drain.test.ts src/gateway/server-restart-sentinel-notice.test.ts: 23/23 and 26/26 passed, two shards in 176.62 seconds, exit 0. This does not prove the CI failures are green on current main or that the large-shard interaction is harmless. A maintainer CI rerun/triage is needed; I have not changed unrelated production code or tests to chase these unreplicated failures.

@obviyus obviyus changed the title fix(claude-cli): count foreground Agent subagent work as progress fix(claude-cli): preserve active foreground Agent calls past 15 minutes Sep 26, 2026
@obviyus
obviyus merged commit e8e68ea into openclaw:main Sep 27, 2026
204 of 206 checks passed
@obviyus

obviyus commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Landed as e8e68ea. Attributed semantic subagent work now keeps the active foreground Agent/Task alive without leaking child content into the parent lane. Real-child CLI-runner proof: current main aborted at 900 simulated seconds; the fix completed at 960 seconds. Silent Agent and non-Agent Bash controls still aborted at 900 seconds. Focused tests, owner types, lint, exact-head CI, and hosted review passed. Thanks @Olli0103 for the fix and @OpenClawKobian99 for the detailed report!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…es (openclaw#157248)

## What Problem This Solves

Fixes foreground Claude CLI `Agent`/`Task` calls being killed after 15 minutes even while their subagents are working, losing the in-flight work and final reply.

Fixes openclaw#157209.

## User Impact

Long foreground Agent calls can finish while their attributed subagents continue making semantic progress. A genuinely silent tool still reaches the existing 900-second recovery floor. No configuration or migration is needed.

## Why This Change Was Made

Only semantic child records attributed to an active parent Agent/Task call renew its progress clock. Tool calls, tool results, and completed assistant snapshots count; raw stdout, partial deltas, system chatter, mismatched parents, and non-Agent tools do not. The parser still drops child content before parent dispatch, preserving openclaw#125621. Output-budget behavior is unchanged and remains separate from this fix.

## Evidence

A synthetic Claude executable was driven through `executePreparedCliRun`, the real process supervisor/child adapter, streaming parser, tool-event handlers, and diagnostic heartbeat. Time was advanced with fake timers at the diagnostic boundary; the production 900-second floor was not changed. The recovery callback aborted the actual child through the run's AbortController. Preparation/admission used the existing executor fixture, so this is CLI-runner boundary proof, not full Gateway E2E. No real Claude or paid provider was used.

- Current-main baseline `3b5f5168783`: parent Agent starts; attributed child tool results arrive every 240 simulated seconds. Semantic progress stays at `tool:Agent:started`; recovery requests active abort at 900 seconds and the executor returns `AbortError: CLI run aborted`.
- Candidate: the same child records renew `tool:Agent:subagent_progress`; at 960 seconds the parent completes with `parent-complete`, exit 0, and no recovery request. The tool summary contains only one Agent call; child results never appear in parent events.
- Silent Agent control: abort at 900 seconds, with no attributed records.
- Non-Agent Bash control: attributed child-shaped records do not renew progress; abort at 900 seconds. Parent events contain no child content.
- Focused parser, executor, and backend-liveness suites plus the temporary real-child proof: 117 tests passed across three shards in 28.99 seconds. The temporary proof is not added to routine CI. Existing coverage also rejects mismatched parent IDs and partial deltas and checks that progress followed by silence eventually aborts.
- Type-aware lint on all nine changed files passed. Focused `core-test-agents-root`, `core-test-agents-other`, and `core-test-state-logging` type graphs passed (9.4s, 9.4s, 6.4s). Formatting and `git diff --check` passed.

The earlier contributor evidence additionally records an installed Claude Code 2.1.243 foreground Agent run lasting 991 wall-clock seconds: 19 child Bash calls, 59 accepted semantic-progress callbacks, exit 0, and final marker `PROOF-COMPLETE-157248`. That earlier harness manually established the active tool; the synthetic executor proof above exercises that connection without a paid provider.

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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants