Skip to content

fix(outbound): prevent empty chunkers from silently dropping replies - #128288

Merged
steipete merged 1 commit into
mainfrom
codex/outbound-empty-chunker-owner-20260823
Aug 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/outbound-empty-chunker-owner-20260823

Conversation

@steipete

@steipete steipete commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Prevents normal outbound replies from disappearing completely when a channel-specific text chunker unexpectedly returns no parts for a nonempty message.

Why This Change Was Made

The newline chunking branch already preserved nonempty text after an empty adapter chunk result, but default and length-based chunking silently produced zero platform sends. Move that existing invariant into the single shared chunk-planning owner and delete the duplicate newline-only recovery branch.

User Impact

Visible replies are delivered across every chunking mode instead of being silently lost or misreported as lacking a platform receipt. Existing reply-to consumption, delivery-part numbering, and formatting behavior are preserved.

Evidence

  • Added one table-driven owner regression covering default, length, and newline chunking with implicit reply ownership and exact send-part topology.
  • On untouched main, default and length cases failed with zero planned sends; newline already passed, proving the intended sibling behavior.
  • node scripts/run-vitest.mjs src/infra/outbound/message-plan.test.ts src/infra/outbound/reply-policy.test.ts — 11 tests passed.
  • Targeted formatting, lint, and git diff --check passed.
  • Independent structured Codex review found no actionable issues.
  • Production delta: +2/-4 lines (net -2); no public configuration, protocol, persistence, or plugin contract changes.

ClawSweeper Rank-Up Review

  • Exact-head required CI is green. Skipped the suggested refresh-only rebase because the PR remains mergeable and repository landing policy avoids rebasing solely because main advanced.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 23, 2026
@steipete
steipete marked this pull request as ready for review August 23, 2026 16:48
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 23, 2026, 3:36 PM ET / 19:36 UTC.

ClawSweeper review

What this changes

The PR makes the core outbound planner send one nonempty text unit when its channel chunker returns no chunks, with regression coverage for default, length, and newline modes.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The core planner repair is sound, but the same empty-chunker drop remains in public SDK delivery helpers used by custom channel adapters; merge after that shared invariant is applied there too.

Priority: P1
Reviewed head: 71b7aec0f999fd1e273592565cedc7cbb2a97726

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused core repair is clean, but a high-impact sibling delivery path remains unprotected.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the PR body supplies focused test evidence, but it does not cover the remaining SDK paths.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the PR body supplies focused test evidence, but it does not cover the remaining SDK paths.
Evidence reviewed 8 items Core repair: The branch moves the nonempty-text fallback into the shared core planner, so its default and newline planning paths receive one text unit after an empty chunk result.
Core caller: The normal delivery path calls the planner before iterating and sending planned text units, so the branch fixes that owner boundary.
Remaining SDK drop: The SDK already defines a full-text fallback, but its custom-adapter text sender calls the chunker directly and returns the empty result when no first chunk exists.
Findings 1 actionable finding [P1] Apply the fallback in the SDK delivery paths
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/infra/outbound/message-plan.test.ts src/plugin-sdk/reply-payload.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs src/infra/outbound/message-plan.test.ts src/plugin-sdk/reply-payload.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128288-PlmGBF/target$ node scripts/run-vitest.mjs src/infra/outbound/message-plan.test.ts src/plugin-sdk/reply-
payload.test.ts
node scripts/run-vitest.mjs src/infra/outbound/message-plan.test.ts src/plugin-sdk/reply-payload.test.ts
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128288-PlmGBF/target

 ✓  unit-fast  src/infra/outbound/message-plan.test.ts (7 tests) 5ms

 Test Files  1 passed (1)
      Tests  7 passed (7)
   Start at  19:37:31
   Duration  712ms (transform 460ms, setup 87ms, import 497ms, tests 5ms, environment 0ms)

[test] starting test/vitest/vitest.plugin-sdk.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128288-PlmGBF/target

































Assertions:

  • PASS expect_output: Test Files

How this fits together

Outbound delivery turns normalized agent reply text into channel send operations. Most channels use the core planner, while custom adapter paths call Plugin SDK delivery helpers directly before sending to their transports.

flowchart LR
A[Agent reply text] --> B[Delivery routing]
B --> C[Core message planner]
B --> D[Custom channel adapter]
C --> E[Channel chunker]
D --> F[Plugin SDK chunking helper]
E --> G[Platform sends]
F --> G
Loading

Before merge

  • Apply the fallback in the SDK delivery paths (P1) - The core planner fallback does not cover custom adapters: both SDK delivery helpers still consume an empty chunker result without sending text, even though resolveTextChunksWithFallback already defines the intended behavior. Zalo's custom sendPayload takes this route. This sibling-path gap was present at the prior reviewed head and is raised late; use the helper at both callers and add behavior-level regression coverage.
  • Resolve merge risk (P1) - Merging now leaves custom adapters that bypass the core planner able to silently drop a nonempty reply when their chunker returns no parts.

Findings

  • [P1] Apply the fallback in the SDK delivery paths — src/plugin-sdk/reply-payload.ts:218-221
Agent review details

Security

None.

PR surface

Source -2, Tests +33. Total +31 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 4 -2
Tests 1 33 0 +33
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 35 4 +31

Review metrics

Metric Value Why it matters
Production versus test delta production +2/-4 (net -2); tests +33/-0 The core repair is net-negative and adds one table-driven planner test, but that test does not exercise SDK custom-adapter delivery.

Merge-risk options

Maintainer options:

  1. Finish the shared delivery repair (recommended)
    Route both SDK text-delivery chunker results through the existing nonempty-text fallback and cover each delivery helper before merge.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Use the existing resolveTextChunksWithFallback helper at both raw chunker call sites in src/plugin-sdk/reply-payload.ts, add behavior-level empty-chunker regressions for both delivery helpers, and run the focused SDK and outbound tests.

Technical review

Best possible solution:

Use the existing SDK fallback at both raw SDK chunker call sites and add behavior-level regressions so core and custom-adapter delivery share the no-silent-drop invariant.

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

Yes, source reproduces it: a nonempty text payload plus a chunker returning [] reaches the SDK raw chunk loops, causing zero sends and an empty or undefined result.

Is this the best way to solve the issue?

No; centralizing the core planner fallback is the right partial repair, but the existing SDK delivery owners still bypass it and already expose the same fallback abstraction.

Full review comments:

  • [P1] Apply the fallback in the SDK delivery paths — src/plugin-sdk/reply-payload.ts:218-221
    The core planner fallback does not cover custom adapters: both SDK delivery helpers still consume an empty chunker result without sending text, even though resolveTextChunksWithFallback already defines the intended behavior. Zalo's custom sendPayload takes this route. This sibling-path gap was present at the prior reviewed head and is raised late; use the helper at both callers and add behavior-level regression coverage.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 message-delivery: The incomplete shared fix can preserve silent reply loss for channels whose custom adapters bypass the core planner.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool 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: This maintainer-authored PR is exempt from the external-contributor proof gate; the PR body supplies focused test evidence, but it does not cover the remaining SDK paths.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: A nonempty normal reply can still complete with zero platform sends on custom channel delivery paths.
  • merge-risk: 🚨 message-delivery: The incomplete shared fix can preserve silent reply loss for channels whose custom adapters bypass the core planner.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the PR body supplies focused test evidence, but it does not cover the remaining SDK paths.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/infra/outbound/message-plan.test.ts src/plugin-sdk/reply-payload.test.ts.
  • [P1] node scripts/check-changed.mjs -- src/infra/outbound/message-plan.ts src/infra/outbound/message-plan.test.ts src/plugin-sdk/reply-payload.ts src/plugin-sdk/reply-payload.test.ts.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the planner and SDK chunking paths to their recent outbound/SDK work, and the submitted branch continues that area. (role: recent outbound and SDK contributor; confidence: high; commits: 47484dc8ccb9, 71b7aec0f999; files: src/infra/outbound/message-plan.ts, src/plugin-sdk/reply-payload.ts)

Rank-up moves

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

  • Apply the existing SDK fallback in both delivery helpers and add empty-chunker behavior tests for those helpers.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-23T16:56:02.019Z sha 71b7aec :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T17:39:46.054Z sha 71b7aec :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added 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. and removed 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. labels Aug 23, 2026
@steipete
steipete merged commit eb0118b into main Aug 23, 2026
317 checks passed
@steipete
steipete deleted the codex/outbound-empty-chunker-owner-20260823 branch August 23, 2026 20:22
@steipete

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

maintainer Maintainer-authored PR 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: XS 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