Skip to content

fix(agents): settle yielded CLI session spawns - #134974

Merged
VACInc merged 1 commit into
mainfrom
openclaw/openclaw-openclaw-vacinc-issue-124343
Sep 1, 2026
Merged

VACInc merged 1 commit into
mainfrom
openclaw/openclaw-openclaw-vacinc-issue-124343

Conversation

@roboclaw-bot

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

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes #124343.

A CLI requester can accept a completion-required child through sessions_spawn, call sessions_yield, and release its turn without carrying the accepted spawn receipt into requester settlement. The child can then complete successfully while direct delivery and wake scheduling both defer forever to settlement state that was never armed.

Why This Change Was Made

The repair carries verified accepted spawn receipts through CLI and Copilot harness results, then settles yielded CLI requester ownership only after the placement claim releases. Existing embedded/native continuation policy remains unchanged. A small forced-terminal context split keeps the placement owner registry-agnostic and removes the resulting runtime import cycle.

The final regression pass also found the matching pre-delivery race: when the child already delivered the requester-visible final before parent settlement, its provisional settle wake remained armed. The registry owner now clears that wake only when the exact delivered-final receipt proves the yielded batch already completed, preventing replay while preserving incomplete and mismatched wakes.

This reuses the canonical settleRequesterAfterSessionSpawns owner instead of adding a second delivery path. No config, protocol, database schema, migration, or fallback is added.

Production delta: +122/-43 (net +79). The growth adds the missing accepted-spawn capability across CLI/Copilot result boundaries, placement-release settlement, the cycle-safe forced-terminal context split, and the owner-side stale-wake cleanup. Tests are +256/-100 (net +156).

User Impact

Requester turns that yield after spawning completion-required children now arm the existing durable settle-wake flow instead of leaving completed child results parked with completion_handoff_pending and no retry. A child that already delivered through the requester turn is not replayed after that turn settles.

Evidence

  • node scripts/run-vitest.mjs src/agents/cli-runner.reliability.test.ts src/agents/subagents/registry/subagent-registry-requester-yield.test.ts — 123 tests passed after the clean rebase, including accepted/rejected/malformed CLI receipt cases and owner stale-wake cleanup.
  • AWS Crabbox run run_6a1dbff58195: node scripts/run-vitest.mjs src/agents/subagents/registry/subagent-registry.lifecycle-retry-grace.e2e.test.ts — 14 tests passed across yielded delivery, pre-delivered no-replay, sibling-race settlement, retry grace, and completion freezing; lease stopped afterward.
  • node scripts/check-changed.mjs -- src/agents/subagents/registry/subagent-registry-requester-yield.ts src/agents/subagents/registry/subagent-registry-requester-yield.test.ts src/agents/subagents/registry/subagent-registry.lifecycle-retry-grace.e2e.test.ts — green, including core/test typecheck, lint, dead-code, database guards, and zero runtime import cycles.
  • Structured autoreview over the complete PR plus final regressions — no accepted/actionable findings.
  • Exact-head CI run 33511228326 — 268 checks, zero pending or failed.

Telegram Test Server proof remains unavailable because this host has neither an authenticated Convex CLI nor the CI broker environment pair; no credentials were requested or bypassed. The isolated production-composition E2E above supplies the requested settlement-to-delivery boundary trace.

ClawSweeper exact-head review was requested three times after the final push. Each fresh lease failed in ClawSweeper’s internal Codex execution layer before publishing a verdict or technical finding; runs 33512292248, 33512885800, and 33513430055. The earlier reviewed head had no code findings and requested the boundary trace now supplied above.

This PR must not be merged or placed on automerge by this session.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling extensions: copilot size: M labels Sep 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Sep 1, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 1, 2026 07:38
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-openclaw-vacinc-issue-124343 branch from 39c629f to e1758c2 Compare September 1, 2026 08:18
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Verification update for exact head e1758c2957565cc9900fd16820ef84a0977fb1c2:

  • Reproduced the first CI failure locally: all 8 failures in lane-controller.queue-liveness.test.ts came from legacy {} as EmbeddedAgentRunResult fixtures now crossing the placement result boundary.
  • Replaced those impossible casts with one valid minimal result fixture; no production guard or runtime fallback was added.
  • Focused proof: node scripts/run-vitest.mjs src/agents/cli-runner.reliability.test.ts src/agents/session-placement-admission.test.ts src/agents/embedded-agent-runner/run/lane-controller.queue-liveness.test.ts extensions/copilot/src/attempt.test.ts — 286 tests passed.
  • Changed-test gate: node scripts/check-changed.mjs -- src/agents/embedded-agent-runner/run/lane-controller.queue-liveness.test.ts — passed.
  • Complete candidate autoreview: clean, no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/33486383223

Live Telegram Test Server proof remains unavailable on this host: the telegram-e2e-userbot prerequisite check found neither an authenticated Convex CLI nor the CI broker environment pair, so no team credential lease can be acquired. I did not request credentials in chat or bypass the broker. The focused boundary tests above are not represented as live proof.

@clawsweeper clawsweeper Bot added 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 Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 10:59 AM ET / 14:59 UTC.

ClawSweeper review

What this changes

The branch captures accepted subagent spawns from CLI tool execution and settles yielded requester turns so completed child work can be scheduled for requester delivery.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The PR remains necessary: current main still lacks CLI accepted-spawn capture and post-placement settlement. The patch follows the existing registry-owned settlement path with targeted boundary coverage; it should receive designated owner review before merge.

Priority: P1
Reviewed head: 37ab2e56bfd1063072e0786b4020a13b08f59b0d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch uses the existing registry owner with targeted capture, settlement, and race coverage; designated-owner review is appropriate for delivery-sensitive behavior.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository metadata identifies the bot PR author as a member, so the external-contributor proof gate does not apply; the added registry and mocked-gateway lifecycle evidence remains supplemental boundary coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository metadata identifies the bot PR author as a member, so the external-contributor proof gate does not apply; the added registry and mocked-gateway lifecycle evidence remains supplemental boundary coverage.
Evidence reviewed 6 items Current-main gap: Current main tracks messaging results but does not retain accepted sessions_spawn results or attach them to CLI output; its local placement wrapper returns directly without requester settlement.
Canonical receipt normalization: The branch accepts only completed, accepted spawn results with both run and child-session identities, preserving whether the child owns a completion message.
Settlement owner and ordering: The new wrapper calls the existing registry settlement owner only after local placement execution returns; the focused test asserts claim, turn, release, then settlement.
Findings None None.
Security None None.

How this fits together

CLI and Copilot agent turns can spawn visible subagents whose completed work is handed back through the subagent registry to the requester session. This change records accepted spawn receipts at the tool boundary and uses them after a yielded turn releases placement.

flowchart LR
  A[CLI or Copilot turn] --> B[Session spawn tool]
  B --> C[Accepted spawn receipt]
  C --> D[Turn settlement]
  D --> E[Subagent registry]
  E --> F[Requester wake]
  F --> G[Completion delivery]
Loading

Decision needed

Question Recommendation
Should the repository accept the CLI/Copilot receipt-and-settlement change as the canonical repair for yielded requester completions? Accept canonical settlement repair: Merge after the designated owner confirms exact receipt matching and requester-wake scheduling cover supported CLI paths.

Why: The change alters durable session settlement and final-delivery scheduling across execution surfaces, requiring designated owner merge judgment.

Before merge

  • Resolve merge risk (P1) - The production +79-line repair crosses CLI/Copilot result boundaries and durable requester settlement. Exact receipt guards and lifecycle suites mitigate replay and loss, but an agent/gateway owner should review the scheduling semantics before merge.
  • Complete next step (P2) - The needed repair is already present in this open protected maintainer PR; route it to the designated owner rather than opening duplicate fix work.
Agent review details

Security

None.

PR surface

Source +79, Tests +156. Total +235 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 14 122 43 +79
Tests 7 256 100 +156
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 378 143 +235

Review metrics

Metric Value Why it matters
Production vs test LOC production +79, tests +156 The P1 repair adds receipt propagation and post-placement settlement across CLI/Copilot boundaries, with coverage for capture, release ordering, replay prevention, and lifecycle races.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #124343
Summary: This PR explicitly targets the linked yielded-requester completion-delivery defect and changes its missing CLI settlement boundary.

Members:

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

Merge-risk options

Maintainer options:

  1. Owner-confirm settlement semantics (recommended)
    Merge after an agent/gateway owner confirms that receipt matching and durable requester settlement retain intended CLI behavior.
  2. Pause for live-route proof
    Leave the PR open if an owner requires a real gateway or channel delivery trace in addition to the maintained boundary tests.

Technical review

Best possible solution:

Have the designated owner confirm supported CLI settlement and requester-wake semantics, then merge the registry-based repair.

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

Yes, from source: current main lacks CLI accepted-spawn receipt propagation and post-placement settlement; the linked issue also provides a live gateway reproduction, though this read-only review did not rerun it.

Is this the best way to solve the issue?

Yes: the branch captures authoritative accepted receipts at the CLI loopback boundary and delegates settlement to the existing registry owner, matching the embedded-run path instead of adding a fallback delivery path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Without this repair, completed visible subagent work can remain undelivered to the requester indefinitely.
  • merge-risk: 🚨 session-state: The branch changes durable requester-turn settlement after a yielded session-spawn turn.
  • merge-risk: 🚨 message-delivery: Receipt matching and wake clearing determine whether a completed child final is scheduled or replayed.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository metadata identifies the bot PR author as a member, so the external-contributor proof gate does not apply; the added registry and mocked-gateway lifecycle evidence remains supplemental boundary coverage.

Evidence

What I checked:

Likely related people:

  • VACInc: 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 (2 earlier review cycles)
  • reviewed 2026-09-01T08:25:56.426Z sha e1758c2 :: needs maintainer review before merge. :: none
  • reviewed September 1, 2026, 4:38 AM ET / 08:38 UTC sha unknown :: needs maintainer review before merge. :: none

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Final exact-head verification for e1758c2957565cc9900fd16820ef84a0977fb1c2:

  • Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/33486383223 (pending=0; repository watcher reported GREEN).
  • ClawSweeper reviewed this exact head with no actionable findings: fix(agents): settle yielded CLI session spawns #134974 (comment).
  • ClawSweeper's optional Rank-up moves item requests an isolated gateway delivery trace. Skipped for this PR because the required telegram-e2e-userbot Test Server lease cannot be acquired on this host: neither an authenticated Convex CLI nor the CI broker environment pair is available. The focused boundary proof and this exact blocker are recorded above; no credentials were requested in chat and no broker bypass was used.
  • Focused local proof: 286 tests passed across CLI receipt projection, placement-release ordering, queue liveness, and Copilot telemetry. The changed-test gate and complete candidate autoreview were clean.

VACInc remains the intended assignee/co-author. This PR is ready for maintainer review; it has not been merged and automerge remains disabled.

@clawsweeper clawsweeper Bot added 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 Sep 1, 2026
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/openclaw-openclaw-vacinc-issue-124343 branch from e1758c2 to 37ab2e5 Compare September 1, 2026 13:04
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Follow-up for VACInc’s 2026-09-01 regression-coverage request, on exact head 37ab2e56bfd1063072e0786b4020a13b08f59b0d:

  • CLI loopback coverage now proves an accepted sessions_spawn receipt survives alongside sessions_yield; rejected and malformed accepted results are not retained.
  • The lifecycle E2E now crosses the production composition from yielded CLI placement release into registry settlement and actual requester delivery.
  • It proves exactly-once delivery for a completed child, no replay when the requester-owned final was already delivered before yield, and batch ownership when sibling deliveries race.
  • The owner unit reproduces and fixes the stale provisional requesterSettleWake: a matching delivered-final receipt clears that wake during requester settlement, while mismatched, incomplete, or running states remain armed.
  • Existing registry suites continue to cover batch re-arming, restart recovery, and multi-child coalescing; the new E2E composes those owner behaviors with the CLI boundary rather than replacing them.

Proof:

  • node scripts/run-vitest.mjs src/agents/cli-runner.reliability.test.ts src/agents/subagents/registry/subagent-registry-requester-yield.test.ts — 123 passed after the clean rebase.
  • node scripts/check-changed.mjs -- src/agents/subagents/registry/subagent-registry-requester-yield.ts src/agents/subagents/registry/subagent-registry-requester-yield.test.ts src/agents/subagents/registry/subagent-registry.lifecycle-retry-grace.e2e.test.ts — green, including core/test typecheck, lint, dead-code, database guards, and zero runtime import cycles.
  • AWS Crabbox cbx_0225494134a1, run run_6a1dbff58195: node scripts/run-vitest.mjs src/agents/subagents/registry/subagent-registry.lifecycle-retry-grace.e2e.test.ts — 14 passed; lease stopped after proof.
  • Fresh structured autoreview: no accepted/actionable findings.

The clean one-commit rebase did not conflict or change the task patch. A local post-rebase E2E attempt did not reach Vitest because this linked worktree resolves another checkout’s stale @openclaw/ai dist; the post-rebase unit suites are green and exact-head CI is running at https://github.com/openclaw/openclaw/actions/runs/33511228326.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@VACInc
VACInc merged commit 10b2956 into main Sep 1, 2026
274 checks passed
@VACInc
VACInc deleted the openclaw/openclaw-openclaw-vacinc-issue-124343 branch September 1, 2026 17:59
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: copilot gateway Gateway runtime 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

[Bug]: yield-owned settle-wake parks a completed subagent forever — no delivery, no retry, no recorded reason

2 participants