Repository navigation
fix(subagents): keep delegated tools and results working after yield - #197335
dankarization wants to merge 6 commits into
Conversation
|
🦞👀 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 Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 346eea631c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return method === "agent" | ||
| ? await runWithoutOwnedSessionTranscriptWrites(() => | ||
| runOutsideOperatorToolGatewayAuthority(() => run(resolved)), | ||
| ? await runOutsidePreparedModelRuntimePluginGenerationScope(() => |
There was a problem hiding this comment.
Preserve reload self-hold checks through agent admission
During an external reload of a plugin still retained by the parent turn, sessions_send now loses its self-hold refusal: this helper clears pluginInvocationContext and pluginInstanceInvocation, the two inputs to assertPreparedModelRuntimeAdmissionCanWait(). Child admission can therefore wait for replacement in prepared-reply-dispatch-runtime.ts:150-164 while the non-overlapping reload waits for the parent's retained work in server-plugin-reload.ts:273-289. Because the parent is awaiting this dispatch, the send reaches its timeout instead of returning the refusal consumed by createSelfHeldSendRetainer; longer-lived spawn calls can also exhaust the reload's drain budget. Preserve caller self-hold detection through admission while giving accepted execution its independent plugin scope.
Useful? React with 👍 / 👎.
|
Codex review: needs maintainer review before merge. What this changesGive delegated execution and completion callbacks independent lifetimes while retaining caller authority and original event ownership. Example: A Telegram parent yields while its child prepares QA_CONT8_PHASE1, then sends a follow-up to the same child.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this PR repairs concrete delegated-work lifetime failures, preserves reload self-hold checks, and has no identified correctness blocker. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherIn-process Gateway dispatch admits delegated agent turns; the subagent registry consumes lifecycle events, persists completion, runs cleanup, and wakes the requester. flowchart LR
Parent[Parent turn] --> Dispatch[Gateway dispatch]
Dispatch --> Admission[Runtime admission]
Admission --> Child[Independent child turn]
Child --> Listener[Lifecycle listener]
Listener --> Registry[Subagent registry]
Registry --> Wake[Cleanup and requester wake]
Technical reviewBest possible solution: Use the existing dispatch and lifecycle owners to detach accepted work while preserving live authority, self-hold refusal, and original event ownership. Do we have a high-confidence way to reproduce the issue? Current-main dispatch retains the caller's plugin scope, and the supplied differential listener evidence records terminal persistence failing before the repair; no target code was executed during this review. Is this the best way to solve the issue? The change addresses ownership at the shared dispatch and lifecycle boundaries without weakening closed-scope rejection or adding retry machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dfdad1a806c5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +70, Tests +558, Other +8. Total +636 across 15 files. Added test files: 3. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
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 HistoryReview history (3 earlier review cycles)
Reviewed November 12, 2026, 12:52 AM ET / 05:52 UTC (Revision 4). |
|
The real managed-child output is now inspectable: https://github.com/dankarization/openclaw/blob/89c352896d814290aa8b45b5973c7e4d794af81a/docs/assets/qa/2026-11-11/delegation-after-yield.md Full CI passed for The self-hold admission finding is being repaired with a focused regression. The allowed-child live check is not presented as post-revocation or native-helper proof; those boundaries remain separate. |
|
Our local 2026.11.3 build
Actual child receipts, timing, images and limits. The image URLs above refer to cropped captures of the actual application, not reconstructed messages. These are positive controls for the tested paths. Native helper shell commands are not proof of access to OpenClaw registered host tools. They also do not certify source revocation, every native completion path, or recovery of historical tasks. The native test's first command ran while yield was pending; its second command ran after yield returned. The self-hold admission repair is included in this local build and is being qualified for the next PR revision. A further lifecycle-event repair now passes five real registry/SQLite tests, including stale-owner and stale-generation rejection; it has not yet been deployed. Earlier closed-scope failures in requester settlement and |
Capture the event generation and original run owner before waiting for admission. Reject obsolete events before writes, while retaining later source and ownership checks.
|
Thanks @dankarization for digging into this and for the detailed reports. We tried to reproduce the closed-scope failure on current main (68aff7f) before reviewing the change. Setup: a built Gateway in a secretless container with a stand-in model. The parent spawns a child with
Every run delivered the child's result to the parent exactly once, and "Plugin invocation scope is closed" never appeared. The PR's new tests do fail on main, but only because they build a closed plugin scope by hand or suspend the Gateway while the child is running. We couldn't find a user path that leads to either. Could you share:
Leaving this open for that. |
|
Thanks for running those checks — that helps narrow this down. I agree that the regression tests alone do not establish a normal user path on current main. I went back to the incident report from our running Gateway. The two clearest failures came from an ordinary Telegram conversation: the parent started a The report records Codex for both parent and child, using bundled Codex 0.164.0. This was OpenClaw-managed delegation, not Codex-native I rechecked the Gateway journal. On November 11, UTC+4: There is no guard stack in those journal windows. The reported build was main-derived with our local audio/topic/progress changes, so this is historical evidence, not a clean-main reproduction. I am now building clean main |
|
Thanks @dankarization for the detailed path. We ran it on current main (c686c16): a Telegram DM, with the parent and the child both on Codex. The parent spawns the child and yields. Later it continues the same child with We did find a separate trigger: an isolated cron run whose child owes its result, where the child's model call fails. There, the announce's Do you still lose results on current main? If so, could you share the Gateway log lines around the failure? |
…n already ended (#197658) fix(gateway): run subagent announce Gateway calls outside the finished turn's plugin scope When a child agent failed after its parent's turn had already ended, the completion announce's in-process Gateway calls (chat.history, and the related sessions.delete and chat.abort) ran inside the parent turn's closed plugin invocation scope. The chat.history read asks plugins which harness to use, so it failed with "Subagent announce failed: Plugin invocation scope is closed" and the parent never learned the child had failed. These in-process calls now run outside the closed scope, the same pattern as #196940, and go through normal Gateway admission, so nothing is granted or widened. No text changes. Evidence: a built Gateway in a secretless node:24.22.1 container with a stand-in model, two runs each. With an isolated cron run whose owed child's model call returns HTTP 400, main logged the scope error four times per run and the parent was never woken; with this change there are no scope errors and the parent is woken once with the child's failure. A non-cron failing child behaved the same way. A succeeding child, a fire-and-forget child, a cron run without a spawn and a plain non-cron announce deliver exactly once on both, with no duplicate announce. A closed-scope history read in the existing closed-caller test fails on main, at net 0 test lines. Details: #197658 (comment). Thanks @dankarization for reporting this bug family in #197335. Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks, that distinction helps. I read #197658 and the built-Gateway proof, and I’m taking the merged fix into our operator build. Our older report contains both rejected child tools and failed result delivery. Your Telegram test means I can’t use that report to claim the same loss still happens on current main. My own isolated run stopped at QA auth selection before it could create a child, so it gives no result on the delegation bug either way. I’ll check the failed-child path with the accepted fix. Any remaining tool-side failure needs its own current-main reproduction and a short log excerpt; I’ll keep that separate from the announcement path you’ve fixed. |
|
#197658 is now installed in our operator build. Its added history-read test failed twice on our old code and passed after the accepted fix; the full build and a real request through the new Gateway also passed. Receipt: https://github.com/dankarization/openclaw/blob/b104d5d0209577e3ccdae41a4cda8995d74ed5db/docs/assets/qa/2026-11-12/lifecycle-history-197658-d1e2a89.md I also checked the previous process's five-hour production window: 3,188 journal records, including subagent activity, with none of our old closed-scope, inactive-host or announce-failure signatures. That is encouraging, but it is an operator build with local changes, not the clean-main reproduction you asked for. I do not have a new current-main failure excerpt to offer. So I’m not presenting these results as proof that the broader changes in this PR are needed on current main. Your successful Codex/Telegram test and the narrower accepted fix remain the clearest upstream evidence. |
|
Added a real host-tool test after parent yield against our running patched build. The child itself successfully called registered Gateway tools after the parent yielded, then its completion reached the parent. I read both transcripts; this is not based only on the parent's summary. The installed lifecycle dispatcher and regression file match merged #197658. This owner CLI test complements the earlier Telegram captures; ordinary-user grants and native-helper variants remain separate checks. |
|
A fresh check on our deployed 2026.11.3 operator build Actual timeline and test limits. This used Dashboard-to-Gateway, not a new Telegram capture, and is not a clean-main reproduction of the original failure. The first phase used unsuitable tool aliases; the successful second phase is identified separately. The latest CI checks for this PR's unchanged |
…n already ended (openclaw#197658) fix(gateway): run subagent announce Gateway calls outside the finished turn's plugin scope When a child agent failed after its parent's turn had already ended, the completion announce's in-process Gateway calls (chat.history, and the related sessions.delete and chat.abort) ran inside the parent turn's closed plugin invocation scope. The chat.history read asks plugins which harness to use, so it failed with "Subagent announce failed: Plugin invocation scope is closed" and the parent never learned the child had failed. These in-process calls now run outside the closed scope, the same pattern as openclaw#196940, and go through normal Gateway admission, so nothing is granted or widened. No text changes. Evidence: a built Gateway in a secretless node:24.22.1 container with a stand-in model, two runs each. With an isolated cron run whose owed child's model call returns HTTP 400, main logged the scope error four times per run and the parent was never woken; with this change there are no scope errors and the parent is woken once with the child's failure. A non-cron failing child behaved the same way. A succeeding child, a fire-and-forget child, a cron run without a spawn and a plain non-cron announce deliver exactly once on both, with no duplicate announce. A closed-scope history read in the existing closed-caller test fails on main, at net 0 test lines. Details: openclaw#197658 (comment). Thanks @dankarization for reporting this bug family in openclaw#197335. Co-authored-by: Ayaan Zaidi <[email protected]>
|
I’ve now deployed the integrated 2026.11.3 build with the final #197658 replacement and the final #198022 changes. A fresh live test used Sol as the parent and Terra as an OpenClaw-managed child. The parent called One qualification gap remains: the synthetic child did not discover V13 native-yield proof (local integration)Parent yield completed at 17:11:00.006 UTC. The child command started at 17:11:02.329 UTC and exited 0 at 17:11:14.190 UTC. The child result completed at 17:11:16.585 UTC; the parent automatically resumed at 17:11:22.858 UTC. This proves one synthetic workflow on our local integration only. It does not establish that all lost-child cases are fixed. |


Related: #196199, #190670, #170562, #194024.
What Problem This Solves
Our earlier Gateway logs showed children losing tool access or failing to return results after the parent yielded. Accepted work could still inherit the plugin call that had just ended.
Current-main status: Related fixes #197658 (failed-child announcement) and #197960 (deferred auth refresh) have merged. The maintainer's Telegram test with a Codex parent and child passed on clean main. Our earlier incident came from a locally modified build, and we do not yet have a fresh current-main reproduction of the broader tool-access or result-delivery failure. The evidence below supports the tested boundaries of this patch, not a claim that every related symptom persists on current main.
User Impact
Keep accepted child work, completion cleanup and parent wake running after the originating call ends. The original caller's authority, revocation, reload self-hold and generation checks remain enforced.
Why This Change Was Made
Detach accepted work and queued lifecycle events from the finished invocation. Carry live self-hold facts through admission, then release them. A stale event cannot settle a replacement run.
Evidence
Public revision:
57afbb83cb76d1beb0ce95195ff9200f3d9c34b7.The live checks used our patched operator build. They do not establish that this broader patch is needed on clean current main. The recorded passing run is not a claim that every current check or merge result is green.