Skip to content

fix: subagent results delivered after a blocked handoff are no longer reported as lost - #201613

Open
Anurag-5ingh wants to merge 1 commit into
openclaw:mainfrom
Anurag-5ingh:fix/subagent-settled-suspended-delivery
Open

Anurag-5ingh wants to merge 1 commit into
openclaw:mainfrom
Anurag-5ingh:fix/subagent-settled-suspended-delivery

Conversation

@Anurag-5ingh

@Anurag-5ingh Anurag-5ingh commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Related #201339

What Problem This Solves

A subagent can finish while its requester is still working. If the requester's turn ends before the result is handed over, the completion is blocked as permanent_failure. A few seconds later the requester's pending batch does hand the result over, but the run keeps the permanent_failure record. subagents list and any monitor then report a lost completion that actually reached the requester.

User Impact

When the requester's batch delivers a completion that was blocked this way, the run is now recorded as delivered. Completions that were blocked for other reasons keep their block.

Why This Change Was Made

Blocking a completion after its requester finished keeps the requester's separately owned yield batch, because that batch still carries the result. When the batch settled successfully, the settlement mutation cleared the wake but only updated delivery for pending, retryable or expired completions, so the permanently suspended record was never corrected.

The settlement now also marks delivery when the completion is blocked as a completed-requester failure and its wake is that yield batch. The existing contract from #176145, that a successful receipt does not recover an ordinary permanent_failure suspension, is unchanged and its test still passes.

Evidence

Owner-level regression. New test in subagent-requester-delivery.test.ts: a completion suspended as permanent_failure (visible_reply_missing), with its yield-batch wake retained, settles with a delivered outcome. It fails on current main (delivery stays suspended) and passes with this change (delivery is delivered, the suspended fields are cleared, and the wake is removed).

Existing data from the latest stable release (v2026.11.5). No schema or serialization change. To check stored rows from a released build:

  1. In a v2026.11.5 checkout, the release's own record writer (bindSubagentRunRecord + writeSubagentRunValuesInDatabase) and schema (user_version 36) stored a blocked completion with its yield-batch wake.
  2. This branch opened that database file unchanged, loaded the row, and ran the requester-batch settlement with a delivered outcome.
stored by v2026.11.5:
  delivery: {status: suspended, disposition: permanent_failure, suspendedReason: permanent_failure,
             lastDropReason: visible_reply_missing, requesterDelivery: {state: waiting}}
  requesterSettleWake: {status: dispatching, requesterYieldBatch: true, batchRunIds: [xv-run]}

loaded by this branch: identical to the stored row

after settlement, this branch:   delivery: {status: delivered, disposition: delivered, deliveredAt: 95}, wake removed
after settlement, current main:  delivery: {status: suspended, disposition: permanent_failure, ...}, wake removed

So rows that are already blocked on an upgraded install load normally and are corrected the next time their yield batch settles. Rows that are blocked for other reasons are untouched (the #176145 contract test still passes).

Related suites. Requester delivery, registry lifecycle, requester-wake e2e, sweeper recovery, persistence, steer-restart, the registry suite and all subagent completion admission tests pass (545 tests). pnpm tsgo:core, pnpm tsgo:core:test, oxlint, oxfmt and git diff --check are clean.

Not covered: a live Gateway run. The reported state only appears when a requester turn ends during restart recovery without visible-reply evidence (the report saw it with CLI-backed runtimes), and then its yield batch settles seconds later. I can't reproduce that race against a live model from my setup, and the mock provider lanes have no scenario that drives restart recovery into this state. If a maintainer can run it against a live runtime, the check is: after the late settle, subagents list should show the run as delivered instead of permanent_failure.

A completion blocked after its requester finished keeps its separately owned
yield batch. When that batch later hands the result to the requester, the
settlement cleared the wake but left the run marked permanent_failure, so
`subagents list` and monitors reported a lost completion that was delivered.

Mark that completion delivered when its owning yield batch settles
successfully. Other permanently suspended completions keep their block.

Fixes openclaw#201339
@clawsweeper

clawsweeper Bot commented Nov 19, 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: XS labels Nov 19, 2026
@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Records successful requester-batch delivery for completions previously blocked by a completed requester.

Example: A completion suspended with visible_reply_missing retains its yield batch, which successfully settles at timestamp 95.

  • Before: The wake disappears, but delivery remains suspended with permanent_failure.
  • After: Delivery becomes delivered at timestamp 95, and the suspension fields and wake are cleared.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The scoped code repair has no actionable findings, but required after-fix runtime proof remains absent and exact-head CI has not executed.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Subagent status and monitoring report a lost completion even after the requester receives its result.
Reason: Correcting successful late settlement has clear value; the linked issue also requests changed wait-consumption semantics and earlier notice suppression, which this PR does not implement, so its issue reference should be Related rather than Closes.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR makes a focused repair to a current delivery-state bug, with no actionable code findings.

Priority: P2
Reviewed head: d46698667b734f6875618ab3cb5ae686aafb372f

Before merge

  • Add real behavior proof - The supplied regression exercises the real SQLite mutation with constructed suspended state and a supplied successful outcome; the updated cross-version trace resolves the previous compatibility concern, but neither demonstrates the production Gateway handoff, which the author explicitly could not reproduce. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted after-fix Gateway logs or terminal evidence showing the retained blocked yield batch handing off its result and its durable status becoming delivered; redact IPs, API keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The completion mutation kernel receives requester-batch outcomes and updates canonical SQLite subagent records consumed by status readers.

flowchart TD
  A[Child completion] --> B[Requester yield batch]
  B --> C[Requester handoff outcome]
  C --> D[Completion mutation kernel]
  D --> E[SQLite delivery record]
  E --> F[Subagent status readers]
Loading

Technical review

Best possible solution:

Use the existing settlement mutation to record confirmed yield-batch delivery before clearing its wake while preserving unrelated permanent suspensions.

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

Current-main source deterministically skips delivery reconciliation for the reported suspended yield-batch shape and then removes its wake; this read-only review executed no target code.

Is this the best way to solve the issue?

The change is the smallest complete repair for successful late settlement: it reuses the existing classifier, delivery transition, transaction, and wake owner, with one distinct regression and no added machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +4, Tests +40. Total +44 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 1 +4
Tests 1 40 0 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 45 1 +44

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.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #201339
Summary: This PR addresses the canonical report's stale permanent-failure record after successful late requester settlement.

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: Successful handoffs can retain misleading permanent-failure records, affecting status and monitoring without demonstrated result loss.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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-19T04:46:07.927Z sha d466986 :: needs real behavior proof before merge. :: none

Reviewed November 19, 2026, 12:44 AM ET / 05:44 UTC (Revision 2).

@Anurag-5ingh

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added a cross-version check to the PR body. A blocked row written by the v2026.11.5 release loads unchanged on this branch and settles to delivered (current main leaves it suspended). The body also says why I could not get a live Gateway run.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Anurag-5ingh. The condition is nicely narrow, but we're holding this for now: the block in #201339 came from a path that #185730 removed in 2026.11.5, and on current code we couldn't reach the "blocked, then delivered by the yield batch" state through any real flow (wait, yield, and the agent method all record the completion as delivered). We've asked the reporter to retest on a current release; if they still see it, we'll pick this back up with their logs.

@Anurag-5ingh

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus, that makes sense. I checked and agree: resolveRequesterRecoveryDelivery went away in #185730 (first in v2026.11.5), and I could not reach the blocked-then-delivered state on current code either, which is why the PR only has a constructed-state regression.

I'll leave this parked. If the reporter's retest on a current release still shows a delivered result marked permanent_failure, I'll rebase and check the fix against their logs. If it doesn't reproduce, feel free to close this.

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 P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants