Skip to content

fix(cron): automation runs fail after sessions_yield on a spawned subagent - #197667

Merged
jalehman merged 1 commit into
mainfrom
fix/automation-yield-settlement
Nov 12, 2026
Merged

jalehman merged 1 commit into
mainfrom
fix/automation-yield-settlement

Conversation

@jalehman

@jalehman jalehman commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: an automation run fails with accepted continuation children could not transfer terminal delivery when it spawns a subagent and then calls sessions_yield.

User Impact

Automations that delegate to a subagent and then yield now finish successfully, in both isolated and in-session placements. Today these runs are recorded as failed even though the subagent completes, and the failure counts toward the job's error backoff and failure alerts. Ordinary chat yields are unchanged.

Why This Change Was Made

This is a regression from #185445. That change made an automation's sessions_yield end the turn with a scheduler-owned yielded result instead of an error. The path intentionally doesn't mark the turn's children as yielded, because the scheduler (not an interactive requester continuation) owns child output. But the run still reported meta.yielded, so settleRequesterRun asked the registry to transfer the children to a yielded continuation. The registry refuses that for unmarked children (the default expectsCompletionMessage: true spawn), and the run threw.

The scheduler-owned check (a cron run session key, or a scheduled placement on the run) is now one shared predicate, used by both the yield tool and settlement. Settlement treats a scheduler-owned yield as an ordinary turn end, the same path a non-yielding automation that spawned the same children already takes. Child completion delivery is unchanged: isolated runs collect the child's answer through the handoff from #197695, and in-session runs deliver it into their session as before.

#185445's tests missed this because its scheduler delivery fixture used a child with completion.required: false, which never reaches the refusing check.

Evidence

Live runs on isolated Gateways on an AWS Crabbox lease, with a real model (clawrouter/anthropic/claude-opus-5-5) and synthetic data. Each automation spawns one subagent that replies PINEAPPLE-42, then (except the control) yields; triggered with cron.run mode: "force". PR head a0433a71 vs base main 5cef30a3, run sequentially:

Placement Case Run result Child result
isolated main, spawn then yield error: accepted continuation children could not transfer terminal delivery finished, never reached the run
isolated this PR, spawn then yield ok in 8.8 s, summary PINEAPPLE-42 collected by the run
isolated this PR, no yield (control) ok in 6.6 s, summary SPAWNED same handoff as before
in-session (session:agent:main:main) main, spawn then yield error: Session event execution failed (Embedded agent failed before reply: accepted continuation children could not transfer terminal delivery) delivered to the session
in-session this PR, spawn then yield ok in 7.9 s delivered into agent:main:main
  • Regression test: openclaw-tools.requester-yield.test.ts yields through the real tool, then runs real settlement against the real registry, for a cron-run session and an in-session automation (scheduled placement bound to the run). The child is released to ordinary delivery. Both cases fail on main with the exact error.
  • Focused suites pass: requester-yield, requester settlement, subagent announce delivery, cron/session-run, and cron automation-yield delivery.
  • pnpm tsgo:core, pnpm tsgo:test:src, oxlint, oxfmt and the test-lines ratchet pass.

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Treat scheduler-owned yields as ordinary turn settlement while preserving existing child delivery.

Example: An automation spawns a child returning PINEAPPLE-42 and calls sessions_yield.

  • Before: The run fails with accepted continuation children could not transfer terminal delivery.
  • After: The run finishes successfully, with isolated runs collecting the answer and in-session runs retaining ordinary child delivery.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused, useful production repair with current-head behavioral evidence and successful CI; the earlier P1 blocker is resolved and the remaining fixture concern is optional.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The current-head PR body records isolated Gateway runs with a real model through cron.run: both isolated and in-session spawn-then-yield cases change from settlement errors to successful runs, with child output collected or delivered respectively; a non-yielding control retains its behavior.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Automations that delegate and yield are recorded as failed despite their children completing.
Reason: This restores the documented automation-yield contract with a focused correction and no new configuration or delivery mechanism.

Regression provenance

Regression provenance — verified: source commit 71e2f57f04e5 by Peter Steinberger; canonical PR #185445 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

This PR fixes a current automation settlement regression and resolves the earlier child-delivery blocker; one non-blocking test-fixture concern remains.

Priority: P1
Reviewed head: a0433a712d1a1b427cae9b0c1236cba4fc0694fd

Before merge

None.

Findings

  • [P3] Construct a valid scheduled context in the regression fixture — src/agents/openclaw-tools.requester-yield.test.ts:467-473
Agent review details

How this fits together

The requester settlement owner receives agent results and accepted child receipts, then releases child completion obligations through the subagent registry.

flowchart TD
 A[Scheduled automation] --> B[Spawn child]
 B --> C[Sessions yield]
 C --> D[Requester settlement]
 D --> E[Subagent registry]
 E --> F[Existing completion delivery]
Loading

Technical review

Best possible solution:

Keep the shared scheduler classification in the existing settlement owner, with an optionally fully typed regression fixture.

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

Current-main source establishes the mismatch between scheduler-owned yield and registry continuation requirements; the contributor also records matching base failures through cron.run.

Is this the best way to solve the issue?

The production change repairs the shared settlement decision directly and preserves ordinary interactive yields and existing delivery owners.

Full review comments:

  • [P3] Construct a valid scheduled context in the regression fixture — src/agents/openclaw-tools.requester-yield.test.ts:467-473
    The in-session fixture omits required ScheduledExecutionContext fields, including assertCurrent, and forces the object through as unknown as ScheduledExecutionContext. This bypasses the real-type guidance in AGENTS.md and pr-simplify and passes an invalid context to the production registry. Build valid execution facts and provide the required assertion, using an annotation or satisfies instead. This is non-blocking test cleanup. I missed it in the earlier review: GitHub's earlier-head blob confirms the same fixture was already present at bba66bd.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is correct
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 71e2f57 adds src/agents/openclaw-tools.requester-yield.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 71e2f57f04e5; files: src/agents/openclaw-tools.requester-yield.ts)
  • Josh Lehman: Raw commit 543c92b adds src/agents/openclaw-tools.requester-yield.ts:38 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 543c92ba688e; files: src/agents/openclaw-tools.requester-yield.ts)

PR surface

Source +17, Tests +60. Total +77 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 23 6 +17
Tests 1 76 16 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 99 22 +77

Preflight source

Source 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

Metric Value Why it matters
Production versus test changes Production +23/-6; tests +76/-16 The modest production growth shares one existing decision; the regression covers the distinct cron-session and scheduled in-session detection paths.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Delegating automations currently fail during settlement despite completed child work, affecting job backoff and failure alerts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T09:32:51.338Z sha 539fc25 :: needs maintainer review before merge. :: [P3] Remove the model-review attribution from the PR body
  • reviewed 2026-11-12T15:18:29.071Z sha bba66bd :: needs changes before merge. :: [P1] Preserve child delivery for in-session automation yields

Reviewed November 12, 2026, 10:51 AM ET / 15:51 UTC (Revision 3).

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 12, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@jalehman
jalehman force-pushed the fix/automation-yield-settlement branch from bba66bd to a0433a7 Compare November 12, 2026 15:30
@jalehman

Copy link
Copy Markdown
Contributor Author

Addressed the review of bba66bd5:

  • In-session delivery (P1): removed the scheduler handoff map. fix(cron): a cron run that hands off to a child times out even when the child answers in seconds #197695 already covers the isolated-cron handoff, so this PR is now only the settlement correction, rebased onto current main. In-session children keep their ordinary delivery. The live in-session run on the new head shows the child's result delivered into agent:main:main, and the run ends ok. On main, the same run fails with the settlement error.
  • Low-value test: removed subagent-registry-lifecycle.scheduler-handoff.test.ts along with the map. The remaining regression runs the real yield tool and real settlement against the real registry.
  • End-to-end proof: the PR body has the isolated and in-session results for the current head.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@jalehman
jalehman merged commit b461970 into main Nov 12, 2026
147 of 148 checks passed
@jalehman
jalehman deleted the fix/automation-yield-settlement branch November 12, 2026 16:03
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…wned helper (openclaw#197667)

(cherry picked from commit b461970)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f71e56c4e01d2f17905fd51bb581222c7b89820f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant