Skip to content

fix(subagents): parent turns never settle after an inline child reply - #181933

Merged
jalehman merged 1 commit into
mainfrom
fix/inline-child-result-cleanup
Oct 23, 2026
Merged

jalehman merged 1 commit into
mainfrom
fix/inline-child-result-cleanup

Conversation

@jalehman

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a parent's turn never fully settles when it waits inline on a sessions_send reply from its own native child and that child's run ends during the wait.

User Impact

User impact: parents that talk to their own children through sessions_send no longer leave the child run stuck as an unfinished descendant, so later turns, descendant-settlement waits, and run cleanup complete normally. There is no configuration or migration.

Why This Change Was Made

When a child run ends while the requester's inline wait still claims it, cleanup is deferred to that claim. Acknowledging the inline result then marked the result delivered and retired the requester obligation without re-entering cleanup, so the run never got cleanupCompletedAt. The acknowledgement now resumes the run after its write commits when the run has already ended, the same step completion delivery already takes after committing its own publication.

Evidence

  • Regression: the existing "consumes an inline child follow-up result" case now ends the child while the parent waits inline and asserts cleanupCompletedAt is set and the requester has no pending descendants. It fails without the fix (cleanupCompletedAt is undefined) and passes with it (30/30 in the file).
  • Real behavior (AWS Crabbox, real Gateway, openai/gpt-5.4): this defect was found while proving fix(sessions): parent follow-ups fail after native child runs age out #181117, whose opt-in live test hung in descendant settlement right after an inline child reply (failed run). The same live test with this commit applied on the fix(sessions): parent follow-ups fail after native child runs age out #181117 head passed every phase in 82 s, exit 0 (run_4eec342e5810). The touched files are identical on main and that head.
  • Focused suites on this branch: child coordination, sessions-send-followup, agent-step, sessions-send-owner-continuation, and Gateway agent.followup-owner pass. tsconfig.core.json and the agents-root test typecheck pass.
  • Review: independent autoreview of the branch is scoped-clean through P1.
  • The test file was at its line cap, so one existing reply helper moved into the shared test-support module; no lint or line-limit gate was relaxed.
Commands
node scripts/run-vitest.mjs src/agents/openclaw-tools.sessions-send-child-coordination.test.ts src/agents/tools/sessions-send-followup.test.ts src/agents/tools/agent-step.test.ts src/agents/tools/sessions-send-owner-continuation.test.ts src/gateway/server-methods/agent.followup-owner.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p tsconfig.core.json --noEmit
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-root.json --noEmit

Related: #181117

A child run that ends while its requester's inline sessions_send wait still
claims it defers cleanup to that claim. Acknowledging the inline result then
retired the obligation without re-entering cleanup, so the row never got
cleanupCompletedAt and stayed a pending descendant of its requester.

Resume the run after the acknowledgement commits when it had already ended.
@clawsweeper

clawsweeper Bot commented Oct 23, 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 agents Agent runtime and tooling size: S labels Oct 23, 2026
@jalehman
jalehman marked this pull request as ready for review October 23, 2026 21:02
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Resume cleanup after a parent consumes an already-ended child’s inline reply.

Example: Parent agent:main:dashboard:inline-parent receives “Inline follow-up result” from its native child.

  • Before: The reply arrives, but the child lacks cleanupCompletedAt and remains a pending descendant.
  • After: Cleanup completes without another requester delivery, allowing the parent to settle.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage, recorded real-Gateway recovery, and green exact-head CI.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate and records a real Gateway/model continuation passing after this patch; the linked Crabbox artifact could not be independently opened because the review environment blocks that host.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A parent receives its child’s reply but cannot finish settling because that child remains pending.
Reason: The maintainer-authored change restores completion of existing delegated work without introducing configuration, another owner, or a new public contract.

Regression provenance

Regression provenance — verified: source commit a8a3680f3749 by Peter Steinberger; canonical PR #181373 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

This PR repairs a current-main settlement bug through the existing registry owner; no actionable introduced defects were found, and exact-head CI is green.

Priority: P2
Reviewed head: 6aecdb76c8d33bd6028e1545a54deac3b3d2c83a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The subagent registry tracks delegated runs and completion obligations; inline reply acknowledgement updates delivery state, then lifecycle cleanup releases pending descendant accounting.

flowchart TD
Parent[Parent turn] --> Send[Sessions send]
Send --> Child[Native child run]
Child --> Reply[Inline reply acknowledgement]
Reply --> Registry[Subagent registry]
Registry --> Cleanup[Existing lifecycle cleanup]
Cleanup --> Settlement[Parent settlement]
Loading

Technical review

Best possible solution:

Keep acknowledgement and deferred cleanup in the existing subagent registry, with this post-commit resume handoff.

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

The current-main acknowledgement, live-claim cleanup deferral, and pending-descendant query establish the failure path; the linked real-Gateway report independently records the matching stall.

Is this the best way to solve the issue?

This is the smallest complete production repair: reuse the existing cleanup owner after acknowledgement commits, while extending the existing regression instead of adding another settlement mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4c7b43d17b08.

Provenance checked

  • Inline child-result acknowledgement keeps the original intent (a8a3680: Preserve durable recovery for synchronous child follow-ups and consume inline results through the existing completion obligation.)
  • Coordination test fixture keeps the original intent (4ac4a4c: Consolidate repeated fixtures and duplicate proof while preserving behavioral coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a8a3680 adds src/agents/subagents/registry/subagent-registry-requester-claim.ts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a8a3680f3749; files: src/agents/subagents/registry/subagent-registry-requester-claim.ts)

PR surface

Source +12, Tests +40. Total +52 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 15 3 +12
Tests 2 54 14 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 69 17 +52

Labels

Label changes:

  • add P2: A reproducible native-child follow-up can leave its parent waiting indefinitely, with a focused repair and limited affected surface.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A reproducible native-child follow-up can leave its parent waiting indefinitely, with a focused repair and limited affected surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 23, 2026, 5:19 PM ET / 21:19 UTC.

@jalehman
jalehman merged commit afd591f into main Oct 23, 2026
218 of 219 checks passed
@jalehman
jalehman deleted the fix/inline-child-result-cleanup branch October 23, 2026 21:31
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
…nclaw#181933)

A child run that ends while its requester's inline sessions_send wait still
claims it defers cleanup to that claim. Acknowledging the inline result then
retired the obligation without re-entering cleanup, so the row never got
cleanupCompletedAt and stayed a pending descendant of its requester.

Resume the run after the acknowledgement commits when it had already ended.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…1933)

A child run that ends while its requester's inline sessions_send wait still
claims it defers cleanup to that claim. Acknowledging the inline result then
retired the obligation without re-entering cleanup, so the row never got
cleanupCompletedAt and stayed a pending descendant of its requester.

Resume the run after the acknowledgement commits when it had already ended.

(cherry picked from commit afd591f)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 1587737ddde0c9b3b6aa8eae040eb982ce62fe16)
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…1933)

A child run that ends while its requester's inline sessions_send wait still
claims it defers cleanup to that claim. Acknowledging the inline result then
retired the obligation without re-entering cleanup, so the row never got
cleanupCompletedAt and stayed a pending descendant of its requester.

Resume the run after the acknowledgement commits when it had already ended.

(cherry picked from commit afd591f)

Adaptation-Base: cecd7059127eb19b4d2a2d2143e6bd4cb126b40b
Adaptation-Scope: Exact admitted inline requester validation and negative controls; retain existing ended-child cleanup
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 3834b27c9c094f80fec12ab5fcd0944a2ccb1aa2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant