Repository navigation
fix(claude-cli): finish parent replies after nested background agents - #182267
Conversation
Keep tasks launched by a native subagent out of parent-input completion accounting. Their notifications are consumed by the launching agent, not the main query. Cover nested Agents and workflows through the stdio runtime, preserving top-level holds and same-process warm reuse. Co-authored-by: steipete <[email protected]>
Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 03795749-42de-4fcd-ada4-4794e31a50d2
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesExclude subagent-launched tasks from parent-input completion accounting and add nested Agent and workflow regressions. Example: Background Agent parent launches child with parent_task_id="parent", then the parent finishes with "parent final".
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still misattributes nested background tasks, and this focused repair addresses the resulting reply-completion failure without changing watchdog policy. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Anthropic CLI adapter consumes native task events, records session-wide ownership, and emits interim or terminal results to the host runner. flowchart LR
A[Gateway input] --> B[Claude CLI transport]
B --> C[Native task events]
C --> D[Task ownership]
D --> E[Parent completion accounting]
E --> F[Terminal reply]
Technical reviewBest possible solution: Keep nested-task classification in the existing ownership helper while preserving top-level holds, notification settlement, and warm-session reuse. Do we have a high-confidence way to reproduce the issue? The supplied event order deterministically leaves the nested task pending on current main; source and regression inspection establish the path, but this read-only review executed no target code. Is this the best way to solve the issue? The patch repairs classification at the existing producer of ownership facts, preserves legitimate continuation accounting, and avoids timers or watchdog changes that could hide the cause. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 70ad789846f2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -2, Tests +75, Docs +1. Total +74 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 24, 2026, 1:39 AM ET / 05:39 UTC. |
|
Merged via squash.
|
…openclaw#182267) * fix(claude-cli): finish parent replies after nested background agents Keep tasks launched by a native subagent out of parent-input completion accounting. Their notifications are consumed by the launching agent, not the main query. Cover nested Agents and workflows through the stdio runtime, preserving top-level holds and same-process warm reuse. Co-authored-by: steipete <[email protected]> * fix(claude-cli): finish parent replies after nested background agents Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 03795749-42de-4fcd-ada4-4794e31a50d2 --------- Co-authored-by: steipete <[email protected]>
…#182267) * fix(claude-cli): finish parent replies after nested background agents Keep tasks launched by a native subagent out of parent-input completion accounting. Their notifications are consumed by the launching agent, not the main query. Cover nested Agents and workflows through the stdio runtime, preserving top-level holds and same-process warm reuse. Co-authored-by: steipete <[email protected]> * fix(claude-cli): finish parent replies after nested background agents Worked on by: - @steipete Co-authored-by: steipete <[email protected]> --------- Co-authored-by: steipete <[email protected]> Release adaptation: main's harness-based task-ownership test file does not exist on stable; the nested Agent/workflow cases are ported as a `nested-child-*` scenario in stable's protocol fixture and cli-runtime.test.ts. Companion follow-up to #170322. (cherry picked from commit f36f0cc)
…#182267) * fix(claude-cli): finish parent replies after nested background agents Keep tasks launched by a native subagent out of parent-input completion accounting. Their notifications are consumed by the launching agent, not the main query. Cover nested Agents and workflows through the stdio runtime, preserving top-level holds and same-process warm reuse. Co-authored-by: steipete <[email protected]> * fix(claude-cli): finish parent replies after nested background agents Worked on by: - @steipete Co-authored-by: steipete <[email protected]> OpenClaw-Publication: 03795749-42de-4fcd-ada4-4794e31a50d2 --------- Co-authored-by: steipete <[email protected]> Adaptation: Apply nested classification directly in the B runtime monolith and its real stdio fixture. This intermediate source behavior is corrected by the required next source for parent-ended-first forwarding; no extracted runtime architecture imported. Source-commit: f36f0cc Co-authored-by: RomneyDa <[email protected]>
Closes #182175
What Problem This Solves
Fixes: Claude CLI parent replies can remain in progress indefinitely after a background Agent launches another background task.
User Impact
User impact: the parent reply finishes when its own background work settles, without waiting for a nested task's reply on the wrong stream. Top-level background work still keeps its parent reply open. No configuration or migration is required.
Why This Change Was Made
Claude identifies nested Agents and workflows with
parent_task_id, but reservesowned_by_subagentfor nested Bash tasks. Treat all tasks with a parent as owned by that subagent instead of inheriting ownership of the outer input. Keep the existing completion, replay, and watchdog policies unchanged.Evidence
parent_task_idmeans the launching local Agent, whileowned_by_subagentis emitted only for nested Bash.6802faaacompletedchat.send→ native Claude stdio →agent.waitwithstatus: okand terminal replyparent final;chat.historyretained both interim and final text. The focused E2E test passed, and its owned Gateway and state were removed. Publication added a metadata-only commit; the published tree is identical to the tested tree.Thanks to Peter Steinberger (@steipete).
Work sessions
Worked on by