Skip to content

fix(agents): record partial subagent completion delivery as incomplete - #159185

Merged
steipete merged 1 commit into
mainfrom
fix/live2-subagent-partial-delivery
Sep 26, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/live2-subagent-partial-delivery

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

When a subagent's completion result is delivered through the direct-message text fallback, a long result is sent as several chunks. If the first chunk was sent and a later chunk failed or was aborted, OpenClaw recorded the completion as delivered: the registry persisted delivery complete and cleared pending delivery, while the recipient received a truncated result. Nothing told the operator or the requester that the rest was missing.

Why This Change Was Made

deliverCompletionDirect (src/agents/subagents/announce/subagent-announce-completion-delivery.ts) committed { delivered: true } from the per-chunk delivery-result callback, and its catch returned that committed success whenever it existed. The first chunk's receipt therefore stood in for the whole payload. Existing tests covered one identified send followed by a bookkeeping failure, never chunk one succeeding and chunk two failing. The sibling ordinary delivery path already distinguishes partial failures.

Success is now settled from the outbound pipeline's existing per-payload observer (onDeliveredPayload, fired by src/infra/outbound/deliver-core.ts after the payload's sends are recorded), so the announcement is only marked delivered once every chunk went out. When a later chunk fails after earlier chunks were sent (hasAnnounceSendEvidence), delivery is recorded as a terminal, incomplete permanent_failure with the error, instead of success or a retryable failure: an automatic retry would resend chunks the recipient already has. A successful child's result stays available for recovery. The existing behavior that a fully sent result stays delivered even if transcript mirroring or bookkeeping fails is preserved. docs/tools/subagents/announce.md documents the incomplete-delivery outcome.

User Impact

A subagent result that only partly reaches a direct-message recipient is now recorded as an incomplete delivery with its error, rather than silently reported as delivered.

Evidence

  • subagent-announce-text-delivery.test.ts: new cases for a rejected and an aborted second chunk return delivered: true on main and fail; they pass with the fix and show no automatic replay.
  • On a Blacksmith Testbox via Crabbox: 323 tests passed across the announce text-delivery, delivery, completion-delivery, direct-delivery, dispatch, and registry-cleanup suites; node scripts/check-changed.mjs passed.
  • Codex autoreview: scoped-clean ("patch is correct", 0.88).
  • Proof drives the real outbound pipeline with a simulated channel transport.

Production LOC: +21 / −4. Tests: +152 / −62. Docs: +5 / −0.

@clawsweeper

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

@steipete
steipete marked this pull request as ready for review September 26, 2026 21:22
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 26, 2026, 5:29 PM ET / 21:29 UTC.

ClawSweeper review

What this changes

The branch changes subagent direct-message completion delivery to record later chunk errors as incomplete, replaces delivery tests, and documents the recovery behavior.

Merge readiness

⛔ Blocked before merge - 3 items remain

The reported silent truncation remains possible on current main, and this PR fixes the rejected and aborted second-chunk cases. Its new completion signal still cannot establish that every chunk was delivered, so the PR needs a focused repair.

Priority: P1
Reviewed head: 050ac0249009c507eca73fbb2ecb3849b06efaf7

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and has useful boundary tests, but its completion criterion misses a supported partial-send outcome.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored PR is exempt from the external contributor proof gate. Its reported Testbox run and new tests exercise dispatch and outbound core with a simulated Discord transport, including rejected and aborted second chunks; the mixed non-send path and registry persistence remain unproven. No stored-data format changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external contributor proof gate. Its reported Testbox run and new tests exercise dispatch and outbound core with a simulated Discord transport, including rejected and aborted second chunks; the mixed non-send path and registry persistence remain unproven. No stored-data format changes.
Evidence reviewed 8 items Current main still has the reported behavior: Current main commits delivery from the first per-send result; its catch then returns that committed success even if a later chunk fails.
Introduced completion signal: The PR uses the payload observer to commit delivered state and classifies an error with earlier send evidence as a terminal incomplete delivery.
Payload observer accepts some identified sends: The outbound owner invokes the delivered-payload observer when the payload has at least one identified result, after a chunk loop that can ignore a result without delivery identity.
Findings 1 actionable finding [P1] Require a receipt for every direct-completion chunk
Security None None.

How this fits together

A subagent sends its completed result through OpenClaw’s outbound message pipeline when direct-message fallback is needed. Delivery results then update the subagent registry, which controls recovery and retry.

flowchart LR
A[Subagent result] --> B[Direct message fallback]
B --> C[Outbound chunk sends]
C --> D[Delivery evidence]
D --> E{Complete result?}
E -->|Yes| F[Registry records delivered]
E -->|No| G[Registry retains incomplete result]
Loading

Before merge

  • Require a receipt for every direct-completion chunk (P1) - The new onDeliveredPayload success gate does not certify every chunk: outbound core calls it whenever at least one chunk has an identified result. If chunk one succeeds and chunk two returns not_sent or no identity without throwing, this callback still commits delivered: true and clears pending delivery, leaving a truncated result reported as complete. Account for that mixed outcome before committing completion.
  • Resolve merge risk (P1) - A later chunk that returns an explicit non-send or lacks delivery identity can leave a truncated result recorded as delivered; the new payload observer does not distinguish that outcome from complete delivery.
  • Complete next step (P2) - Fix the mixed chunk outcome before merge and verify that partial delivery is retained as incomplete in the registry.

Findings

  • [P1] Require a receipt for every direct-completion chunk — src/agents/subagents/announce/subagent-announce-completion-delivery.ts:353-359
Agent review details

Security

None.

PR surface

Source +17, Tests +90, Docs +5. Total +112 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 21 4 +17
Tests 2 152 62 +90
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 178 66 +112

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Account for every chunk before merge (recommended)
    Treat an identified first chunk followed by an explicit non-send or unknown result as incomplete, and preserve the no-replay behavior.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Cover a first chunk with an identified receipt followed by a second chunk returning not_sent or no identity. Repair completion accounting at the outbound owner boundary so this cannot commit delivered state, while retaining partial-send evidence and preventing automatic replay.

Technical review

Best possible solution:

Settle direct completion from evidence for every planned chunk, retaining the child result and preventing automatic replay whenever only part of it was sent.

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

Yes, from source: give the first chunk an identified receipt and have the second return not_sent with no message ID. The outbound observer still reports payload delivery; I did not execute the path in this read-only review.

Is this the best way to solve the issue?

No. The observer fixes thrown and aborted sends, but it fires with only one identified chunk; the completion decision needs per-chunk accounting.

Full review comments:

  • [P1] Require a receipt for every direct-completion chunk — src/agents/subagents/announce/subagent-announce-completion-delivery.ts:353-359
    The new onDeliveredPayload success gate does not certify every chunk: outbound core calls it whenever at least one chunk has an identified result. If chunk one succeeds and chunk two returns not_sent or no identity without throwing, this callback still commits delivered: true and clears pending delivery, leaving a truncated result reported as complete. Account for that mixed outcome before committing completion.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Silently treating a truncated subagent result as delivered breaks a user-facing agent message workflow.
  • add merge-risk: 🚨 message-delivery: The proposed completion signal can still report a partially sent direct message as fully delivered.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The member-authored PR is exempt from the external contributor proof gate. Its reported Testbox run and new tests exercise dispatch and outbound core with a simulated Discord transport, including rejected and aborted second chunks; the mixed non-send path and registry persistence remain unproven. No stored-data format changes.

Label justifications:

  • P1: Silently treating a truncated subagent result as delivered breaks a user-facing agent message workflow.
  • merge-risk: 🚨 message-delivery: The proposed completion signal can still report a partially sent direct message as fully delivered.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The member-authored PR is exempt from the external contributor proof gate. Its reported Testbox run and new tests exercise dispatch and outbound core with a simulated Discord transport, including rejected and aborted second chunks; the mixed non-send path and registry persistence remain unproven. No stored-data format changes.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/agents/subagents/announce/subagent-announce-text-delivery.test.ts.
  • [P1] node scripts/run-vitest.mjs src/infra/outbound/deliver.test.ts.
  • [P1] node scripts/check-changed.mjs.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Add a mixed-result regression in which the second chunk returns not_sent or no identity, and prove the registry does not record complete delivery.
  • Repair the outbound completion criterion while preserving no automatic replay of confirmed chunks.

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.

Direct text completion previously committed delivery on the first chunk receipt, so later transport failures appeared successful. Settle the single payload after its fanout completes, preserve successful delivery through bookkeeping failures, and retain partial sends for recovery without automatically duplicating confirmed chunks.

Replace callback-scripted bookkeeping tests with real outbound and dispatch coverage in a focused sibling suite. On Blacksmith Testbox, both second-chunk regressions fail on base 9883b72; the candidate passes 323 tests across six suites, check-changed, and independent Codex review.
@steipete
steipete force-pushed the fix/live2-subagent-partial-delivery branch from 050ac02 to 28c7b7f Compare September 26, 2026 21:33
@steipete
steipete merged commit aaaa8e8 into main Sep 26, 2026
194 checks passed
@steipete
steipete deleted the fix/live2-subagent-partial-delivery branch September 26, 2026 22:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
Direct text completion previously committed delivery on the first chunk receipt, so later transport failures appeared successful. Settle the single payload after its fanout completes, preserve successful delivery through bookkeeping failures, and retain partial sends for recovery without automatically duplicating confirmed chunks.

Replace callback-scripted bookkeeping tests with real outbound and dispatch coverage in a focused sibling suite. On Blacksmith Testbox, both second-chunk regressions fail on base 73cbb5d; the candidate passes 323 tests across six suites, check-changed, and independent Codex review.

Co-authored-by: Peter Steinberger <[email protected]>
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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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