Skip to content

fix: deliver subagent results after the requester yields - #155348

Merged
jalehman merged 4 commits into
mainfrom
openclaw/fix-completion-authority-custody-143334
Sep 22, 2026
Merged

jalehman merged 4 commits into
mainfrom
openclaw/fix-completion-authority-custody-143334

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #143334

What Problem This Solves

Fixes: a completed subagent’s result is retained but never delivered when its requester yields and the spawning execution releases its operator authority.

User Impact

User impact: yielded requesters receive the completed child result without restarting the Gateway. Cancellation and operator revocation still stop child execution and deliver cancellation notices. No configuration or data migration is required.

This addresses the reproduced inactive-operator-authority mechanism, not every queued-input starvation or restart-time timeout reported in the linked issue.

Why This Change Was Made

The existing registry retains the original restricted completion context while its source is live, independently of the execution that spawned the child. It shares the delayed-session-reply capture mechanism, transfers custody across same-task replacement or a freshly admitted explicit retry, and releases it after committed settlement, retirement, or source/Gateway revocation. Failed persistence does not discard custody.

Successful result batches validate every original source and exact registry member. Cancellation-only notices retain their existing independent cancellation caller; mixed waves cannot borrow another or revoked operator’s source. Retired callbacks fail closed. Role/device/profile, scope-ceiling, execution and Gateway guards remain enforced. Unchanged dispatch types move to a sibling contract module to satisfy the source-size gate after the main refresh.

Evidence

  • CI fixture follow-up (01bfacf84d3d2fa12f85639cad9895c09e7abb01): repaired the two native-spawn test identities missing their real live receipt authority, without changing production code or weakening assertions. The original two failures reproduced; 65 focused/sibling tests and all selected changed-file gates passed, with fresh independent AutoReview clean at P0–P2. Exact-head CI passed; both openclaw/ci-gate surfaces are green (September 22, 14:39 UTC readback). The runtime proof below remains on d2244005, with byte-identical production in this fixture-only follow-up.

  • Real-Gateway proof and downloadable manifest for d2244005a9a5bdf204c5e18e144172d3d1adf088: normal completion delivered exactly once without restart; cancellation and role-revocation controls both cancelled the child and delivered the notice; restart recovered the retained result without rerunning the child. Four strict cases passed. All12 published artifacts were downloaded and SHA256-verified; links expire2026-09-29.

  • Same-head core typecheck, lint (zero warnings/errors), formatting, conflict/line-cap guards, and 479 tests in16 files passed. Registered-boundary negatives cover stale/mixed sources, scope retention, persistence rollback, replacement, settlement and fresh retry. These are not extra live mixed-principal E2E cells.

  • BEFORE proof, independently reproduced on implementation base 7ad0839 before production edits. Registered-boundary and retained-retry regressions failed before the repair and passed afterward. Earlier pre-rebase verification also passed all31 selected gates, including all25 core-test typecheck graphs; that is historical evidence, not current-head full CI.

  • Fresh independent AutoReview: no actionable P0–P2 findings in the final combined patch. Hosted CI/review is separate; no full-CI or merge-readiness claim.

Only the external authentication service and model HTTP/SSE responses are fixtures; actual Gateway admission, registered spawn/yield tools, execution, registry, durable tasks and successor dispatch are exercised. All owned Testboxes were stopped and cleanup read back. Portal metadata sync timed out, but command receipts succeeded. Restart proof intentionally interrupts admitted synthesis: interruption/failure text precedes exactly one successful result, so this is not a claim of interruption-free UX.

Contributor credit: @jalehman (Josh Lehman), who directed this investigation and fix.

Work sessions


View the OpenClaw team session

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 22, 2026
roboclaw-bot and others added 2 commits September 22, 2026 01:52
Retain the original restricted operator source at registered completion custody, independently of spawning execution. Release on committed settlement or revocation; preserve exact-row, batch, cancellation and retry ownership.

Related: #143334

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: b1f1b29c-a435-4aa0-9508-5d44d8fe2a05
Co-authored-by: jalehman <[email protected]>
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/fix-completion-authority-custody-143334 branch from bd80ab2 to db1de7b Compare September 22, 2026 01:54
@clawsweeper clawsweeper Bot added 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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 10:48 AM ET / 14:48 UTC (Revision 6).

ClawSweeper review

What this changes

Retains a subagent’s original operator permissions until its result reaches the yielded requester, with cleanup, retry handling, regression coverage, and documentation.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. Source review and the supplied Gateway observations support the repair, with no actionable correctness or security finding. Maintainer discussion explicitly confirms that the related merged work does not supersede it.

Priority: P1
Reviewed head: 01bfacf84d3d2fa12f85639cad9895c09e7abb01

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A coherent owner-level repair with meaningful lifecycle regressions and real Gateway success, cancellation, revocation, and recovery observations.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied isolated real-Gateway observations exercise registration, yield, child completion, and successor dispatch: delivery succeeds once, cancellation and role revocation prevent successful child results, and restart recovers the retained result. Production is unchanged since that proof revision. Artifact retrieval was blocked on the reviewer side; mixed-source negatives remain supplemental boundary tests. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied isolated real-Gateway observations exercise registration, yield, child completion, and successor dispatch: delivery succeeds once, cancellation and role revocation prevent successful child results, and restart recovers the retained result. Production is unchanged since that proof revision. Artifact retrieval was blocked on the reviewer side; mixed-source negatives remain supplemental boundary tests. No stored-data contract changes.
Evidence reviewed 10 items Pinned change ownership: Reviewed the introduced merge-base-to-head delta. Comparing the runtime-proof revision with the reviewed head confirms that the follow-up changes only the native-spawn test fixture; production code is unchanged. The supplied test merge is stale and was not used to infer integration behavior.
Current main still needs registry custody: Current main’s run map has no completion-authority retention. Its existing continuation helper retains authority only around an explicitly wrapped asynchronous operation; it does not cover registered subagent settlement. No merged fixing PR or shipped implementation of this registry repair was established.
Authority lifecycle and final admission: Registration captures live authority; registry custody checks exact entries and compatible batch sources. The shared continuation owner preserves scope ceilings and source/Gateway revocation. Dispatch carries current-authority checks through asynchronous preparation into admission. Committed settlement releases custody, while failed writes preserve it.
Findings None None.
Security None None.

How this fits together

OpenClaw’s subagent registry tracks delegated work after the requesting agent yields. When children finish, it passes their results through Gateway admission to resume the requester under the original permission limits.

flowchart TD
  A[Requester spawns child] --> B[Registry retains completion authority]
  A --> C[Requester yields]
  B --> D[Child result ready]
  C --> D
  D --> E{Source and batch still authorized?}
  E -->|Yes| F[Gateway resumes requester]
  E -->|No| G[Reject result delivery]
  F --> H[Committed settlement releases authority]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +237, Tests +298, Docs +14. Total +549 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 9 378 141 +237
Tests 4 302 4 +298
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 694 145 +549

Review metrics

Metric Value Why it matters
Production versus regression coverage production +237 net lines; tests +298 net lines Production growth implements registry-owned authority retention and reuses the existing continuation mechanism; tests exercise its lifecycle and rejection boundaries.

Technical review

Best possible solution:

Keep completion authority with the existing registry until settlement, while preserving permission ceilings, revocation, and fresh admission after restart.

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

Yes: source shows the missing registry-owned authority hold, and the supplied before-fix Gateway trace demonstrates rejection after the requester yields. This review did not execute a current-main reproduction.

Is this the best way to solve the issue?

Yes: extending the existing registry and shared continuation owner repairs the lifetime mismatch without adding configuration, a competing delivery path, or persisted authority.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 50ea1795fc80.

Labels

Label changes:

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

Label justifications:

  • P1: Completed delegated work can fail to reach a yielded requester, breaking an active agent workflow despite successful child execution.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied isolated real-Gateway observations exercise registration, yield, child completion, and successor dispatch: delivery succeeds once, cancellation and role revocation prevent successful child results, and restart recovers the retained result. Production is unchanged since that proof revision. Artifact retrieval was blocked on the reviewer side; mixed-source negatives remain supplemental boundary tests. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied isolated real-Gateway observations exercise registration, yield, child completion, and successor dispatch: delivery succeeds once, cancellation and role revocation prevent successful child results, and restart recovers the retained result. Production is unchanged since that proof revision. Artifact retrieval was blocked on the reviewer side; mixed-source negatives remain supplemental boundary tests. No stored-data contract changes.

Evidence

What I checked:

  • Pinned change ownership: Reviewed the introduced merge-base-to-head delta. Comparing the runtime-proof revision with the reviewed head confirms that the follow-up changes only the native-spawn test fixture; production code is unchanged. The supplied test merge is stale and was not used to infer integration behavior. (src/agents/subagents/spawn/subagent-spawn.in-process-gateway.test.ts:400, 01bfacf84d3d)
  • Current main still needs registry custody: Current main’s run map has no completion-authority retention. Its existing continuation helper retains authority only around an explicitly wrapped asynchronous operation; it does not cover registered subagent settlement. No merged fixing PR or shipped implementation of this registry repair was established. (src/agents/subagents/registry/subagent-registry-memory.ts:76, 50ea1795fc80)
  • Authority lifecycle and final admission: Registration captures live authority; registry custody checks exact entries and compatible batch sources. The shared continuation owner preserves scope ceilings and source/Gateway revocation. Dispatch carries current-authority checks through asynchronous preparation into admission. Committed settlement releases custody, while failed writes preserve it. (src/gateway/server-plugin-in-process-dispatch.ts:149, 01bfacf84d3d)
  • Real Gateway observations: The captured proof comment reports four isolated Blacksmith Testbox cases through actual Gateway admission, registered spawn/yield tools, registry, task storage, and successor dispatch: one successful result after yield; cancellation and role revocation with no successful child result; and restart recovery without rerunning the child. External authentication and model responses were fixtures. Restart emitted interruption text before the successful result. Mixed-source and stale-member negatives are registered-boundary tests, not additional live cases. Source: fix: deliver subagent results after the requester yields #155348 (comment). (d2244005a9a5)
  • Before-fix mechanism: The linked before-fix observation records a yielded parent, retained successful child result, and repeated admission rejection because operator execution authority had ended. Its controls distinguish cancellation and revocation from ordinary execution settlement; it expressly does not reproduce every starvation symptom in the broader report. (953882c74a1f)
  • Meaningful lifecycle regressions: The new registered-owner suite covers 13 lifecycle variants, including release, revocation, replacement, persistence failure, incompatible sources, and stale members. Two retry cases check fresh authority transfer and failed-write cleanup. The supplied exact-head evidence reports 65 focused/sibling tests passing after repairing real authority predicates in the fixtures. (src/agents/subagents/registry/subagent-registry.completion-authority.test.ts:29, 01bfacf84d3d)

Likely related people:

  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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 (5 earlier review cycles)
  • reviewed 2026-09-22T02:02:22.088Z sha db1de7b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-22T02:14:56.047Z sha d224400 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-22T02:32:43.186Z sha d224400 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-22T08:29:35.572Z sha d224400 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-22T14:31:08.225Z sha 01bfacf :: needs maintainer review before merge. :: none

Keep the continuation owner within the line-cap gate after the current-main refresh. Move only unchanged type declarations and type imports into a coherent sibling contract module; runtime behavior is unchanged.

Co-authored-by: jalehman <[email protected]>
@VACInc

VACInc commented Sep 22, 2026

Copy link
Copy Markdown
Member

#154874 has merged, but it does not supersede this PR. #154874 changes Claude CLI completed-reply delivery boundaries; this PR changes the subagent requester-settle wake and completion path. Keep this draft open for independent review; do not close it.

@roboclaw-bot

roboclaw-bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

Real-Gateway proof at d2244005

Verified d2244005a9a5bdf204c5e18e144172d3d1adf088 on a fresh Blacksmith Testbox via Crabbox. The entire remote Git tree matched the published head plus only the uncommitted replay. Production Gateway admission, registered spawn/yield tools, execution settlement, registry, task storage and successor dispatch were unmocked; only the external-auth service and model HTTP/SSE were deterministic fixtures.

Cell Observed result
Normal: parent yielded and execution settled before child response released child completed once; result delivered without restart; exactly one visible PROOF_PARENT_RESULT: PROOF_CHILD_RESULT; 8.166s
tasks.cancel while child held cancelled; cancellation notice delivered; no successful child result; 11.280s
Operator role revoked while child held actor disconnected/child cancelled; cancellation notice delivered; no successful child result; 11.392s
Restart during accepted, held synthesis same retained child result delivered once; child invocation count remained one; 58.145s

Normal parent af7c85ca-bf24-4816-ab51-2db3fa1d7a23, child 9a002853-4cc8-4e77-ba1b-0c7d1837ae2f, task 4225895a-146d-4037-91ad-8f09ef502f3b. All four cases returned agent.wait: {status: "ok", yielded: true} before release. Normal made one child and one synthesis model request.

The BEFORE proof was also reproduced on implementation base 7ad0839 before production edits: retained success result, delivery blocked by inactive operator authority. Its observation-test exit0 did not mean product delivery worked.

Control limits: the repaired restart case interrupts admitted synthesis rather than waiting for the old rejected wake. It emits interruption/failure text, makes three parent-side model requests, and then emits exactly one successful result; this is not interruption-free UX. Cross-source and stale-member negatives reject the continuation callback in registered-boundary tests, not an additional live mixed-principal E2E cell. No claim that every #143334 starvation/restart symptom is fixed.

The same exact-head command passed core typecheck, focused lint (zero warnings/errors), formatting, conflict/line-cap guards, and 479 tests in 16 files / four Vitest shards (86.56s). Fresh independent AutoReview: scoped-clean at P0–P2. Earlier pre-rebase selected gates also covered all25 core-test typecheck graphs; that is historical evidence, not current-head full CI.

Provider run, lease tbx_01m33dy6qtgx64sx7sc82amh4c. Combined command exit0, 696.884s including source build; lease stopped/read back completed02:20:56UTC. All owned leases are stopped. Portal metadata synchronization timed out; the actual command receipt succeeded.

The bundle contains sanitized RPC/task receipts, actual parent text, the replay, command/environment receipts, full-tree equivalence and limitations. Terminal transport interleaved shell trace with dumped JSON; only exact known script trace bytes were removed, and all decoded IDs/task projections/model counts matched independent test summaries.

Download verification: all12 files returned HTTP200 with matching SHA256; remote manifest matched byte-for-byte. Signed artifact links expire 2026-09-29.

CI fixture follow-up — 01bfacf84d3d2fa12f85639cad9895c09e7abb01

The original CI failure reproduced locally: two native-spawn fixture failures, 14 passing tests. Those fixtures claimed real delegated authority but omitted its live receipt predicate when constructing the Gateway caller; the new registration check correctly rejected the incomplete identity. The worker fixture also supplied a no-op receipt callback.

The follow-up changes only the test fixture (+8/−1): carry the real registry-backed predicate and forward the worker callback. Existing successful-launch, token, capability-revalidation and lineage assertions remain unchanged. No production behavior, authorization guard, or timeout changed; main had the same fixture, so no rebase was needed.

65 tests across five focused/sibling files passed, including the originally failing file and pending-preparation/caller-closure controls. All selected check:changed gates passed, including the owning agents-other typecheck, assertion safety, formatting and lint (zero warnings/errors). Fresh independent AutoReview is scoped-clean at P0–P2.

The four-cell real-Gateway proof below remains explicitly bound to d224400, whose production code is byte-identical in this test-only follow-up; it was not rerun or relabeled as a new-head execution. New exact-head CI passed at 14:38:04 UTC. At 14:39 UTC, both the CI check and aggregate openclaw/ci-gate status were SUCCESS, no checks were failed/pending, and GitHub reported OPEN/non-draft/MERGEABLE/CLEAN. Hosted revision-5 review at this same head found no actionable findings and accepted the unchanged-production proof. No merge or deployment was performed.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 22, 2026 02:24
@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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 22, 2026
Carry the real delegated-run receipt predicate through local and worker caller identities. Keep the existing accepted-launch and lineage assertions; do not weaken production admission or replace receipt authority with an unconditional success.

Co-authored-by: jalehman <[email protected]>
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 22, 2026
@jalehman
jalehman merged commit e2e5b0b into main Sep 22, 2026
203 of 204 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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.

3 participants