Skip to content

fix(agents): prevent duplicate yielded subagent fanout - #118703

Merged
vincentkoc merged 1 commit into
mainfrom
codex/beta8-requester-settle-race-20260803
Aug 4, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
codex/beta8-requester-settle-race-20260803

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where Codex-runtime sessions using sessions_yield fanout could replay the original child launches or never receive the final synthesized completion after the children finished.

The release-grade runtime-pair lane reproduced this as duplicate alpha/beta launches followed by a timeout.

Why This Change Was Made

Native harness results now settle accepted child spawns immediately after the harness releases active-run ownership, before dispatch can replace the successful result with a late abort. OpenClaw keeps its existing earlier settlement boundary.

Completion delivery remains parked while the yielded requester owns the handoff, and the requester wake is re-armed only after that turn settles. This avoids both duplicate steering/direct delivery and silent completion loss.

User Impact

Users can fan out subagents from the Codex runtime, yield for their completion, and receive one final synthesis without duplicate child launches.

Evidence

  • Reproduced in Full Release Validation at frozen SHA 8895b0c28858caf9c45f4924bc27db281f672522: runtime-pair failure and release verifier failure.
  • Rebuilt conflict-free on origin/main 45643863d7132a2580864ac05d007dcc724a5dbf; exact signed head cfb7fd1b3660f3c19341a6761e5c87df12b3df9d.
  • Blacksmith Testbox tbx_01kz5tscp2pewppczmrkfgbvky: workflow run.
  • pnpm check:changed: passed.
  • Focused Vitest proof: 290 tests passed across registry lifecycle, announcement delivery, and native late-abort settlement.
  • Private QA runtime build: passed.
  • QA runtime pair subagent-fanout-synthesis: OpenClaw 1/1, Codex 1/1, validator 1/1.
  • Fresh exact-head autoreview: no accepted/actionable findings, correctness 0.94.
  • Direct Codex contract checked at codex-rs/app-server/src/request_processors/turn_processor.rs, codex-rs/core/src/session/mod.rs, codex-rs/app-server/src/bespoke_event_handling.rs, and codex-rs/app-server-protocol/src/protocol/v2/turn.rs for expected-turn steering and turn completion behavior.

Provenance: made visible by #118644, which added native accepted-spawn telemetry but did not yet settle it through the shared harness boundary.

@vincentkoc vincentkoc self-assigned this Aug 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 10:18 AM ET / 14:18 UTC.

ClawSweeper review

What this changes

The PR settles native-harness accepted child spawns before a late dispatcher abort, parks completion delivery while sessions_yield owns the requester handoff, and prevents duplicate requester wake delivery.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this MEMBER-authored, maintainer-labeled draft open. The patch targets a real session-state boundary and has focused regression coverage, but current main gained a related requester-handoff repair after the PR base; the branch needs a rebase and exact-head runtime-pair validation before a merge decision. Independent Codex contract verification is blocked because sibling ../codex is absent and the checkout cannot reach GitHub to obtain it.

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

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has focused lifecycle coverage and no discrete line-level defect found, but rebase validation and the unavailable Codex contract check prevent a higher-confidence merge assessment.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored draft is outside the external-contributor proof gate; its linked runtime evidence should nevertheless be rerun on the rebased exact head before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored draft is outside the external-contributor proof gate; its linked runtime evidence should nevertheless be rerun on the rebased exact head before merge.
Evidence reviewed 6 items Proposed native-harness settlement boundary: The branch calls the registry settlement API after a non-OpenClaw harness returns accepted spawns, before the dispatcher can replace that result with a late abort.
Registry owns yielded handoff state: The current registry settles only matching completion rows, records a pending requester-yield batch, then clears the old requester-run ownership before scheduling the eventual wake.
Current-main related repair: Current main history contains f9df87ce6885e715134c5dd1b8bf849e1856add3 titled fix(agents): preserve successful sessions_yield handoffs (#118584), so the submitted branch must be revalidated after integrating that later lifecycle work.
Findings None None.
Security None None.

How this fits together

Embedded agent runs call a selected harness, record accepted child-session spawns, and use the subagent registry to decide when the requester can resume. Completion cleanup then either wakes that requester for synthesis or delivers a portable completion message through the channel path.

flowchart LR
  A[Requester turn] --> B[Embedded agent attempt]
  B --> C[Selected native harness]
  C --> D[Accepted child spawns]
  D --> E[Subagent registry settlement]
  E --> F[Requester wake decision]
  F --> G[Final synthesis or completion delivery]
Loading

Decision needed

Question Recommendation
After rebasing onto current main, does this PR still provide a distinct, necessary native-harness settlement fix beyond the requester-handoff behavior introduced by f9df87ce6885e715134c5dd1b8bf849e1856add3? Rebase and revalidate the combined lifecycle: Recommended: rebase the draft, inspect the Codex source contract, and rerun the runtime-pair fanout scenario on the resulting exact head before deciding whether to merge.

Why: The answer depends on the integrated ordering of current-main lifecycle changes and the Codex app-server turn contract, which could not be directly inspected because sibling ../codex is unavailable.

Before merge

  • Resolve merge risk (P1) - Current main added a related yielded-handoff repair after this PR's base; without rebase and exact-head runtime-pair proof, the combined lifecycle ordering remains uncertain.
  • Resolve merge risk (P1) - The required direct Codex source inspection cannot be completed in this environment, so the native harness completion/steering timing behind the new boundary has not been independently verified.
  • Complete next step (P2) - This protected MEMBER draft needs a rebase-aware lifecycle-owner review and direct Codex contract inspection, not an automated repair lane.
Agent review details

Security

None.

PR surface

Source +32, Tests +63. Total +95 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 38 6 +32
Tests 3 88 25 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 126 31 +95

Review metrics

Metric Value Why it matters
Production versus test delta production +32 net (38 added, 6 removed); tests +63 net (88 added, 25 removed) The production growth is tied to an explicit lifecycle ownership boundary and is accompanied by focused coverage, but its combined behavior with current main still needs rebase proof.

Merge-risk options

Maintainer options:

  1. Rebase and prove the integrated handoff (recommended)
    Rebase onto current main and rerun the focused runtime-pair scenario so the merged ordering proves that spawned children launch once and the requester receives one synthesis.
  2. Pause pending owner confirmation
    Keep the draft paused if the rebased path overlaps the current-main requester-handoff repair or the Codex completion contract cannot be independently checked.

Technical review

Best possible solution:

Rebase onto current main, preserve one canonical requester-settlement path with the current registry owner, and publish fresh exact-head runtime-pair evidence showing one child launch per request and one final requester synthesis.

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

No independent high-confidence reproduction was established here: the PR supplies linked Testbox and runtime-pair claims, but this read-only environment could not inspect or rerun them and lacks the required sibling Codex source.

Is this the best way to solve the issue?

Unclear: settling at the harness boundary is consistent with the registry's explicit yielded-handoff owner, but current main has a later related repair and the upstream Codex turn contract could not be inspected directly.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Duplicate child launches or a missing final synthesis breaks an active agent workflow for users of yielded subagent fanout.
  • add merge-risk: 🚨 session-state: The patch changes persisted requester-yield and wake ordering, so an incorrect integrated ordering can replay fanout or suppress the final completion.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored draft is outside the external-contributor proof gate; its linked runtime evidence should nevertheless be rerun on the rebased exact head before merge.

Label justifications:

  • P1: Duplicate child launches or a missing final synthesis breaks an active agent workflow for users of yielded subagent fanout.
  • merge-risk: 🚨 session-state: The patch changes persisted requester-yield and wake ordering, so an incorrect integrated ordering can replay fanout or suppress the final completion.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored draft is outside the external-contributor proof gate; its linked runtime evidence should nevertheless be rerun on the rebased exact head before merge.

Evidence

What I checked:

  • Proposed native-harness settlement boundary: The branch calls the registry settlement API after a non-OpenClaw harness returns accepted spawns, before the dispatcher can replace that result with a late abort. (src/agents/embedded-agent-runner/run/backend.ts:18, b0320befcbdd)
  • Registry owns yielded handoff state: The current registry settles only matching completion rows, records a pending requester-yield batch, then clears the old requester-run ownership before scheduling the eventual wake. (src/agents/subagent-registry-requester-yield.ts:41, ffcca757eb3a)
  • Current-main related repair: Current main history contains f9df87ce6885e715134c5dd1b8bf849e1856add3 titled fix(agents): preserve successful sessions_yield handoffs (#118584), so the submitted branch must be revalidated after integrating that later lifecycle work. (src/agents/subagent-registry-requester-yield.ts:41, f9df87ce6885)
  • Focused patch coverage: The branch adds coverage for native late-abort settlement and for withholding direct completion delivery while yielded requester synthesis owns the handoff. (src/agents/embedded-agent-runner/run.overflow-compaction.loop.test.ts:154, b0320befcbdd)
  • Related merged telemetry repair: Merged PR fix(codex): avoid duplicate subagents after yielded fanout #118644 preserved Codex accepted-spawn evidence; this PR addresses the subsequent shared settlement and delivery boundary rather than duplicating that earlier bridge fix. (8895b0c28858)
  • Codex dependency-contract gate unavailable: Repository policy requires direct inspection of sibling ../codex for Codex runtime verdicts. That checkout is absent, and the local promisor remote cannot resolve GitHub, so this review cannot independently validate Codex completion and steering timing.

Likely related people:

  • steipete: Current-main history attributes the related yielded-handoff repair and the original backend bridge to Peter Steinberger; the affected registry and embedded-runner paths are central to this PR. (role: recent lifecycle owner; confidence: high; commits: f9df87ce6885, 188957a18af8; files: src/agents/subagent-registry-requester-yield.ts, src/agents/subagent-registry-lifecycle-requester-wake.ts, src/agents/embedded-agent-runner/run/backend.ts)
  • vincentkoc: Vincent Koc authored the merged Codex accepted-spawn telemetry repair that this PR explicitly builds on, providing adjacent ownership of the Codex-to-registry handoff. (role: recent adjacent contributor; confidence: medium; commits: 8895b0c28858; files: src/agents/embedded-agent-subscribe.ts, src/agents/embedded-agent-runner/run/backend.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and rerun the runtime-pair fanout proof on that exact head.
  • Inspect the sibling Codex turn-completion and steering source before treating the native-harness timing contract as verified.

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.

@vincentkoc
vincentkoc force-pushed the codex/beta8-requester-settle-race-20260803 branch from b0320be to cfb7fd1 Compare August 4, 2026 07:40
@vincentkoc
vincentkoc marked this pull request as ready for review August 4, 2026 07:40
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head is cfb7fd1b3660f3c19341a6761e5c87df12b3df9d. The branch was rebuilt on 45643863d7132a2580864ac05d007dcc724a5dbf, direct sibling Codex source was inspected, exact-head Testbox check:changed and 290 focused tests passed, the OpenClaw/Codex subagent-fanout-synthesis runtime pair passed 1/1, fresh autoreview reported no actionable findings, and all hosted checks are green.

@clawsweeper

clawsweeper Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@vincentkoc
vincentkoc merged commit 05c987c into main Aug 4, 2026
182 of 184 checks passed
@vincentkoc
vincentkoc deleted the codex/beta8-requester-settle-race-20260803 branch August 4, 2026 07:54
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 4, 2026
…checkpoint

* origin/main: (46 commits)
  fix(agents): recover from invalid compaction summaries (#119137)
  fix(gateway): expose OAuth-backed tools to CLI agents (#119166)
  fix(plugins): preserve metadata reloads during models status (#119183)
  fix(test): bound direct gateway server runs (#119184)
  test(tui): prove command surfaces through PTY (#119165)
  fix(testbox): restore claims across path aliases (#119170)
  fix(message): preserve sends with incidental Telegram locations
  fix(perf): give each concurrency sample a full deadline (#119164)
  fix(testbox): remove changed-gate sync residue (#119163)
  fix(telegram): preserve later chunks after rejected sends
  fix(tui): block terminal controls in system messages (#118998)
  fix(auto-reply): suppress false no-reply fallback during continuations (#119154)
  fix(scripts): prevent gateway benchmarks from stalling on probes (#119063)
  test(channels): verify built sanitizer semantics (#119151)
  fix: prevent live updater from leaving Gateway offline indefinitely (#119116)
  test(qa): restore memory tools primary ownership (#119142)
  fix(agents): settle yielded fanout at harness boundary (#118703)
  fix(codex): cap compaction override warning cache via createDedupeCache (#101745)
  fix(daemon): skip unlabeled launchd plists (#119091)
  test(qa): repair QA catalog integrity (#119140)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
zyw02 pushed a commit to zyw02/openclaw that referenced this pull request Aug 5, 2026
* origin/main:
  fix: prevent live updater from leaving Gateway offline indefinitely (openclaw#119116)
  test(qa): restore memory tools primary ownership (openclaw#119142)
  fix(agents): settle yielded fanout at harness boundary (openclaw#118703)
  fix(codex): cap compaction override warning cache via createDedupeCache (openclaw#101745)
  fix(daemon): skip unlabeled launchd plists (openclaw#119091)
  test(qa): repair QA catalog integrity (openclaw#119140)
  fix(test): isolate shared state between test files (openclaw#118781)
  test(xai): cover delayed OAuth connection setup
  fix(voice): start socket timeout after auth preparation
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
* origin/main:
  fix: prevent live updater from leaving Gateway offline indefinitely (openclaw#119116)
  test(qa): restore memory tools primary ownership (openclaw#119142)
  fix(agents): settle yielded fanout at harness boundary (openclaw#118703)
  fix(codex): cap compaction override warning cache via createDedupeCache (openclaw#101745)
  fix(daemon): skip unlabeled launchd plists (openclaw#119091)
  test(qa): repair QA catalog integrity (openclaw#119140)
  fix(test): isolate shared state between test files (openclaw#118781)
  test(xai): cover delayed OAuth connection setup
  fix(voice): start socket timeout after auth preparation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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