Skip to content

fix(agents): restore missing subagent replies after steering or yield - #118117

Merged
steipete merged 1 commit into
mainfrom
codex/qa0802-subagent-completion-owner
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa0802-subagent-completion-owner

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users waiting for a spawned agent could receive no final reply when a child was steered before Gateway restart, or when a sandboxed/controller session differed from the real completion-owner session.

Why This Change Was Made

Requester completion is owned by the durable requester session and the original immutable child task identity. Restart restoration now reconstructs accepted children with their original task identity, and the yield hook marks the actual trimmed completion-owner session before ending the requester turn. Existing controller/policy identity and persisted schema remain unchanged.

User Impact

Completed child-agent work reliably wakes the original requester after steering, restart, and sandboxed session projection. Normal sessions, whitespace/absent overrides, and non-yielded completion keep their existing behavior.

Evidence

  • Before: actual production settlement returned settled=false, made no persistence update, and scheduled no requester wake for a restored steered child; a controller/durable-owner split likewise marked zero children and lost the requester wake.
  • After: both production-owner paths settle successfully; the yielded requester wakes exactly once and the durable requester-turn marker is cleared.
  • Focused hosted Testbox proof: pnpm test src/agents/openclaw-tools.registration.test.ts src/agents/subagent-registry.persistence.resume.test.ts src/agents/subagent-registry-requester-yield.test.ts — 61/61 tests across three files passed.
  • Hosted runner: https://github.com/openclaw/openclaw/actions/runs/30760713254
  • Added real SQLite restore regressions for yielded and non-yielded steered children, plus actual tool-factory coverage for distinct, trimmed, blank, and absent completion-owner sessions.
  • Fresh independent gpt-5.6-sol/high autoreview: no actionable P0/P1 findings; confidence 0.93. TruffleHog clean.
  • Production delta: +1 line across the two canonical owners; no schema, configuration, security, or permission changes.
  • AI-assisted; independently reviewed and behaviorally reproduced.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 2, 2026
@steipete
steipete marked this pull request as ready for review August 2, 2026 18:36
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 2:55 PM ET / 18:55 UTC.

ClawSweeper review

What this changes

The branch binds subagent completion to the original child task and durable requester session so a steered or yielded child can wake its requester after Gateway restart.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This PR is still necessary and should remain open for maintainer merge review. Current main still restores requester settlement with the mutable steered run ID and records yield intent against the controller session; the branch corrects both durable ownership boundaries and adds focused SQLite and tool-factory regressions. No actionable patch defect was found, but the maintainer label and pending exact-head checks mean this review should not close or automate it.

Priority: P1
Reviewed head: d89b53b165bc92489dd313b1b8b4e3cf96e92a58

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused real-behavior proof and narrow owner-boundary coverage support a high-quality repair, with pending exact-head checks remaining as the merge gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body reports an after-fix hosted Testbox run of the real tool factory and SQLite restore path, including successful settlement, one requester wake, and durable-marker cleanup.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports an after-fix hosted Testbox run of the real tool factory and SQLite restore path, including successful settlement, one requester wake, and durable-marker cleanup.
Evidence reviewed 5 items Current-main restore mismatch: The restorer groups child entries by durable requester turn but reconstructs accepted child spawns with entry.runId; the run manager elsewhere starts and finalizes the immutable task using entry.taskRunId ?? entry.runId. The PR changes restoration to use the same task identity.
Current-main yield owner mismatch: Current main destructures agentSessionKey as the requester completion owner; the PR instead chooses the trimmed runSessionKey and falls back to the controller key only when that durable owner is absent or blank, before persisting yield intent.
Settlement API requires the durable identity: The requester-yield API persists state by an exact requester session key and requester turn run ID before aborting the active requester run, so selecting the controller session when it differs cannot settle the durable requester’s children.
Findings None None.
Security None None.

How this fits together

A requester can spawn subagents and yield its active turn while their work continues. The subagent registry persists child ownership in SQLite, restores it after restart, and wakes the requester when the original child tasks have settled.

flowchart LR
  Requester[Requester session] --> Spawn[Spawn child task]
  Requester --> Yield[Yield active turn]
  Spawn --> Registry[Durable subagent registry]
  Yield --> Registry
  Registry --> Restore[Gateway restart restore]
  Restore --> Settle[Settle original child task]
  Settle --> Wake[Wake durable requester]
Loading

Before merge

  • Resolve merge risk (P1) - The patch changes durable requester-turn settlement across restart, so an incorrect task or session identity could still suppress the requester wake or direct it to the wrong session.
  • Resolve merge risk (P1) - The supplied PR state has pending exact-head CI jobs; merge should wait for required checks rather than infer success from the completed fast lanes.
  • Complete next step (P2) - This is an active, proof-positive implementation PR with no discrete repair finding; its remaining action is maintainer merge review after exact-head CI completes.
Agent review details

Security

None.

PR surface

Source +1, Tests +123. Total +124 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 2 +1
Tests 2 124 1 +123
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 127 3 +124

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Merge after exact-head checks (recommended)
    Keep the durable-identity repair and merge once the pending checks succeed for the current head and no human-review blocker remains.
  2. Pause on contradictory lifecycle evidence
    Hold the PR if pending validation shows a restored child can settle a different requester turn or schedule more than one wake.

Technical review

Best possible solution:

Preserve one canonical durable requester session and original child-task identity through yield, SQLite restoration, and completion settlement; merge after the exact PR head passes its remaining required checks.

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

Yes. Current source establishes both mismatched ownership paths, and the branch supplies focused tool-factory and SQLite-restoration regression scenarios for the affected steering and yield flows.

Is this the best way to solve the issue?

Yes. The branch repairs the two canonical ownership boundaries—yield recording and restart restoration—rather than adding a downstream delivery fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5c2559e2d9b4.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: The defect can leave a requester without the final reply from completed child-agent work.
  • merge-risk: 🚨 session-state: The patch changes the durable session and task identifiers used for requester-turn settlement after restart.
  • merge-risk: 🚨 message-delivery: Wrong settlement ownership can suppress the final requester wake or target another session.
  • 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 (live_output): The PR body reports an after-fix hosted Testbox run of the real tool factory and SQLite restore path, including successful settlement, one requester wake, and durable-marker cleanup.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an after-fix hosted Testbox run of the real tool factory and SQLite restore path, including successful settlement, one requester wake, and durable-marker cleanup.

Evidence

What I checked:

  • Current-main restore mismatch: The restorer groups child entries by durable requester turn but reconstructs accepted child spawns with entry.runId; the run manager elsewhere starts and finalizes the immutable task using entry.taskRunId ?? entry.runId. The PR changes restoration to use the same task identity. (src/agents/subagent-registry-restore.ts:121, 5c2559e2d9b4)
  • Current-main yield owner mismatch: Current main destructures agentSessionKey as the requester completion owner; the PR instead chooses the trimmed runSessionKey and falls back to the controller key only when that durable owner is absent or blank, before persisting yield intent. (src/agents/openclaw-tools.ts:299, 6e87d3b5f3e5)
  • Settlement API requires the durable identity: The requester-yield API persists state by an exact requester session key and requester turn run ID before aborting the active requester run, so selecting the controller session when it differs cannot settle the durable requester’s children. (src/agents/subagent-registry-requester-yield.ts:6, 5c2559e2d9b4)
  • Focused branch coverage: The branch adds session-owner selection coverage for durable, trimmed, blank, and absent run-session values, plus SQLite-backed restored steered-child cases for both yielded and ordinary requester turns. (src/agents/openclaw-tools.registration.test.ts:523, d89b53b165bc)
  • Feature provenance: The current restore and tool-owner lines both blame to the same recent commit, showing that this PR repairs a coherent recent requester-settlement implementation rather than adding a parallel flow. (src/agents/subagent-registry-restore.ts:121, 6e87d3b5f3e5)

Likely related people:

  • steipete: Peter Steinberger introduced the currently blamed requester-settlement lines in commit 6e87d3b5f3e5c2555561587fa7dd81829292a99a, and is also the author of the focused corrective PR commit. (role: feature owner and recent area contributor; confidence: high; commits: 6e87d3b5f3e5, d89b53b165bc; files: src/agents/openclaw-tools.ts, src/agents/subagent-registry-restore.ts, src/agents/subagent-registry-requester-yield.ts)

Rank-up moves

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

  • Wait for the pending required checks on the current head before merging.

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 (1 earlier review cycle)
  • reviewed 2026-08-02T18:41:24.791Z sha 51d5daf :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/qa0802-subagent-completion-owner branch from 51d5daf to d89b53b Compare August 2, 2026 18:50
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 2, 2026
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer exact-head review completed at d89b53b. Root cause: requester yield recorded the controller session instead of the durable run session, and restart restoration reconstructed a steered child with its mutable run ID rather than original taskRunId. Canonical owners now persist the durable session and settle immutable original child tasks; SQLite-backed yielded and ordinary restore paths each wake the correct requester exactly once. Production delta +1 line, no schema/config/protocol changes. Hosted Blacksmith final-source tool-factory/requester-yield/SQLite proof: 61/61 tests. Exact-head CI https://github.com/openclaw/openclaw/actions/runs/30762029700 including check-test-types and ci-gate, Workflow Sanity https://github.com/openclaw/openclaw/actions/runs/30762029667 , and real behavior proof https://github.com/openclaw/openclaw/actions/runs/30762027069 all succeeded. Fresh full-branch Sol/high review clean, confidence 0.96. I personally read the latest ClawSweeper review; its only rank-up requested waiting for exact-head CI, now fully satisfied.

@steipete
steipete merged commit 82540ad into main Aug 2, 2026
124 of 126 checks passed
@steipete
steipete deleted the codex/qa0802-subagent-completion-owner branch August 2, 2026 19:13
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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: 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