Skip to content

fix: prevent missed and duplicate parent turns after worker replies - #206529

Merged
freeqaz-openai merged 2 commits into
mainfrom
fix/worker-already-acknowledged
Nov 30, 2026
Merged

freeqaz-openai merged 2 commits into
mainfrom
fix/worker-already-acknowledged

Conversation

@freeqaz-openai

@freeqaz-openai freeqaz-openai commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A worker can finish successfully and still leave its parent waiting. If the parent detaches just as a delivery attempt decides to wait, the next attempt can join one that has already finished. In another race, an acknowledgment arrives during requester lookup and the parent gets a redundant turn.

User Impact

A finished worker can reach the parent when it detaches. An answer already read by the parent can retire without another turn.

Why This Change Was Made

The shared completion owner now clears the finished attempt before its promise settles. It checks whether the parent consumed the result when delivery first requests admission. A later acknowledgment leaves an accepted handoff intact. Ownership checks still run at execution.

Please review the admission boundary before merging. The first revision could revoke an accepted handoff. An unchanged Codex contention test caught that regression. The second commit fixes it. The guard treats an exception after refusing an already consumed result as superseded. It doesn't cancel in-flight transport.

Evidence

Local checks used older cached dependencies. The hosted CI run passed in 1,015 seconds.

Timing controls through the Gateway

Five isolated runs used the real Gateway, Codex CLI 0.164.0 and synthetic model replies. Each sent one chat request and started one worker. Test-only hooks controlled when the parent detached or when OpenClaw applied a genuine wait_agent acknowledgment. The same development build selected the unchanged completion owner from either commit. It included none of the other pending fixes.

Owner Event order Delivery calls Parent notification starts Saved notification replies
5e245aa0 Waiting → detach → joined previous attempt 0 0 0
544f90ba Waiting → detach → started new attempt 1 1 1
5e245aa0 Lookup started → acknowledged → lookup finished 1 1 1
544f90ba Lookup started → acknowledged → lookup finished 0 0 0
544f90ba Delivery admitted → acknowledged → transport called 1 1 1

All five retained the original parent reply. I checked each worker’s saved answer, matched notification IDs to the native turn and checked parent history after a three-second observation window. The hooks forced these orderings. The trial does not measure how often they occur.

@clawsweeper

clawsweeper Bot commented Nov 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 agents Agent runtime and tooling size: S labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. 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 Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR clears finished delivery attempts sooner and suppresses parent wakes acknowledged before admission while preserving accepted handoffs.

Example: A worker finishes with "saved answer" while its parent detaches.

  • Before: The detach can join an already finished attempt, leaving the parent without the answer.
  • After: The detach starts another attempt and delivers the answer once.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Focused, source-supported repair with distinct regression tests and passing current-head CI, but the supplied runtime evidence does not establish recovery under either race.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A completed worker can leave its parent waiting or trigger a redundant parent turn.
Reason: Both failures violate the existing completion contract, and the repair preserves the established owner and accepted-handoff behavior.

Merge readiness

✅ Ready for maintainer review

This PR addresses two concrete completion races still present on current main; no actionable introduced defect was found.

Reviewed head: 544f90ba68dfdd5eca11344a74ed7b16558aa31e

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared completion owner receives worker results and consumption receipts, coordinates delivery through the harness adapter, and retires completed obligations.

flowchart LR
  Worker[Worker result] --> Owner[Shared completion owner]
  Receipt[Consumption receipt] --> Owner
  Owner --> Admission[Delivery admission]
  Admission --> Transport[Harness delivery transport]
  Transport --> Parent[Parent session]
  Owner --> Retirement[Assignment retirement]
Loading

Technical review

Best possible solution:

Keep the focused repair in the existing completion owner and demonstrate both race outcomes through the production delivery boundary.

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

Source inspection establishes both race windows, and the PR reports both focused regressions failing on the base; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch repairs attempt ownership and first-admission consumption in the existing owner without adding a competing lifecycle, public API, configuration, or persistence format.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Detached native completion attempt and admission lifecycle keeps the original intent (a9569e9: Centralize native delivery, receipt precedence, retries, and retirement in core while preserving Codex-specific correlation and storage contracts.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit a9569e9 adds src/agents/subagents/announce/subagent-announce-obligation-lifecycle.ts:203 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a9569e99ea71; files: src/agents/subagents/announce/subagent-announce-obligation-lifecycle.ts)

PR surface

Source +19, Tests +97. Total +116 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 26 7 +19
Tests 1 99 2 +97
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 125 9 +116

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.

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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-11-27T09:28:58.454Z sha f398348 :: passed. :: none

Reviewed November 27, 2026, 6:15 AM ET / 11:15 UTC (Revision 2).

@freeqaz-openai freeqaz-openai changed the title fix: skip waking the parent after a worker result was acknowledged fix: prevent missed and duplicate parent turns after worker replies Nov 27, 2026
@freeqaz-openai

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 27, 2026
@freeqaz-openai
freeqaz-openai merged commit fda3a56 into main Nov 30, 2026
152 of 156 checks passed
@freeqaz-openai
freeqaz-openai deleted the fix/worker-already-acknowledged branch November 30, 2026 08:52
@freeqaz-openai

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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