Skip to content

fix: keep turns active when sessions_yield has no child - #125850

Merged
steipete merged 4 commits into
mainfrom
steipete/pensive-euclid-9848f9
Aug 18, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/pensive-euclid-9848f9

Conversation

@steipete

@steipete steipete commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Closes #125848

AI-assisted: yes

What Problem This Solves

Fixes an issue where an interactive agent could call sessions_yield without 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_yield now 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_yield after 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_yield is 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: markRequesterTurnYielded returned 0, but sessions_yield still returned status: "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 current main.
  • 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.
  • Fresh Codex autoreview (--mode uncommitted, high reasoning) — clean, no accepted/actionable findings.
  • Isolated live agent proof against the built PR head with environment-only Anthropic credentials: the model called sessions_yield without spawning a child, received one failed tool result, stayed in the same turn, and returned exactly YIELD_REJECTED_CONTINUED plus No pending child completion is owned by this turn. (assistantTurns: 2, toolSummary.calls: 1, toolSummary.failures: 1).
  • The first exact-head CI run correctly exposed two omitted sibling cases: Gateway loopback yield composition and Codex native direct-child retention. The repair now proves both authoritative owners while retaining the zero-child rejection.
  • ClawSweeper's documented-self-yield finding was addressed: a host-identified subagent may still pause itself for plugin-managed external work. The composed-tool boundary regression passes, and the existing registry pause/adopt/announce lifecycle suite remains green.

Production logs established the original execution order: background exec running → unsupported sessions_yield accepted → exec completion wake handled independently → promised continuation not executed. No secrets, private channel identifiers, or transcript content are included here.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 18, 2026 14:30
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added 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. 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. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 18, 2026, 11:23 AM ET / 15:23 UTC.

ClawSweeper review

What this changes

The PR changes sessions_yield to end a turn only after its requester has successfully claimed a completion-bearing child.

Regression provenance

Possible 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
Reviewed head: 1cb1198d29f485d7be8b6a4f2411f09e94e6e24a

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The submitted no-child proof is strong, but the current implementation breaks a documented adjacent lifecycle.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides after-fix live agent output for the rejected no-child path, though the corrected patch should also prove the preserved child self-pause path.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides after-fix live agent output for the rejected no-child path, though the corrected patch should also prove the preserved child self-pause path.
Evidence reviewed 7 items Changed admission check: The new check returns an error before invoking the runtime yield callback whenever the child-claim callback returns false.
Claim only represents requester-owned child completions: The claim filters registry rows by requester session, requester turn, and expectsCompletionMessage; a child waiting on its own external work has no such child row and therefore yields zero matches.
Documented self-yield contract: Current documentation explicitly permits a subagent to yield while it waits for an external job, then be resumed by a plugin follow-up.
Findings 1 actionable finding [P1] Preserve documented child self-yield
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125850-xKAWd6/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.88 kB
[log]
[success] rolldown v1.2.0 Finished in 40.75 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 14.1s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4247ms (slowest: built plugin control-plane loads 3472ms)

OpenClaw 2026.8.1 (1cb1198) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color  
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

OpenClaw exposes sessions_yield from its agent tool set to transfer a turn to a later completion event. The registry records child-completion ownership and separately preserves a yielded child so a plugin follow-up can resume it.

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]
Loading

Before merge

  • Preserve documented child self-yield (P1) - This guard also runs in a child session. A child waiting on an external job has no completion-bearing child of its own, so the registry claim returns zero and the callback that pauses the child never runs. That breaks the documented plugin follow-up flow in docs/tools/subagents.md:319; keep the requester-only rejection while retaining this valid child pause. This concern was missed in the earlier review of the unchanged head.
  • Resolve merge risk (P1) - Merging would prevent a child from pausing for documented external work, leaving its requester unable to receive the intended later plugin continuation.
  • Resolve merge risk (P1) - The exact head has failed CI-gate-related checks in the supplied status context; refresh and inspect those checks after the lifecycle repair before merge.
  • Resolve merge risk (P1) - The bug-fix adds net +10 production lines while narrowing a valid lifecycle; the repair should absorb the distinction at the ownership boundary rather than add another blanket rejection path.
  • Improve patch quality - Preserve subagent self-yield for plugin-managed external work while rejecting invalid requester yields.
  • Improve patch quality - Add a boundary regression for a paused child resumed by its plugin follow-up.
  • Improve patch quality - Refresh the exact-head CI after the repair and inspect the failing gate.

Findings

  • [P1] Preserve documented child self-yield — src/agents/tools/sessions-yield-tool.ts:49-54
Agent review details

Security

None.

PR surface

Source +10, Tests +76. Total +86 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 19 9 +10
Tests 3 85 9 +76
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 104 18 +86

Review metrics

Metric Value Why it matters
Production vs test LOC production +19/-9; tests +85/-9 The net production growth adds a lifecycle admission rule, but the rule currently excludes an established valid state.

Stored data model

Persistent data-model change detected: serialized state: src/agents/tools/sessions-yield-tool.test.ts, serialized state: src/agents/tools/sessions-yield-tool.ts, unknown-data-model-change: src/agents/tools/sessions-yield-tool.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #125848
Summary: This PR is the candidate repair for the reported invalid requester yield; the older handoff PR is adjacent but addresses a different completion timing path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Preserve child self-yield before merge (recommended)
    Refine the ownership gate so requester handoff requires a claimed child while a child session can still pause for plugin-managed external work, with boundary coverage for its later continuation.
  2. Pause this narrowing change
    Do not merge if the intended product direction is to remove child self-yield; that would require an explicit documentation and lifecycle-contract decision.

Technical review

Best 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 sessions_yield from a child that is waiting on external work without spawning its own completion-bearing child; the new claim deterministically returns false before the pause callback runs.

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:

  • [P1] Preserve documented child self-yield — src/agents/tools/sessions-yield-tool.ts:49-54
    This guard also runs in a child session. A child waiting on an external job has no completion-bearing child of its own, so the registry claim returns zero and the callback that pauses the child never runs. That breaks the documented plugin follow-up flow in docs/tools/subagents.md:319; keep the requester-only rejection while retaining this valid child pause. This concern was missed in the earlier review of the unchanged head.
    Confidence: 0.96
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 07a0b5170343.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix live agent output for the rejected no-child path, though the corrected patch should also prove the preserved child self-pause path.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body provides after-fix live agent output for the rejected no-child path, though the corrected patch should also prove the preserved child self-pause path.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The patch would break a documented yielded-subagent continuation workflow and can strand parent work waiting on that child.
  • merge-risk: 🚨 session-state: The changed yield gate alters whether agent and subagent turns enter the persisted paused lifecycle.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body provides after-fix live agent output for the rejected no-child path, though the corrected patch should also prove the preserved child self-pause path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix live agent output for the rejected no-child path, though the corrected patch should also prove the preserved child self-pause path.

Evidence

What I checked:

Likely related people:

  • steipete: Authored this PR and the prior merged requester-handoff repair that owns the adjacent completion-yield lifecycle. (role: recent agent-lifecycle contributor; confidence: high; commits: 1cb1198d29f4, bf2da1ce1af7; files: src/agents/tools/sessions-yield-tool.ts, src/agents/subagents/registry/subagent-registry-requester-yield.ts)
  • wonfong: History identifies a prior yielded-child follow-up repair in the same continuation behavior. (role: adjacent lifecycle contributor; confidence: medium; commits: 9fdc266f6468; files: docs/tools/subagents.md, src/agents/subagents/registry/subagent-registry.test.ts)

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-18T14:39:22.702Z sha 1cb1198 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 18, 2026
@steipete
steipete force-pushed the steipete/pensive-euclid-9848f9 branch from 4ac9ae5 to f8d5857 Compare August 18, 2026 16:58
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for source head 034f32514fafb2c088c9da3e7e9ae79ac52e8e57.

The root cause was lifecycle admission: sessions_yield could end an interactive requester turn without any authoritative spawned-child completion owner, so unrelated async completion could arrive while the promised continuation remained silently stranded. The canonical fix requires one completion owner before ending the turn: an OpenClaw requester-child registry claim, a Codex native direct-child claim, or the documented host-identified subagent self-pause claim. Runtime observational claims run before durable registry mutation. There is no heartbeat/exec fallback, config, protocol, storage, migration, or compatibility shim.

Exact local proof:

  • node scripts/run-vitest.mjs src/agents/openclaw-tools.registration.test.ts src/agents/tools/sessions-yield-tool.test.ts src/agents/agent-tools.runtime.test.ts src/agents/subagents/registry/subagent-registry.test.ts
  • node scripts/run-vitest.mjs src/gateway/tool-resolution.test.ts extensions/codex/src/app-server/run-attempt.native-hook-relay-retention.test.ts
  • Focused total: 263 tests passed across the owner and sibling surfaces.
  • node scripts/check-changed.mjs -- extensions/codex/src/app-server/dynamic-tool-build.ts extensions/codex/src/app-server/native-hook-relay.ts extensions/codex/src/app-server/run-attempt-tool-setup.ts extensions/codex/src/app-server/run-attempt.ts src/agents/agent-tools.runtime.test.ts src/agents/agent-tools.ts src/agents/openclaw-tools.registration.test.ts src/agents/openclaw-tools.requester-yield.ts src/agents/openclaw-tools.ts src/agents/tools/sessions-yield-tool.test.ts src/agents/tools/sessions-yield-tool.ts src/gateway/tool-resolution.test.ts
  • git diff --check
  • Codex autoreview ran in local/uncommitted mode and branch mode against origin/main, with high reasoning; both were clean with no accepted/actionable findings.

Direct Codex contract inspection confirmed that V1 exposes the spawned receiver only on successful completed spawn (../codex/codex-rs/app-server-protocol/src/protocol/event_mapping.rs:78-135) and V2 emits the new child as a started subagent activity (../codex/codex-rs/core/src/tools/handlers/multi_agents_v2/spawn.rs:150-192), with the app-server receiving-child contracts in ../codex/codex-rs/app-server-protocol/src/protocol/v2/item.rs:346-374.

The isolated live proof ran an agent against the built PR head with no spawned child. Its single sessions_yield call returned a failed tool result, the same turn stayed active, and the agent completed with the expected rejection explanation. No secrets or private identifiers are included.

Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/32166459882. OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125850 completed in hosted_exact_or_recent_parent mode on the same SHA. It recorded CI run 32166459882 and Workflow Sanity run 32166459839 (https://github.com/openclaw/openclaw/actions/runs/32166459839); Blacksmith Testbox, ARM Testbox, and Build Artifacts Testbox were not applicable, so no separate Testbox run ID/URL was emitted. The native prepare step is local and emits no separate workflow run ID/URL.

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.

@steipete
steipete merged commit 62b2141 into main Aug 18, 2026
228 checks passed
@steipete
steipete deleted the steipete/pensive-euclid-9848f9 branch August 18, 2026 17:53
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
)

* fix(agents): reject sessions_yield without child completion

* fix(agents): preserve native child yield claims

* chore(agents): keep tool registry within lint limit

* fix(agents): preserve subagent self-yield
etzelm added a commit to etzelm/openclaw that referenced this pull request Sep 13, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex gateway Gateway runtime maintainer Maintainer-authored PR 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sessions_yield can strand unrelated background work without a child

1 participant