fix(telegram): preserve debounce for partial draft fragments#80045
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. source-level reproduction is high confidence: current main keeps the 30-character first-preview debounce and the draft stream suppresses first previews below that threshold. A token-shaped partial forwarded as text-only can therefore remain invisible until final delivery; I did not run a live Telegram bot in this read-only review. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Keep the Telegram-side accumulator, but complete the contract by preserving or recomputing partial Do we have a high-confidence way to reproduce the issue? Yes, source-level reproduction is high confidence: current main keeps the 30-character first-preview debounce and the draft stream suppresses first previews below that threshold. A token-shaped partial forwarded as text-only can therefore remain invisible until final delivery; I did not run a live Telegram bot in this read-only review. Is this the best way to solve the issue? No. The Telegram accumulator is a maintainable shape, but the PR must also carry or recompute Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against cb60a06c9e58. |
|
Follow-up after opening: the Real behavior proof gate is green after adding the local Telegram runtime smoke output to the PR body. The current red CI jobs look unrelated to this two-file Telegram diff:
I tried to rerun failed CI jobs, but GitHub rejected the rerun because this account does not have repository admin rights. Additional local validation after the PR opened:
|
|
Pushed 8151d4d to address the ClawSweeper P2. The answer-fragment accumulator is now separate from the visible answer lane draft state, so tool-progress status text is not used as the previous answer partial when coalescing delta-shaped answer fragments. Added regression coverage for a partial-mode turn that emits tool progress before short answer fragments; the answer stream now updates from the progress draft to Validation:
@clawsweeper re-review |
|
Post-push CI follow-up for 8151d4d: the real behavior proof gate is green, and the Telegram-adjacent/changed-file checks are passing. The remaining red jobs look unrelated to this patch:
So I do not see another code change needed in this PR for the current red CI. |
0cab701 to
fdb7de5
Compare
|
Landed via rebase onto main.
Thanks @TurboTheTurtle! |
Fixes #79605.
Summary
Telegram partial draft streaming now coalesces delta-shaped partial fragments into the cumulative answer preview before handing them to the draft stream. This keeps the existing 30-character first-preview debounce intact, but prevents providers that deliver token-sized fragments from staying permanently below that threshold until the final answer arrives.
This is the debounce-preserving replacement for the closed debounce-removal attempts, including #80002.
Root Cause
The Telegram draft lane treated every
onPartialReplytext payload as a complete cumulative preview. That works when the provider sends full accumulated text, but providers can also surface token/delta-shaped fragments. In that case each fragment may be shorter than the 30-character first-preview debounce, so no preview message is created before final delivery.Real behavior proof
Behavior or issue addressed: Telegram
streaming.mode: "partial"can build a cumulative preview from delta-shaped text fragments while still passingminInitialChars: 30to the draft stream, then edit that preview when the final answer extends it.Real environment tested: Local OpenClaw checkout on macOS, branch
fix/telegram-partial-preserve-debounce, running the Telegram dispatcher and draft stream runtime with a redacted local Telegram API adapter.Exact steps or command run after this patch:
node --import tsx /tmp/telegram-partial-smoke.mjsEvidence after fix: Console output from the local OpenClaw Telegram partial runtime smoke:
Observed result after fix: The first two fragments,
Streamingandpreviews, remain under the 30-character debounce until the third fragment coalesces the cumulative preview to 57 characters. The runtime then creates the Telegram preview withsendMessage, edits the same message to the 87-character final answer witheditMessageText, and records the internal sent hook for message2001.What was not tested: A live Telegram DM screenshot or production bot-token run was not captured in this environment; the local runtime smoke uses a redacted in-process Telegram API adapter.
Validation
pnpm test extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/draft-stream.test.ts src/plugin-sdk/channel-streaming.test.tspnpm check:changed --base upstream/mainpnpm exec oxfmt --check --threads=1 extensions/telegram/src/bot-message-dispatch.ts extensions/telegram/src/bot-message-dispatch.test.tsgit diff --check upstream/main