Skip to content

fix(reply): preserve explicit routing through block coalescing - #129271

Merged
steipete merged 2 commits into
mainfrom
codex/qa-block-reply-explicit-routing-20260825
Aug 25, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa-block-reply-explicit-routing-20260825

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Preserve the complete original reply payload while streaming text blocks are coalesced.
  • Carry explicit current-message/tag reply intent and authoritative reply metadata through both plain-text and text-plus-media flushes.
  • Delete the lossy field-by-field reconstruction and its duplicate buffered state.

Root cause

The block coalescer decomposed a ReplyPayload into a small hand-maintained list of properties, then rebuilt a new payload. Explicit routing flags were absent from that list, so downstream Telegram delivery could mistake intentional replies for implicit replies and route them to the wrong message. The media merge also lost the buffered routing intent when a later media payload omitted it.

Validation

  • Authentic production pipeline-to-Telegram-owner reproduction: explicit replies previously targeted quoted message 42 instead of the requested message 100; both text and media now retain target 100.
  • OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs run src/auto-reply/reply/block-reply-pipeline.test.ts src/auto-reply/reply/block-reply-pipeline.multi-message.test.ts — 33 tests passed.
  • Broader owner/channel verification previously passed 173 tests.
  • Repository formatter, git diff --check, type-aware lint, and independent Codex autoreview passed.
  • Production change removes 34 lines and introduces no configuration, protocol, or persistence surface.

@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 mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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, 8:25 AM ET / 12:25 UTC.

ClawSweeper review

What this changes

This PR retains the original reply payload while coalescing streamed text, so explicit reply targeting and internal delivery metadata survive text and text-plus-media flushes.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review: the focused coalescer repair removes the current-main reconstruction that drops explicit routing, and no blocking patch defect was found. The PR is maintainer-authored/protected; the remaining work is exact-head validation and the already-running Telegram proof.

Priority: P1
Reviewed head: db13adc4a3130f76861fbfff04bc2963bb033cb4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a clean owner-boundary simplification with focused regression coverage; exact-head CI and the running Telegram proof remain useful merge evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body records a production-path Telegram-owner reproduction, and Telegram Desktop proof is already running.
Patch quality 🦞 diamond lobster (5/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 a production-path Telegram-owner reproduction, and Telegram Desktop proof is already running.
Evidence reviewed 5 items Current-main defect: The current coalescer reconstructs a text payload from a fixed field list, omitting replyToCurrent and replyToTag even though they are members of ReplyPayload.
Delivery consequence: Block delivery uses replyToCurrent to choose whether the current message may become the reply target, so dropping that field changes observable routing.
Patch and regression coverage: The PR stores the original buffered payload, replaces only its text at flush, and adds text/media cases covering reply-to-current, explicit-tag routing, and metadata retention.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129271-HiiSVr/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 106.38 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.6s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 13.3s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 3680ms (slowest: built plugin control-plane loads 2763ms)

OpenClaw 2026.8.1 (db13adc) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw [options] [command]

How this fits together

Streaming reply blocks enter the block-reply pipeline, which coalesces them before passing one payload to channel delivery. Routing fields on that payload determine which incoming message Telegram and other channel owners reply to.

flowchart LR
  A[Streaming reply blocks] --> B[Block reply pipeline]
  B --> C[Block coalescer]
  C --> D[Combined reply payload]
  D --> E[Channel delivery owner]
  E --> F[Requested reply target]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as behind main; refresh exact-head CI against the actual merge result before landing, without treating that drift as a code regression.
  • Complete next step (P2) - This protected maintainer PR has no concrete automated repair task; normal exact-head validation and maintainer merge review remain.
Agent review details

Security

None.

PR surface

Source -33, Tests +55. Total +22 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 31 64 -33
Tests 1 55 0 +55
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 86 64 +22

Review metrics

Metric Value Why it matters
Production versus test delta production +31/-64 (net -33); tests +55/-0 The bug fix removes the manual payload projection while adding four routing-and-metadata regression cases.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/auto-reply/reply/block-reply-pipeline.test.ts. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A Telegram Desktop transcript can directly show that a coalesced reply remains attached to the requested message rather than an implicit quoted message. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify that a coalesced text-and-media explicit reply remains attached to the requested message.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one canonical buffered ReplyPayload and alter only its coalesced text, preserving media-specific fields when a media payload joins the buffer.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one canonical buffered ReplyPayload and alter only its coalesced text, preserving media-specific fields when a media payload joins the buffer.

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

Yes, at high confidence from source: coalescing a payload with replyToCurrent or replyToTag reaches the current field list, which omits both fields before delivery reads replyToCurrent. The review did not execute the reproduction because this checkout is read-only.

Is this the best way to solve the issue?

Yes. Preserving the original buffered payload and replacing only text fixes the owner-boundary loss without adding a Telegram-specific exception or another parallel routing path.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: Explicit reply routing can visibly attach a channel response to the wrong message.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • 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 a production-path Telegram-owner reproduction, and Telegram Desktop proof is already running.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The change affects the visible Telegram reply anchor, which a short Telegram Desktop before/after proof can demonstrate.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Blame attributes the current lossy reconstruction to the earlier coalescer commit, and the reviewed PR continues work in the same owner module. (role: introduced affected coalescer behavior and recent area contributor; confidence: high; commits: c90786592684, db13adc4a313; files: src/auto-reply/reply/block-reply-coalescer.ts, src/auto-reply/reply/block-reply-pipeline.test.ts)

Rank-up moves

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

  • Refresh exact-head CI for the actual merge result and attach the redacted Telegram Desktop outcome from the active proof run.

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 (1 earlier review cycle)
  • reviewed 2026-08-25T11:43:09.078Z sha db13adc :: needs maintainer review before merge. :: none

@openclaw-mantis

openclaw-mantis Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Mantis Telegram proof — PASS

Summary: Baseline lost explicit block-reply routing and replied to the older quoted message; candidate retained the routing intent and replied to the current Telegram request.

  • Scenario: A real Telegram user sent a current request as a reply to an older anchor. In each exact SUT, the production block-reply pipeline coalesced a payload carrying replyToCurrent and replyToTag, then the real Telegram sender delivered the result to the live chat.
  • Trigger: clawsweeper_label
  • Run: https://github.com/openclaw/openclaw/actions/runs/32845772087
  • Artifact: https://github.com/openclaw/openclaw/actions/runs/32845772087/artifacts/9563406298
  • Baseline: pass at 0b867e14fe1cf50fc2a657a4beeeab1af0b90725 — With older anchor 50910 and current request 50930, bot message 50931 replied to anchor 50910. The recorded Bot API request likewise used reply_to_message_id 50910.
  • Candidate (PR merged onto main): pass at 74606a538215b08a17052c102dc210a382b965e7 — With older anchor 50932 and current request 50934, bot message 50935 replied to current request 50934. The recorded Bot API request likewise used reply_to_message_id 50934.
  • Differential (trusted facts): The same production pipeline boundary and live Telegram delivery changed from old-anchor routing on baseline to current-message routing on candidate. This exactly matches the pull request's claimed repair: preserving explicit reply routing through block coalescing.
  • Overall: pass
Before — current main After — this PR
baseline previewGifCropped candidate previewGifCropped

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-visible/pr-129271/run-32845772087-1/index.json

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 25, 2026
@steipete
steipete merged commit 1e68499 into main Aug 25, 2026
244 checks passed
@steipete
steipete deleted the codex/qa-block-reply-explicit-routing-20260825 branch August 25, 2026 13:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…law#129271)

* fix(reply): preserve explicit routing through block coalescing

* fix(reply): narrow buffered payload before reading visibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. 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