Repository navigation
fix: keep turns active when sessions_yield has no child - #125850
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 18, 2026, 11:23 AM ET / 15:23 UTC. ClawSweeper reviewWhat this changesThe PR changes Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readiness⛔ Blocked by patch quality or review findings - 7 items remain Keep open: the patch fixes the no-child requester case, but it also rejects the documented subagent self-yield flow for external work, so it is not safe to merge unchanged. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherOpenClaw exposes flowchart LR
A[Agent turn] --> B[sessions_yield request]
B --> C{Requester owns child completion?}
C -->|Yes| D[Record child ownership]
D --> E[End turn and wake on completion]
C -->|No| F{Child waiting for external work?}
F -->|Yes| G[Pause child for plugin follow-up]
F -->|No| H[Return actionable error and keep turn active]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +10, Tests +76. Total +86 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Reject only top-level requester yields with no claimed completion child, while preserving a running child’s documented self-pause for plugin-managed external work and proving both paths. Do we have a high-confidence way to reproduce the issue? Yes—invoke Is this the best way to solve the issue? No—the patch correctly protects the reported requester case but conflates it with the documented child self-pause lifecycle; the ownership decision must distinguish those two states. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 07a0b5170343. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
4ac9ae5 to
f8d5857
Compare
|
Land-ready proof for source head 034f32514fafb2c088c9da3e7e9ae79ac52e8e57. The root cause was lifecycle admission: Exact local proof:
Direct Codex contract inspection confirmed that V1 exposes the spawned receiver only on successful completed spawn ( The isolated live proof ran an agent against the built PR head with no spawned child. Its single Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/32166459882. Production LOC: +53/-19 (net +34) | Tests: +227/-30. The production growth is the single canonical multi-runtime ownership boundary. All seven latest completed ClawSweeper rank-up moves were applied: documented child self-yield is preserved; session-state merge risk is resolved; exact-head CI is refreshed; positive LOC is justified by the canonical boundary; the owner distinction is implemented; composed self-yield plus paused/adopted/announce lifecycle regressions are covered; and the exact-head gate was inspected green. Per policy, this fresh review needs no re-review request. Proof gap: there was no production Molty redeploy/replay before merge. The isolated live agent and owner-boundary tests above were used instead; this comment does not claim production replay evidence. |
|
Merged via squash.
|
…nts_wait forever - Reject sessions_yield from a Swarm collector turn before any claim source runs, so no durable yield intent is recorded against a child row, and return a diagnostic telling the model to finish the turn so its collected result is recorded for whoever waits on the run. This admission layer only sees turns whose tool factory is given collector context. - Settle a yielded terminal for a run with collect === true as an ordinary ok terminal on both the lifecycle-event path and the agent.wait observer path. A collector is read by an explicit wait and never receives a requester continuation, so a parked collector row has no wake source at all and its waiter blocks until the operator gives up. - Keep a result the collector already captured through structured_output; a collector that captured nothing keeps the existing "structured_output was not called" diagnostic instead of having a valid result overwritten. - Settle as ok rather than a cancellation: a yielded terminal can also look aborted, and any other settlement would reintroduce the false cancellation notice from openclaw#92448. - Leave every non-collector yielded terminal on the shipped markSubagentRunPausedAfterYield path. The documented sub-agent self-yield-for-external-work contract preserved in openclaw#125850 is unchanged; openclaw#141474 carries clawsweeper:needs-product-decision for that arm. - Write no pauseReason on the settle path, so downstream pauseReason === "sessions_yield" guards, openclaw#146248 retention, and the paused-run adoption added by openclaw#146667 are untouched: they select paused rows, which a settled collector never becomes. - Document the collector rule in the sessions_yield and Swarm docs, qualified to demonstrated behavior rather than universal tool hiding: the tool is withheld where collector context reaches the tool factory, such as the embedded runner; a CLI-backed collector turn through the Gateway tool resolver can still be offered it and receive a successful yielded result; and in every case the terminal settle is what resolves the waiter. - Repoint the yielded-continuation reset case added by openclaw#146565 at an ordinary announcing sub-agent fixture, with every assertion unchanged, because a yielded collector is now settled at its terminal and is no longer a continuation to preserve. Add a sibling case pinning that contract: a yielded collector completes with no pauseReason and a frozen collectorCompletion, and sessions.reset then revokes its cleanup as a completed run. - Await the durable cleanup mark of the settled collector in that reset case, not the residual-roots deadline. Its cleanup: "delete" work is dispatched detached and takes 0.5 s to 3.9 s locally depending on whether the SQLite reclamation worker starts cold, so the one-second vi.waitFor inside settleSubagentRegistryPersistenceWork could observe a live registry root under CI load. The guard and every assertion are unchanged. Related: openclaw#141474
Closes #125848
AI-assisted: yes
What Problem This Solves
Fixes an issue where an interactive agent could call
sessions_yieldwithout owning any pending spawned-child completion, ending the turn and abandoning promised follow-up work behind an unrelated async completion event.Why This Change Was Made
sessions_yieldnow requires an explicit completion-ownership claim before the runtime may abort the requester turn. The claim composes the durable OpenClaw subagent registry with side-effect-free runtime owners such as Codex native direct children. Runtime claims run before durable registry mutation, so a runtime failure cannot record a yield that never happens.A missing or zero-child claim returns an actionable tool error and keeps the turn active. Valid OpenClaw child yields, Codex-native child yields, persistence failures, acknowledgments, relay retention/revocation, heartbeat handling, and background-command completion policy remain intact.
This repairs the lifecycle owner rather than teaching exec-event heartbeats to recover an invalid yield.
User Impact
Agents that accidentally call
sessions_yieldafter unrelated background work now remain active and can finish or wait for that work normally. Valid subagent fan-out across the embedded and Codex runtimes continues to pause and resume as before.Release-note context: prevent successful async work from becoming silently stranded when
sessions_yieldis called without a pending child completion.Production LOC: +53/-19 (net +34) | Tests: +227/-30. The production growth adds one canonical multi-runtime completion-claim boundary; no fallback path, config, protocol, storage, or compatibility shim was added.
Evidence
Before the production change, the composed-tool regression failed as intended:
markRequesterTurnYieldedreturned0, butsessions_yieldstill returnedstatus: "yielded"and invoked the runtime yield callback.After the change:
node scripts/run-vitest.mjs src/gateway/tool-resolution.test.ts extensions/codex/src/app-server/run-attempt.native-hook-relay-retention.test.ts src/agents/tools/sessions-yield-tool.test.ts src/agents/openclaw-tools.registration.test.ts src/agents/agent-tools.runtime.test.ts— 111 tests passed across 4 shards after rebasing onto currentmain.node scripts/check-changed.mjs -- <all touched paths>— passed (core,coreTests,extensions,extensionTests), including typecheck, lint, import-cycle, plugin-boundary, and database-first guards.git diff --check— passed.--mode uncommitted, high reasoning) — clean, no accepted/actionable findings.sessions_yieldwithout spawning a child, received one failed tool result, stayed in the same turn, and returned exactlyYIELD_REJECTED_CONTINUEDplusNo pending child completion is owned by this turn.(assistantTurns: 2,toolSummary.calls: 1,toolSummary.failures: 1).Production logs established the original execution order: background exec running → unsupported
sessions_yieldaccepted → exec completion wake handled independently → promised continuation not executed. No secrets, private channel identifiers, or transcript content are included here.