Skip to content

fix(subagents): stop terminal requester wake retry loops - #140956

Draft
yu-xin-c wants to merge 4 commits into
openclaw:mainfrom
yu-xin-c:codex/137332-orphan-reconcile
Draft

yu-xin-c wants to merge 4 commits into
openclaw:mainfrom
yu-xin-c:codex/137332-orphan-reconcile

Conversation

@yu-xin-c

@yu-xin-c yu-xin-c commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Related: #137332

Current Status - October 31

Draft; recovery policy and native-owner integration are unresolved. Issue #137332 is closed after Tasks/TaskFlow retirement in #159179. The earlier comments distinguishing this PR from #150065 and #151949 do not establish acceptance of using legacy task evidence in the replacement native owner.

The October 8 review identifies the remaining decision: whether legacy exact-owner task evidence may substitute for a missing captured native execution outcome when permanently stopping delivery. That interpretation has not been accepted. This branch must not restore the retired task ledger or silently weaken native outcome checks.

Proposed scope for owner confirmation: integrate only a demonstrated remaining queue/wake convergence defect for native owners with captured execution outcomes; leave missing-outcome records unresolved unless a separate historical-recovery policy is explicitly approved. A current post-retirement reproduction is needed to justify the remaining production change. Existing branch proof below does not establish that current-main defect or qualify an integration with the new owner.

Before ready: confirm the remaining scope, resolve conflicts in the native settlement owner, and requalify rollback, cohort/generation checks, persisted-state recovery, and restart suppression. No source changes or fresh test runs are claimed on October 31. Head remains 444d33e3124d577571dd40279db4f1eb88d5f891.

What Problem This Solves

On its pre-retirement base, this branch targets an issue where terminal subagent completions could retain a durable requester-settle wake after the final handoff was rejected, causing the same failed reconciliation to run repeatedly across Gateway restarts. This includes non-success child outcomes, already-delivered task projections, historical rows without a captured outcome, and legacy partial settlements whose physical delivery queue entry remained replayable.

Why This Change Was Made

Rejected requester-settle batches now validate their exact wake, frozen cohort, task/run owner, and delivery generation before settling all affected state in one SQLite transaction. Retired or already-cleared frozen members may disappear without trapping the surviving owner, including legacy wakes without a rearm generation, while an omitted member that still holds the same wake generation in SQLite rejects the whole transaction. The transaction terminalizes any matching replayable session-queue owner, preserves task delivery already observed by the requester, and clears or retires the durable wake atomically; legacy rows that already lost their logical queue ID are reconciled by the full physical owner tuple.

This is an incremental repair on top of #137344. It intentionally does not clear rows whose task owner is entirely absent, because that state still needs an explicit owner-safe reconciliation policy.

User Impact

On the tested historical branch, operators no longer see represented terminal subagent completions retry the same rejected requester wake indefinitely after restart, and stale physical queue work cannot replay after the wake is closed. Existing successful or already-delivered task outcomes remain intact.

Evidence

  • node scripts/run-vitest.mjs src/agents/subagents/completion/subagent-completion-requester-settle.store.test.ts src/agents/subagents/registry/subagent-registry-lifecycle.test.ts src/agents/subagents/registry/subagent-registry.test.ts: 365 passed.
  • Real Gateway restart E2E with a pending task, in-progress completion delivery, leased physical queue entry, and HTTP/SSE NO_REPLY: 1 passed; task, logical delivery, queue, and wake reached their durable terminal projections, and a second Gateway start made no additional model request.
  • Changed-gate format, core production types, core test types, root E2E types, core/root Oxlint, database-first storage guard, import-cycle check, and native state schema guard passed.
  • All three Knip dead-export scans passed on an isolated rerun after one concurrent changed-gate subprocess exited transiently despite reporting zero findings.
  • Latest pnpm tsgo:core, changed-file Oxlint, and changed-file Oxfmt checks passed.
  • Fresh local autoreview after the unnumbered frozen-wake follow-up: scoped clean at P0-P2.

@clawsweeper

clawsweeper Bot commented Sep 7, 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.

@yu-xin-c
yu-xin-c marked this pull request as ready for review September 7, 2026 07:07
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR atomically settles rejected requester wakes, matching completion deliveries, and physical queue entries.

Example: On the historical branch, run-gateway-restored-settle-pending receives NO_REPLY during restored requester delivery.

  • Before: Its durable wake and physical queue entry can remain replayable after rejection.
  • After: Delivery and queue state become failed, the wake clears, and the recorded second Gateway start makes no additional matching model request.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Historical behavior is demonstrated, but the remaining native repair and permanent recovery interpretation are unresolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Retained evidence for the unchanged head exercises the real Gateway with loopback HTTP/SSE NO_REPLY, durable queue/wake settlement, and a bounded second-start replay check; it qualifies the historical branch only. No latest-stable upgrade run establishes compatibility of the proposed persistent recovery semantics.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: Operators on the historical base could see rejected child completions retry repeatedly across Gateway restarts.
Reason: The remaining production need and historical recovery contract require owner confirmation after task retirement.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open as a maintainer-engaged draft: current main removed the task-ledger failure paths, while its remaining recovery scope awaits an owner decision.

Priority: P2
Reviewed head: 444d33e3124d577571dd40279db4f1eb88d5f891
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this PR be narrowed to demonstrated native-owner defects with captured outcomes, or may legacy task evidence justify permanently settling records without a native execution outcome?
  • Recommendation: Require captured native outcomes: Confirm the narrower scope and require a current-main defect before integrating a repair.
  • Why: The author has acknowledged the unresolved policy and paused the PR; earlier maintainer retention comments do not approve that durable-data interpretation.

Before merge

  • Complete next step - After scope is accepted, resolve the confirmed conflicts through the existing native settlement owner without restoring task-ledger dependencies.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Historical Gateway proof does not establish a remaining native-owner defect or a latest-stable upgrade preserving existing state.
Agent review details

How this fits together

Subagent completion connects finished child runs to requester continuations; registry wakes, SQLite delivery state, and the session queue govern retries and restart recovery.

flowchart TD
  A[Terminal child run] --> B[Requester wake lifecycle]
  B --> C[Completion settlement owner]
  C --> D[SQLite transaction]
  D --> E[Delivery queue state]
  D --> F[Durable wake state]
  F --> B
Loading

Technical review

Best possible solution:

Use the existing native completion owner for any demonstrated remaining defect, preserving captured-outcome requirements unless an owner explicitly approves historical recovery.

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

No current-main failing reproduction is established; historical task-owner failures were removed, and current source explicitly rejects missing-outcome settlement.

Is this the best way to solve the issue?

Atomic, generation-fenced settlement is appropriate, but any remaining repair must extend the native owner and establish a defect beyond its intentional evidence requirements.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit acdd2bb adds src/agents/subagents/registry/subagent-registry-lifecycle-wake.ts:102 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: acdd2bb8d627; files: src/agents/subagents/registry/subagent-registry-lifecycle-wake.ts)
  • Sho Jikumaru: Raw commit 1c10f70 adds src/agents/subagents/completion/subagent-completion-admission.store.ts:179 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1c10f70d9c86; files: src/agents/subagents/completion/subagent-completion-admission.store.ts)
  • joshavant: Raw commit d9393bd adds src/agents/subagent-completion-admission.store.ts:81 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d9393bd3cbe1; files: src/agents/subagent-completion-admission.store.ts)

PR surface

Source +349, Tests +721. Total +1070 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 357 8 +349
Tests 4 745 24 +721
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 1102 32 +1070

Root-cause cluster

Relationship: partial_overlap
Canonical: #137332
Summary: This PR originated as a partial repair for the now-closed task-ledger report; later native repairs do not establish complete supersession of its historical recovery proposal.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is bounded completion-recovery work whose remaining current-main impact is unestablished.
  • merge-risk: 🚨 session-state: The patch can permanently suppress delivery and clear durable wakes using historical task evidence when a native outcome is absent.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

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

  • Obtain an owner decision on the narrowed recovery scope.
  • Establish a current-main defect before integrating further production changes.

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 (6 earlier review cycles)
  • reviewed 2026-09-07T07:15:18.361Z sha 42d960b :: needs real behavior proof before merge. :: [P2] Validate surviving frozen members without requiring retired rows
  • reviewed 2026-09-07T07:36:56.933Z sha b704b9d :: needs real behavior proof before merge. :: [P2] Validate surviving frozen members without requiring retired rows
  • reviewed 2026-09-07T08:04:37.398Z sha 9f410dd :: blocked before merge. :: [P2] Require a persisted wake before comparing optional generations
  • reviewed 2026-09-07T08:33:27.787Z sha 444d33e :: blocked before merge. :: none
  • reviewed September 23, 2026, 3:51 AM ET / 07:51 UTC (Revision 5) sha unknown :: blocked before merge. :: none
  • reviewed 2026-10-08T04:22:59.973Z sha 444d33e :: blocked before merge. :: none

Reviewed October 31, 2026, 8:40 AM ET / 12:40 UTC (Revision 7).

@yu-xin-c

yu-xin-c commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 7, 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:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 7, 2026
@yu-xin-c

yu-xin-c commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 7, 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:

@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 7, 2026
@VACInc

VACInc commented Sep 16, 2026

Copy link
Copy Markdown
Member

Related fix: #150065 does not implement durable rejected-wake reconciliation, exact cohort/generation fencing, physical queue terminalization, or restart replay suppression. Its cancellation classification is a different boundary. This PR's requester-settle convergence work for #137332 is not superseded; retain the documented missing-task-owner limitation.

@VACInc

VACInc commented Sep 18, 2026

Copy link
Copy Markdown
Member

Related to #151949, but not superseded. That merged change handles a successful same-owner receipt after expiry suspension. This PR has broader rejected/mixed-batch, historical-owner, physical-queue terminalization, and restart-convergence scope. Keeping this PR open; retain its distinct ownership, queue, and rollback coverage.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 8, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Oct 9, 2026
@yu-xin-c
yu-xin-c marked this pull request as draft October 31, 2026 12:22
@yu-xin-c

Copy link
Copy Markdown
Contributor Author

Acknowledging the October 8 recovery-policy review. I moved this to draft and updated the description: #137332 is closed after #159179, and the earlier comparisons with #150065/#151949 do not settle the missing-native-outcome policy. My proposed remaining scope is only a demonstrated post-retirement queue/wake convergence defect for native owners with captured outcomes; absent-outcome rows would stay unresolved, with no inferred verdict from retired task projections. Does the completion owner want that narrowed follow-up, and is there a current persisted-state reproduction for it? I will not restore the retired task ledger or claim the historical Gateway proof qualifies current main. No new tests or re-review are claimed/requested.

@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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 31, 2026

This branch has not been deployed

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

Labels

agents Agent runtime and tooling merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

2 participants