fix: Preserve Telegram hooks when flushing buffered finals#83670
fix: Preserve Telegram hooks when flushing buffered finals#83670bpconnor3-r2 wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. Source inspection on current main shows a final payload split into reasoning and answer segments can buffer the answer and then return from the segmented-delivery branch without flushing it; I did not run the test lane in this read-only review. PR rating Rank-up moves:
What the crustacean ranks mean
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. PR egg Rarity: 🥚 common. What is this egg doing here?
Real behavior proof Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land this focused Telegram dispatcher fix after maintainer review and required checks, or request independent Telegram live proof if maintainers want unredacted transport confirmation before merging. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows a final payload split into reasoning and answer segments can buffer the answer and then return from the segmented-delivery branch without flushing it; I did not run the test lane in this read-only review. Is this the best way to solve the issue? Yes. The PR keeps the fix inside Telegram segmented-final delivery, flushes only final buffered answers, and reuses the existing preview-finalized hook/transcript path rather than adding a competing delivery mechanism. Label justifications:
Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3e6f7494af75. |
|
Additional downstream evidence from R2 after an OpenClaw package update:
Post-patch R2 verification: Recent Telegram sends after the restart were recorded in the gateway journal, including outbound |
|
Heads up: this PR needs to be updated against current |
Summary
message:senthook and transcript mirror when the buffered answer flushesWhy this PR exists
This is a hook-preserving replacement for the canonical fix path in #53762. PR #53762 has the right user-visible fix direction, but ClawSweeper flagged that its
flushBufferedFinalAnswer()path discards theLaneDeliveryResult, so a buffered final answer can display in Telegram while bypassing the same preview-finalized hook/transcript path used by ordinary final segment delivery.I cannot update #53762 directly, so this branch rebases the fix onto current
mainand addresses that review finding in the replacement patch.Root cause
When Telegram final output is split into reasoning and answer lane segments, the reasoning segment can be handled/skipped without marking reasoning as delivered. The answer segment is then buffered, but the
segments.length > 0branch returns before the buffered final answer is drained.A minimal flush fixes visible Telegram delivery, but the flush also needs to route any
preview-finalizedLaneDeliveryResultthroughemitPreviewFinalizedHook(...); otherwise internalmessage:sentand transcript mirroring diverge from normal final delivery.Real behavior proof
2026.5.12, systemd user gateway, Telegram channel enabled, real allowlisted direct Telegram chat, direct-message visible replies set to automatic.R2_AUTO_OK_SIM, then ran the live health sequence includingcurl -sS http://127.0.0.1:18789/health,systemctl --user status openclaw-gateway.service --no-pager -l,openclaw gateway status, and the downstream hotfix checker./healthreturned{"ok":true,"status":"live"}; the downstream checker printedOpenClaw Telegram auto-delivery hotfix present; the Telegram sent-message cache recorded the outbound Bot API delivery at2026-05-18T12:45:28Z, message id27371; nomessage.actionsend tool was used.R2_AUTO_OK_SIM, and Telegram automatic delivery sent that visible answer through the Bot API instead of leaving it buffered and unsent.Additional redacted proof context is posted on #53762: #53762 (comment)
Validation
git diff --checkOPENCLAW_VITEST_INCLUDE_FILE=/tmp/openclaw-telegram-include-v2.json node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-telegram.config.tsextensions/telegram/src/bot-message-dispatch.test.tspassed, 68 testsNote: I also tried
node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-telegram.config.ts bot-message-dispatch.test.ts, but that CLI-filter form reportedNo test files found, so I am not counting it as validation.Related