Skip to content

fix(reply): prevent deduplicated follow-ups from losing threaded replies - #129123

Merged
steipete merged 2 commits into
mainfrom
codex/followup-media-dedupe-empty-reply-qa
Aug 25, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/followup-media-dedupe-empty-reply-qa

Conversation

@steipete

@steipete steipete commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users would receive no reply, lose the expected threaded reply, or receive a duplicate Slack reply when a messaging tool had already delivered media or text during a queued follow-up.

Why This Change Was Made

Follow-up delivery applied stateful first/batched reply threading before message-tool deduplication. Duplicate payloads consequently consumed the single-use reply slot, deduplicated media survived as an empty but explicitly deliverable reply, and empty replies blocked recovery of a substantive assistant final. Naively reversing the order also changed Slack's actual thread destination, so the canonical threading owner now supports a side-effect-free route preview: deduplication sees the eventual transport destination, while the reply slot is committed only after a visible payload survives.

Production delta: +24/-18 (net +6), justified by the new owner-level preview/commit boundary that preserves actual channel routing while preventing discarded payloads from consuming state; the obsolete threading barrel export was removed. Tests: +102/-2.

User Impact

Previously sent media never suppresses a real assistant answer, duplicate media or text never steals the first threaded reply, substantive message-tool-only answers recover normally, and Slack replies are deduplicated against their actual transport thread.

Evidence

  • Authentic pre-fix owner regressions: already-sent media returned an empty payload; duplicate media/text consumed both first and batched threading slots; a substantive final returned an empty deliver decision instead of retry-source-delivery.
  • Independent review caught and reproduced an additional real Slack route regression in the initial naive reorder; the final change preserves the registered Slack threading adapter's actual destination and suppresses its already-sent cross-thread duplicate.
  • node scripts/run-vitest.mjs src/auto-reply/reply/followup-delivery.test.ts src/auto-reply/reply/followup-delivery.channel.test.ts src/auto-reply/reply/reply-payloads.test.ts src/auto-reply/reply/reply-threading.test.ts src/auto-reply/reply/agent-runner-payloads.test.ts src/auto-reply/reply/reply-plumbing.test.ts: 212 passed, 1 existing skipped.
  • Focused lint, production/full-tree unused-export checks, assertion-safety ratchet, max-lines ratchet, and final fresh independent source-aware owner/sibling review all pass.

@clawsweeper

clawsweeper Bot commented Aug 25, 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: S maintainer Maintainer-authored PR labels Aug 25, 2026
@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 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 4:02 AM ET / 08:02 UTC.

ClawSweeper review

What this changes

The PR prevents deduplicated queued follow-up payloads from consuming a one-time threaded-reply slot while retaining channel-specific route-aware deduplication.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. Current main retains the pre-deduplication threading order; this active maintainer PR moves route preview and single-use reply-slot commitment into the canonical threading owner, with no blocking defect found.

Priority: P1
Reviewed head: ee0817bc1cdebcadd05755de9caed6bf4748f7ef

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused owner and channel-boundary coverage supports a clean repair; exact-head CI remains the routine merge gate.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records focused owner-boundary test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records focused owner-boundary test evidence.
Evidence reviewed 6 items Current main still has the defect ordering: Current main applies stateful reply threading to all sanitized payloads before message-tool deduplication, allowing a later-discarded payload to consume the single-use slot.
Stateful owner provenance: Blame maps the existing hasThreaded state transition to the recent reply-threading implementation; current main has no intervening change from the PR base on this surface.
Canonical repair: The branch previews the eventual route for deduplication, removes non-renderable remnants, and commits reply threading only for the payload that survives.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/auto-reply/reply/followup-delivery.test.ts src/auto-reply/reply/followup-delivery.channel.test.ts src/auto-reply/reply/reply-payloads.test.ts src/auto-reply/reply/reply-threading.test.ts src/auto-reply/reply/agent-runner-payloads.test.ts src/auto-reply/reply/reply-plumbing.test.ts

Result: PASS (completed)

runner@runnervm76f27:/tmp/clawsweeper-live-proof-129123-dDX2yZ/target$ node scripts/run-vitest.mjs src/auto-reply/reply/followup-delivery.test.ts src/auto-reply
/reply/followup-delivery.channel.test.ts src/auto-reply/reply/reply-payloads.test.ts src/auto-reply/reply/reply-threading.test.ts src/auto-reply/reply/agent-run
ner-payloads.test.ts src/auto-reply/reply/reply-plumbing.test.ts
[test] starting test/vitest/vitest.auto-reply.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129123-dDX2yZ/target

node scripts/run-vitest.mjs src/auto-reply/reply/followup-delivery.test.ts src/auto-reply/reply/followup-delivery.channel.test.ts src/auto-reply/reply/reply-pay
loads.test.ts src/auto-reply/reply/reply-threading.test.ts src/auto-reply/reply/agent-runner-payloads.test.ts src/auto-reply/reply/reply-plumbing.test.ts
 ✓  auto-reply  src/auto-reply/reply/reply-payloads.test.ts (38 tests | 1 skipped) 137ms
 ✓  auto-reply  src/auto-reply/reply/reply-plumbing.test.ts (30 tests) 43ms
 ✓  auto-reply  src/auto-reply/reply/agent-runner-payloads.test.ts (67 tests) 181ms
 ✓  auto-reply  src/auto-reply/reply/reply-threading.test.ts (9 tests) 8ms
 ✓  auto-reply  src/auto-reply/reply/followup-delivery.test.ts (59 tests) 61ms
 ✓  auto-reply  src/auto-reply/reply/followup-delivery.channel.test.ts (10 tests) 265ms

 Test Files  6 passed (6)
      Tests  212 passed | 1 skipped (213)
   Start at  08:03:46
   Duration  15.89s (transform 32.11s, setup 3.78s, import 39.57s, tests 695ms, environment 1ms)

[test] passed 1 Vitest shard in 22.28s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129123-dDX2yZ/target$ node scripts/run-vitest.mjs src/auto-reply/reply/followup-delivery.test.ts src/auto-reply
/reply/followup-delivery.channel.test.ts src/auto-reply/reply/reply-payloads.test.ts src/auto-reply/reply/reply-threading.test.ts src/auto-reply/reply/agent-run
ner-payloads.test.ts src/auto-reply/reply/reply-plumbing.test.ts


























Assertions:

  • PASS expect_output: passed

How this fits together

Queued follow-up responses are normalized, assigned a reply route, deduplicated against message-tool sends, and then delivered to the originating channel. The changed boundary decides which visible payload earns a single threaded-reply slot.

flowchart LR
  A[Queued follow-up payloads] --> B[Reply route preview]
  B --> C[Route-aware deduplication]
  C --> D{Visible payload remains}
  D -->|No| E[Discard without consuming slot]
  D -->|Yes| F[Commit reply threading]
  F --> G[Channel delivery]
Loading

Before merge

  • Resolve merge risk (P2) - The production diff is net +6 lines; this is warranted by the explicit preview-versus-commit ownership boundary, but it should remain localized to reply threading rather than be duplicated in deduplication callers.
  • Resolve merge risk (P1) - Exact-head preflight is still in progress, so merge readiness is not yet established.
  • Complete next step (P2) - This active maintainer PR remains necessary; complete ordinary exact-head validation rather than dispatching a replacement repair.
Agent review details

Security

None.

PR surface

Source +6, Tests +100. Total +106 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 24 18 +6
Tests 4 102 2 +100
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 126 20 +106

Review metrics

Metric Value Why it matters
Production versus test LOC production +24/-18 (net +6); tests +102/-2 (net +100) The small production increase creates the required preview/commit state boundary; the test growth covers state ordering, route matching, and recovery.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the single canonical threading filter with its side-effect-free preview, then deduplicate and commit only surviving payloads; no net-neutral refactor can remove that lifecycle distinction without moving state ownership downstream.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the single canonical threading filter with its side-effect-free preview, then deduplicate and commit only surviving payloads; no net-neutral refactor can remove that lifecycle distinction without moving state ownership downstream.

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

Yes, from source: current main commits the stateful single-use threading filter before deduplication, while the new tests exercise the resulting discarded-first-payload case.

Is this the best way to solve the issue?

Yes. Previewing the existing channel-aware threading owner before deduplication preserves actual transport routing while delaying its only state mutation until a visible payload remains.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The repair addresses a channel workflow that can otherwise suppress an expected follow-up reply or emit a duplicate.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records focused owner-boundary test evidence.

Label justifications:

  • P1: The repair addresses a channel workflow that can otherwise suppress an expected follow-up reply or emit a duplicate.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records focused owner-boundary test evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main history shows repeated ownership of the central follow-up delivery and reply-threading refactors. (role: recent area contributor; confidence: high; commits: c4dccc614d0f, f8cc39ce6213, 6335d9777138; files: src/auto-reply/reply/followup-delivery-payloads.ts, src/auto-reply/reply/reply-threading.ts)
  • sandieman2: History attributes an earlier routed-thread deduplication repair to this contributor. (role: earlier follow-up delivery contributor; confidence: medium; commits: c67dc59b02b0; files: src/auto-reply/reply/followup-delivery-payloads.ts)

Rank-up moves

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

  • Let the in-progress exact-head preflight check finish before merge.

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.

@steipete
steipete merged commit 0f95468 into main Aug 25, 2026
241 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/followup-media-dedupe-empty-reply-qa branch August 25, 2026 08:20
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…ies (openclaw#129123)

* fix(reply): dedupe follow-ups before consuming reply threads

* refactor(reply): remove obsolete threading re-export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant