Skip to content

fix(agents): avoid yield failures in automation turns - #185445

Merged
steipete merged 4 commits into
mainfrom
codex/automation-yield-ends-turn
Oct 27, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/automation-yield-ends-turn

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Peter asked “wth is yield failed” after a scheduled automation called sessions_yield while waiting for a publisher child. The tool returned Automation turns cannot use sessions_yield because no requester continuation is available and told the model to finish the turn so the scheduler could handle child output. That normal handoff appeared as a red failure row.

User Impact

Automation calls now return status: "yielded" and end through the ordinary yield callback, without another model request. The scheduler keeps delivering child output under the job's delivery policy. Ordinary user yields, collector final-result requirements, and deferral for unobserved asynchronous tool results remain intact.

Why This Change Was Made

The yield owner returns a scheduler-owned outcome before registering interactive claims. The obsolete tool filter is removed from all three internal tool surfaces, keeping the session catalog uniform. Parents needing synthesis retain collect=true / agents_wait guidance even when yield is exposed. The unattended-run message explains the end-turn contract for all automation placements, including an existing session, without changing that session's system prompt or tools.

The focused scheduler proof uses existing fixtures and a synthetic channel adapter: a child completes after yield, none retains the result without sending, and announce delivers exactly once. The double-announce test file is unchanged. New collection-guidance cases live in the delegation owner test; system-prompt.test.ts remains net zero lines. Documentation describes when to collect results before ending the turn.

No config, dependency, version, persisted-shape, migration, or deployment changes. No live Gateway or real user state was used. Ending without pending children is accepted; parents needing synthesis must collect before yielding.

Evidence

  • Base e93a1b0d1370941e0b016d4c0455d8efeb2a5a51: the actual embedded Agent automation regression failed with expected yielded, received error; eight existing cases passed. With the fix, the turn ends after one model request.
  • Focused proof after the collection-guidance repair: 8 files / 180 tests passed, including embedded Agent/runtime settlement, ordinary user yield, admitted embedded/CLI placements, scheduler delivery, rendered prompts, and all 13 prefix-stability cases. Command: node scripts/run-vitest.mjs src/agents/delegation-guidance.test.ts src/agents/system-prompt.test.ts src/agents/embedded-agent-runner/run/attempt.sessions-yield.test.ts src/agents/openclaw-tools.requester-yield.test.ts src/cron/execution-context-tool-policy.test.ts src/cron/isolated-agent/delivery-dispatch.automation-yield.test.ts src/agents/tools/sessions-yield-tool.test.ts src/agents/agent-tools.prefix-stability.test.ts --maxWorkers=1.
  • Both review regressions were reproduced through their production owners before repair: cron collection guidance was absent when yield was exposed; an existing-session automation message lacked the end-turn/collection instructions.
  • Final affected-owner rerun: node scripts/run-vitest.mjs src/cron/run-prompt.test.ts src/cron/session-run.test.ts src/agents/agent-tools.prefix-stability.test.ts --maxWorkers=1 PASS: 3 files / 29 tests, including all 13 prefix-stability cases, on 35634ac39a126308cd3b5c8c7bef7723a2821799. Fresh P1 Codex branch review is scoped-clean with no actionable P0/P1 findings. Exact-head CI is green: both required openclaw/ci-gate checks are SUCCESS (CI run 40457415786).
  • Production and affected test type checks passed. Formatting, unchanged line-cap ratchet, and git diff --check pass. Earlier targeted lint passed; the later local lint preparation timed out generating plugin-sdk declarations before lint ran. The required exact-head CI gates pass on the final head, covering lint and type validation. The local preparation timeout is retained as a local proof limitation.
  • Initial CI found stale generated prompt-description bytes. Reproduced locally, regenerated only the three affected artifacts and derived counts/hashes, and node --import ./scripts/tsx.mjs scripts/generate-prompt-snapshots.ts --check passed: Prompt snapshots are current (6 files). No budget, baseline, or ratchet changes.
  • Local startup was slow on the shared host; the 180-test wrapper took 1256.14 seconds, while the new rendered-guidance regression ran in 14 ms. The first focused delivery run executed its two cases in 3.396 seconds. No limits were raised.

Change size: 19 files, +287/-89 (net +198). Production: +38/-46 (net -8); tests including generated fixtures: +240/-43 (net +197); docs: +9.

@clawsweeper

clawsweeper Bot commented Oct 27, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 27, 2026
@steipete
steipete marked this pull request as ready for review October 27, 2026 04:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T05:51:23.808392Z 35634ac New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 691f47a563

ℹ️ 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".

Comment thread src/agents/agent-tools.ts Resolved
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR lets automation turns end through sessions_yield while the scheduler retains responsibility for child-output delivery.

Example: Scheduled job yield-job calls sessions_yield while handing off a publisher child.

  • Before: The tool returns an error saying automation turns cannot yield.
  • After: The tool returns status yielded and ends the model turn without registering an interactive continuation.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful, focused direction with repaired collection guidance, but an existing P2 lifecycle defect still blocks merge.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises the embedded attempt and scheduler delivery in process, with synthetic model and channel boundaries.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A normal scheduled child-output handoff appears as a failed yield action.
Reason: The maintainer-authored direction removes a misleading failure without adding configuration or changing scheduler delivery ownership.

Merge readiness

⛔ Needs changes before merge - 1 item remains

The collection-guidance repairs are present, but the previously reported terminal-finalization defect remains and needs repair before merge.

Priority: P2
Reviewed head: 35634ac39a126308cd3b5c8c7bef7723a2821799

Before merge

  • Carry scheduler-owned completion through terminal finalization (P2) - The earlier P2 finding remains unresolved. An automation calling sessions_yield with no acknowledgment, accepted spawn, delivery, or other continuation evidence now succeeds, including the no-child case explicitly accepted by this PR. However, schedulerOwned is consumed only for the tool-result note: onYield and attempt state retain no scheduler-owned completion fact. Outer finalization consequently reaches terminal-resolution.ts:611 and emits “⚠️ Turn yielded without a continuation source. Send a message to resume.” This replaces the original misleading failure with another incorrect recovery instruction even though the automation is intentionally finished. Propagate the outcome through the existing lifecycle and cover the empty case through full runner finalization; retain the diagnostic for unsupported interactive yields.

Findings

  • [P2] Carry scheduler-owned completion through terminal finalization — src/agents/openclaw-tools.requester-yield.ts:40

Tests

  • Missing end-to-end proof: The added empty-automation regression stops at runEmbeddedAttempt and does not exercise the outer finalization that emits the remaining diagnostic.
Agent review details

How this fits together

Scheduled jobs enter the agent runtime with automation context; the yield tool ends model execution, and runner finalization prepares output for scheduler delivery.

flowchart TD
A[Scheduled job] --> B[Automation turn context]
B --> C[Agent tools]
C --> D[Requester yield owner]
D --> E[Runner finalization]
E --> F[Scheduler delivery]
G[Child completion] --> F
Loading

Technical review

Best possible solution:

Carry the scheduler-owned terminal outcome through the existing yield callback and runner finalization while preserving diagnostics for unsupported interactive yields.

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

Current-main source explicitly refuses automation yields; on this head, an accepted empty yield reaches the unchanged no-continuation diagnostic, although no target code was executed during review.

Is this the best way to solve the issue?

Using the existing yield owner and removing duplicated filters is appropriately small, but the scheduler-owned outcome must survive the complete runner lifecycle.

Full review comments:

  • [P2] Carry scheduler-owned completion through terminal finalization — src/agents/openclaw-tools.requester-yield.ts:40
    The earlier P2 finding remains unresolved. An automation calling sessions_yield with no acknowledgment, accepted spawn, delivery, or other continuation evidence now succeeds, including the no-child case explicitly accepted by this PR. However, schedulerOwned is consumed only for the tool-result note: onYield and attempt state retain no scheduler-owned completion fact. Outer finalization consequently reaches terminal-resolution.ts:611 and emits “⚠️ Turn yielded without a continuation source. Send a message to resume.” This replaces the original misleading failure with another incorrect recovery instruction even though the automation is intentionally finished. Propagate the outcome through the existing lifecycle and cover the empty case through full runner finalization; retain the diagnostic for unsupported interactive yields.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Automation refusal and catalog filtering changes intended behavior with a stated reason (af58a77: Prevent automation turns from recording interactive yield claims that their completion owner cannot resume; extended to scheduled placements by 543c92b.)
  • Automation collection guidance keeps the original intent (ab6d6bd: Observed cron parents ended before synthesizing or integrating child results; the repaired head retains collection guidance independently of yield visibility.)
  • Collector and incoming-message semantics keeps the original intent (d840b33: Child-completion waits must not create false message-wait notices; collectors must settle through explicit result collection.)
  • Unattended turn instructions keeps the original intent (3d2f7ca: Scheduled conversation work uses ordinary session admission; adding automation guidance to its message preserves the existing session's stable system prompt and catalog.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/terminal-preparation.yield.test.ts src/agents/embedded-agent-runner/run/attempt.sessions-yield.test.ts src/agents/openclaw-tools.requester-yield.test.ts src/agents/tools/sessions-yield-tool.test.ts --maxWorkers=1
  • node scripts/run-vitest.mjs src/cron/isolated-agent/delivery-dispatch.automation-yield.test.ts src/cron/execution-context-tool-policy.test.ts src/agents/agent-tools.prefix-stability.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3ae3e4d adds src/agents/openclaw-tools.requester-yield.ts:47 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3ae3e4dc88ed; files: src/agents/openclaw-tools.requester-yield.ts)
  • Josh Lehman: Raw commit 40c71f5 adds src/agents/openclaw-tools.requester-yield.ts:63 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 40c71f5e7c71; files: src/agents/openclaw-tools.requester-yield.ts)
  • Jason (Json): Raw commit d840b33 adds src/agents/tools/sessions-yield-tool.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d840b332594f; files: src/agents/tools/sessions-yield-tool.ts)

PR surface

Source -8, Tests +197, Docs +9. Total +198 across 19 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 38 46 -8
Tests 10 240 43 +197
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 287 89 +198

Review metrics

Metric Value Why it matters
Production versus test changes Production +38/-46; tests and generated fixtures +240/-43 Production removes duplicated filtering; added coverage exercises distinct prompt, admission, attempt, and delivery boundaries but misses outer finalization.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Misleading automation yield failures and recovery instructions affect scheduled delegation with a focused repair boundary.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 (1 earlier review cycle)
  • reviewed 2026-10-27T04:56:04.423Z sha 691f47a :: needs changes before merge. :: [P1] Preserve automation collection guidance when exposing yield | [P2] Carry scheduler-owned completion through terminal finalization

Reviewed October 27, 2026, 2:10 AM ET / 06:10 UTC (Revision 2).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d96fea60a

ℹ️ 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".

Comment thread src/agents/delegation-guidance.ts Resolved
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Both collection-guidance findings are repaired on 35634ac. The PR body records the owner tests, unchanged line-cap limits, clean P1 Codex review, and green exact-head CI.

@clawsweeper

clawsweeper Bot commented Oct 27, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Oct 27, 2026
@steipete
steipete merged commit 71e2f57 into main Oct 27, 2026
159 of 160 checks passed
@steipete
steipete deleted the codex/automation-yield-ends-turn branch October 27, 2026 06:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 27, 2026
Jump 8 of the absorb-8083 line: one merge of upstream openclaw/openclaw main
7fdf69f (477 commits, 3,070 files past U7
96da011) into the j7 head 1b92f87.

Schema: upstream state 34 -> 35 (shared workspace CAS) is taken as is; our
agent 38 (recipient authority) stays above upstream's unchanged agent 37.
U8 did not touch the agent schema, its SQL, catalogs or port descriptor.

18 conflicts, resolved upstream-first:
- subagent-announce: upstream's terminal-reply summary import beside our moved
  flow types.
- subagent-registry-restore: upstream's retainRestoredCompletionReservation
  (openclaw#185549) owns restart recovery, cancellation, mismatch and orphan release;
  spawn custody (H1/F1) rows are skipped before it in both restore loops, so
  they keep their requester reservation for the sweeper exactly as in j7.
  isRestoredSubagentRunOwnedElsewhere now covers spawn custody only.
- subagent-registry-sweeper: upstream's settleSubagentCompletionReservation
  and restart-drain stop; the H1 custody branch stays ahead of settlement and
  retired authority (non-mismatched rows only, as j7 skipped mismatches first),
  and the drain stop is ported into the extracted collector-group sweep.
- session.ts: upstream moved the lifecycle-mutation types and preprocessing
  state out; our nextLifecycleRevision field moves with the type.
- tool-resolution: both sides removed one import each (our catalog factory,
  upstream's requester-yield filter, openclaw#185445).
- system-events test: upstream's file-level hooks plus our restore tests.
- state-port PG test: upstream 135 tables + continuation_records = 136.
- package.json schemaVersions: state 35, agent 38.
- lint-suppressions, database-worker core paths: union.
- plugin-sdk surface budgets: upstream + the fork's measured +11/+4.
- generated files regenerated with config:docs:gen, db:postgres:gen and
  db:worker-inventory:gen, not hand-merged.

Refs karmaterminal/openclaw-bootstrap#1727

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
* fix(agents): end automation turns successfully on yield

* test(agents): regenerate automation yield prompt snapshots

* fix(agents): preserve automation collection guidance with yield

* fix(cron): explain automation yield in turn context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. 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.

1 participant