Skip to content

fix(reply): dedupe duplicate non-streaming final replies#100828

Merged
vincentkoc merged 4 commits into
mainfrom
clownfish/gitcrawl-1325-autonomous-drip-20260706
Jul 6, 2026
Merged

fix(reply): dedupe duplicate non-streaming final replies#100828
vincentkoc merged 4 commits into
mainfrom
clownfish/gitcrawl-1325-autonomous-drip-20260706

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Jul 6, 2026

Copy link
Copy Markdown
Member

Fixes #84623.

What Problem This Solves

Non-streaming dispatchReplyFromConfig could deliver byte-identical final payload entries twice for one turn.

Why This Change Was Made

The shared final-dispatch loop now keeps a per-turn key over delivery-visible payload fields and routing identity. Exact duplicate finals are suppressed, while same-content replies remain deliverable when they come from distinct assistant messages, route to different accounts, or carry different explicit reply-threading identity.

User Impact

Channels using non-streaming final replies no longer send duplicate identical text or media payloads for one inbound turn, without collapsing intentional repeated replies.

Evidence

  • Focused regression coverage for exact duplicate payloads and three distinct-identity negative controls.
  • 66 focused local tests passed.
  • 58 focused remote tests passed.
  • The two affected QA scenarios passed after the harness wait-envelope fix landed on main.
  • pnpm check:changed passed in the guarded validation lane.
  • Rebased through the native fork-update path onto current main.
  • Fresh exact-head hosted CI is running on a5f6c13efb61e60f4ad454bc8cebc3d6a1798190.

@vincentkoc vincentkoc added the clownfish Tracked by Clownfish automation label Jul 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 6, 2026
@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Jul 6, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 6, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper

clawsweeper Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 6, 2026, 7:16 AM ET / 11:16 UTC.

Summary
The branch adds a per-turn dedupe key in dispatchReplyFromConfig, regression tests for duplicate and intentionally distinct final payloads, and a release-note entry.

PR surface: Source +45, Tests +104, Docs +1. Total +150 across 3 files.

Reproducibility: yes. at source level: current main sends every replyResult array entry through final delivery, and the linked issue includes duplicate media-delivery logs from an affected channel. I did not run a live affected-channel reproduction in this read-only review.

Review metrics: 1 noteworthy metric.

  • Release-owned changelog edits: 1 added entry. CHANGELOG.md is release-owned, so this normal fix PR should keep release-note context in the PR body or squash message instead.

Stored data model
Persistent data-model change detected: serialized state: src/auto-reply/reply/dispatch-from-config.ts, vector/embedding metadata: CHANGELOG.md, vector/embedding metadata: src/auto-reply/reply/dispatch-from-config.reply-dispatch.test.ts, vector/embedding metadata: src/auto-reply/reply/dispatch-from-config.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #84623
Summary: This PR is the live candidate fix for the canonical duplicate non-streaming final reply issue; the earlier candidate with the same root is closed unmerged.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Remove the added CHANGELOG.md entry and keep release-note context in the PR body or squash message.
  • [P2] Maintainers should decide whether the current dispatcher-level tests are enough or whether affected-transport proof is required.

Risk before merge

  • [P1] The new shared final-payload dedupe intentionally skips repeated final deliveries; if the key misses a transport-visible distinction, a legitimate repeated final message could be dropped.
  • [P1] I did not run the affected WeChat/openclaw-weixin path in this read-only review; the evidence is source-level behavior, PR tests, and CI status.

Maintainer options:

  1. Accept Dispatcher Coverage (recommended)
    After removing the release-owned changelog line, maintainers can land the dispatcher dedupe with existing identity tests while owning the residual live-transport proof risk.
  2. Ask For Transport Proof
    Require redacted affected-channel or near-real transport evidence showing duplicate final payloads collapse to one visible send after the patch.
  3. Pause The Replacement PR
    Keep this PR paused if maintainers are not ready to accept a shared dispatcher dedupe without broader identity coverage.

Next step before merge

  • A narrow automated cleanup can remove the release-owned changelog entry; maintainer review still owns final acceptance of the shared message-delivery risk.

Maintainer decision needed

  • Question: Should this shared final-dispatch dedupe land with the current source-level identity tests, or require affected-transport duplicate-delivery proof before merge?
  • Rationale: The diff changes shared message-delivery behavior; source and tests support the dispatcher as the right layer, but only maintainer intent can decide the proof bar for a live transport that was not exercised here.
  • Likely owner: vincentkoc — They are both the current PR owner and a recent contributor to adjacent reply payload dedupe/history paths.
  • Options:
    • Accept Source-Level Coverage After Cleanup (recommended): Remove the release-owned changelog entry, then land if maintainers accept the focused dispatcher and identity-preservation tests for this bounded bug.
    • Require Affected-Transport Proof: Keep the PR open until redacted WeChat/openclaw-weixin or near-real transport output shows duplicate final payload input producing one delivered message or media upload.
    • Pause For Broader Identity Audit: Hold the PR if maintainers want additional coverage for every transport-visible distinction before changing shared final delivery.

Security
Cleared: The diff changes TypeScript reply-dispatch logic, colocated tests, and a changelog entry; it does not touch dependencies, CI, secrets, install scripts, package resolution, or generated code.

Review findings

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:24
Review details

Best possible solution:

Remove the release-owned changelog line, keep the shared dispatcher-level dedupe with identity-preservation tests, and have a maintainer accept whether source-level proof is enough before merge.

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

Yes at source level: current main sends every replyResult array entry through final delivery, and the linked issue includes duplicate media-delivery logs from an affected channel. I did not run a live affected-channel reproduction in this read-only review.

Is this the best way to solve the issue?

Likely yes: the shared dispatch loop is the maintainable choke point because buildReplyPayloads only dedupes message-tool/direct-block evidence and custom resolvers still flow through dispatchReplyFromConfig. The PR should drop the release-owned changelog edit before merge.

Full review comments:

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:24
    OpenClaw's repository policy says CHANGELOG.md is release-owned and normal PRs should keep release-note context in the PR body or squash message. This added entry bypasses that release-generation flow; remove it from the branch and leave the context in the PR body.
    Confidence: 0.93

Overall correctness: patch is correct
Overall confidence: 0.87

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: The PR targets a credible user-visible duplicate text/media final-delivery bug with a bounded shared-dispatcher surface.
  • add merge-risk: 🚨 message-delivery: The diff changes shared final reply delivery and could suppress a legitimate repeated final if the identity key is too broad.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is maintainer-authored and labeled maintainer, so the external-contributor real behavior proof gate does not apply; I did not run tests in this read-only review.

Label justifications:

  • P2: The PR targets a credible user-visible duplicate text/media final-delivery bug with a bounded shared-dispatcher surface.
  • merge-risk: 🚨 message-delivery: The diff changes shared final reply delivery and could suppress a legitimate repeated final if the identity key is too broad.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is maintainer-authored and labeled maintainer, so the external-contributor real behavior proof gate does not apply; I did not run tests in this read-only review.
Evidence reviewed

PR surface:

Source +45, Tests +104, Docs +1. Total +150 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 45 0 +45
Tests 1 104 0 +104
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 150 0 +150

Acceptance criteria:

  • [P1] git diff --check.
  • [P1] git diff -- CHANGELOG.md.

What I checked:

  • Repository policy read: Root AGENTS.md was read fully; its whole-path PR review guidance and release-owned changelog rule apply to this PR. (AGENTS.md:29, 827402243d7f)
  • Current main final loop: Current main normalizes replyResult to an array and sends each non-suppressed entry through sendFinalPayload without a per-turn final-payload dedupe set. (src/auto-reply/reply/dispatch-from-config.ts:3845, 827402243d7f)
  • PR dedupe implementation: The PR head adds createFinalDispatchPayloadDedupeKey and checks a per-turn sentFinalPayloadDedupeKeys set after suppression and before final delivery. (src/auto-reply/reply/dispatch-from-config.ts:209, bd4411abc06a)
  • PR regression coverage: The PR head adds tests that collapse byte-identical finals while preserving same-content finals with distinct route, threading, and assistant-message identity. (src/auto-reply/reply/dispatch-from-config.reply-dispatch.test.ts:353, bd4411abc06a)
  • Release-owned changelog rule: AGENTS.md states CHANGELOG.md is release-only and normal PRs should keep release-note context in PR body, squash message, or direct commit instead. (AGENTS.md:238, 827402243d7f)
  • Related canonical issue: Live GitHub data shows this PR closes the open canonical duplicate non-streaming final reply issue, and search found the closed unmerged prior candidate PR for the same wording.

Likely related people:

  • vincentkoc: Recent main history includes reply payload dedupe helper extraction and target-aware duplicate-delivery work adjacent to this final payload identity boundary. (role: recent adjacent contributor; confidence: high; commits: 125e778fe618, 8a74724cb4f1; files: src/auto-reply/reply/reply-payloads-dedupe.ts, src/auto-reply/reply/agent-runner-payloads.ts, src/auto-reply/reply/block-reply-pipeline.ts)
  • steipete: Introduced the reply dispatch hook and split reply-dispatch regression tests, both central to the dispatcher boundary this PR changes. (role: feature-history owner; confidence: high; commits: 82ce30b7895a, 0e96c82ce8d2; files: src/auto-reply/reply/dispatch-from-config.ts, src/auto-reply/reply/dispatch-from-config.reply-dispatch.test.ts)
  • mathiasnagler: Authored the merged Mattermost duplicate-message fix in sibling block/final reply dedupe surfaces, useful context for preserving legitimate delivery distinctions. (role: adjacent duplicate-delivery fix author; confidence: medium; commits: e8a162d3d8a0, 3c07c19dcaba; files: src/auto-reply/reply/agent-runner-payloads.ts, src/auto-reply/reply/block-reply-pipeline.ts, src/auto-reply/reply/reply-delivery.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 6, 2026
@vincentkoc
vincentkoc requested review from a team as code owners July 6, 2026 11:42
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: acpx extensions: anthropic extensions: openai extensions: memory-wiki extensions: codex labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@vincentkoc
vincentkoc force-pushed the clownfish/gitcrawl-1325-autonomous-drip-20260706 branch from f4a33b5 to d347f57 Compare July 6, 2026 11:59
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 6, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle openclaw-barnacle Bot added app: android App: android app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: diagnostics-otel Extension: diagnostics-otel cli CLI command changes scripts Repository scripts agents Agent runtime and tooling extensions: qa-lab extensions: opencode-go extensions: xai size: XL and removed size: S labels Jul 6, 2026
@vincentkoc
vincentkoc merged commit bab1415 into main Jul 6, 2026
176 of 178 checks passed
@vincentkoc
vincentkoc deleted the clownfish/gitcrawl-1325-autonomous-drip-20260706 branch July 6, 2026 13:21
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…0828)

* fix(reply): dedupe duplicate non-streaming final replies

* fix(reply): preserve distinct final delivery identities

* chore(reply): drop release-owned changelog entry

* chore(reply): drop release-owned changelog entry

---------

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
…0828)

* fix(reply): dedupe duplicate non-streaming final replies

* fix(reply): preserve distinct final delivery identities

* chore(reply): drop release-owned changelog entry

* chore(reply): drop release-owned changelog entry

---------

Co-authored-by: openclaw-clownfish[bot] <280122609+openclaw-clownfish[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: macos App: macos app: web-ui App: web-ui cli CLI command changes clownfish Tracked by Clownfish automation extensions: diagnostics-otel Extension: diagnostics-otel extensions: opencode-go extensions: qa-lab extensions: xai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

Non-streaming dispatchReplyFromConfig delivers final reply payload twice

1 participant