Repository navigation
fix(telegram): preserve mixed text order and pending stop - #144839
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 6:37 AM ET / 10:37 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR preserves processing order between ordinary Telegram text and long-message fragments, connects authorized native stop commands to pending-input cancellation, and adds regression coverage and documentation. Merge readiness✅ Ready for maintainer review The fix remains necessary on current main. The added redacted Telegram trace resolves the previous proof request, and source review found no blocking correctness defect. Priority: P2 Review scores
Verification
How this fits togetherTelegram’s inbound buffers collect messages before handing them to agent processing. Their ordering and cancellation decisions determine which inputs reach the provider and produce chat replies. flowchart TD
A[Telegram messages] --> B[Authorization and conversation scope]
B --> C[Ordinary text batch]
B --> D[Long fragment collection]
C --> E[Shared ordered queue]
D --> E
B --> F[Authorized stop cancels pending input]
F --> E
E --> G[Agent processing and Telegram replies]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +135, Tests +827, Docs +1. Total +963 across 16 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one ordered buffer execution owner while preserving separate text batches, source metadata, and sender-scoped stop cancellation. Do we have a high-confidence way to reproduce the issue? Yes: current main’s independent queues explain the 3000 ms short–long–continuation reordering, corroborated by the supplied baseline trace; this review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: reusing the existing ordered debouncer removes the competing execution queue while retaining fragment assembly and existing command authorization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f50d4ce71e3e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
landpr-approve-unrelated-red |
|
Thanks @xilopaint for the detailed reproduction! Proof: Real Telegram Test Server direct messages through a built Gateway and deterministic provider preserve short → long/continuation admission and reply order. Native
CI: The introduced type-cycle and missing fixture account ID are fixed; hosted architecture and test-type checks pass. The completed final run has one unrelated failing child, checks-node-compact-small-19, and the resulting aggregate failure. That child fails The fixture materializer and its use were introduced by #138742, commit |
Preserve the reviewed harness while incorporating the landed benchmark prerequisite. Punchcard-Session: coral-orchard-orchard-d4 * commit '4407ed19ac63b1c1c84a0cfe6eb4bbeca9c2322c': (1196 commits) fix(perf): isolate benchmark subprocess transport (#144159) refactor(auth): await Copilot cache persistence (#144810) refactor(web-fetch): exercise URL normalization through the public tool (#144887) fix(ollama): preserve hosted subdomain model context (#144891) fix(doctor): explain Codex plugin health failures (#144813) fix(channels): honor pinned accounts in Mattermost model menus (#144880) fix(update): failed-update records hide the triggering error behind the excerpt tail (#144729) fix(logging): preserve OpenClaw package references in diagnostics (#144808) fix: retain plugin detail tab selections while inspection loads (#144647) fix: keep discovered models when sign-in tokens renew (#144861) fix(update): preserve local package overrides (#89985) fix(update): resolve compatibility bridges within the runtime graph (#144831) chore(i18n): refresh native locales (#144856) fix: preserve child signal termination during CLI respawn (#144838) fix(text): hide encoded MiniMax tool envelopes (#126307) fix(subagents): deliver child replies that match the empty placeholder (#130647) fix(cli): reject blank message channel selectors (#144802) fix(telegram): preserve mixed text order and pending stop (#144839) fix(memory): restore FTS fallback for same-name view collisions (#144783) chore(release): close out 2026.9.4 on main (#144708) ...
…44839) Coordinate ordinary Telegram text and near-limit fragment processing through the existing inbound debouncer while preserving assembly and source metadata. Connect authorized native stop to pending text cancellation before post-authorization preparation. Real Telegram Test Server baseline and candidate proof covers mixed ordering, pairs, thresholds, pending cancellation and reuse. Focused owner, command, media, ingress and debounce checks cover the related internal contracts. Thanks @xilopaint for the reproduction. Fixes openclaw#144722 Co-authored-by: Ayaan Zaidi <[email protected]>
…44839) Coordinate ordinary Telegram text and near-limit fragment processing through the existing inbound debouncer while preserving assembly and source metadata. Connect authorized native stop to pending text cancellation before post-authorization preparation. Real Telegram Test Server baseline and candidate proof covers mixed ordering, pairs, thresholds, pending cancellation and reuse. Focused owner, command, media, ingress and debounce checks cover the related internal contracts. Thanks @xilopaint for the reproduction. Fixes openclaw#144722 Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 62258ae)
Related: #144839 ## What Problem This Solves Fixes partial prompts and multiple replies when Telegram delivers one long paste as a rapid burst of differently sized message chunks. ## User Impact Telegram now batches ordinary text by default with a 300 ms quiet window, extending the wait for likely long-paste continuations. Existing global/per-channel settings still take precedence; explicit `0` disables ordinary burst batching while retaining automatic near-limit reassembly. The tradeoff is a small delay before ordinary text starts a turn, and intentionally separate rapid messages may be combined. Commands and media remain separate, and stop still cancels pending input. ## Why This Change Was Made Short text and near-limit fragments previously used separate collectors, and reassembly required consecutive message IDs. One shared keyed queue now collects both, preserves source metadata and cancellation, and orders forwarded batches without merging their origins into ordinary text. Ordinary batches are bounded to 12 messages, 50,000 characters, and 7.5 seconds of collection (or a longer configured initial quiet window). Likely continuations retain a 1.5-second allowance. The separate fragment maps, timers, and completion bookkeeping are removed. No config migration or dependency change is required. ## Evidence Real Telegram Test Server user → bot → OpenClaw Gateway → deterministic mock provider, with TDLib recording actual replies: | Scenario | Pinned baseline | Candidate | | --- | --- | --- | | 3,999 + 4,096 + 200 characters, sent about 100 ms apart | Two user turns: first chunk, then remaining chunks; two replies | One combined user turn; one reply | | 4,096 + 200 characters | One joined turn and one reply | One joined turn and one reply | | Buffered long text, then native stop, then fresh text | — | Canceled text never reached the provider; fresh text produced one turn and reply | The candidate mixed case exercised real transport deliveries 233 ms apart. Stop arrived 587 ms after the buffered text; the fresh message arrived at 2,999 ms. Counts above are primary user turns, not background session-recap requests. All proof leases, processes, listeners, and credential scratch were cleaned up. - The mixed-burst regression fails on baseline `d15cac3f06178f7aa6a49d746ae2201dcd3eb4a4` and passes on the candidate. - **328 focused tests passed** across shared debouncing, Telegram bot/media handling, durable ingress, cancellation, authorization, reply/quote context, entity formatting, and SDK mock conformance. - Targeted type-aware lint, generated SDK declaration checks, formatting, and line-count ratchets passed. Full repository checks remain for hosted CI. - The complete shared-debounce suite moved into its own directly imported test file; no existing coverage was dropped, and one obsolete oversized-file allowance was removed. - Independent correctness review completed. Its channel-post concern was checked against the ingress normalizer and passing sender-less channel-post reassembly case; channel posts already receive a stable synthetic sender before batching. <details> <summary>Measured test cost (one worker)</summary> - Shared debounce: 24 tests, 0.59 s test time. - Remaining inbound tests: 39 tests, 0.23 s test time; both shared files completed in 19.03 s command wall time including preparation. - Telegram bot boundary: 163 tests, 66.54 s test time. - Telegram channel-post/media boundary: 41 tests, 25.46 s test time; the two-file command completed in 120.38 s wall time. - SDK mock admission conformance: 1 targeted case, 16.56 s command wall time including preparation; it fails without the new mock member and passes with it. - The existing large bot suite exercises registered handlers and durable SQLite-backed admission. New timing cases reuse its fixtures and fake clock rather than adding Gateway/process boots. - Hosted CI timings will be available on the PR checks. </details> ### Hosted CI follow-up Regenerated the config-doc fingerprint for the intentional help change. Fixtures testing immediate delivery now explicitly disable ordinary batching, and typed Feishu debounce doubles expose the admission query. The SDK mock reuses the canonical debounce resolver rather than growing its duplicate policy. The 56 targeted repair tests, plugin test-typecheck lane, and size ratchet passed; Telegram production batching is unchanged from the live proof. The initial launcher failure came from an unchanged main-parent test and was fixed upstream in #155825; this PR does not change launcher code. The remaining bot context/media suite now explicitly opts out of ordinary batching through its shared config builders while retaining explicit debounce windows. All137 cases pass (58.75s test time,83.46s command wall time); no assertions or production batching behavior were weakened. The final integration includes current main rather than copying an unrelated wrapper repair into the Telegram code. The wrapper closure tests passed 2/2 on the integrated source. A newly added disabled-binding startup fixture was made explicitly immediate; all 9 cases pass. The mixed-burst registered-handler and forwarded-context controls passed on the integrated runtime; the original Test Server capture remains for the unchanged batching owner. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: openclaw#144839 ## What Problem This Solves Fixes partial prompts and multiple replies when Telegram delivers one long paste as a rapid burst of differently sized message chunks. ## User Impact Telegram now batches ordinary text by default with a 300 ms quiet window, extending the wait for likely long-paste continuations. Existing global/per-channel settings still take precedence; explicit `0` disables ordinary burst batching while retaining automatic near-limit reassembly. The tradeoff is a small delay before ordinary text starts a turn, and intentionally separate rapid messages may be combined. Commands and media remain separate, and stop still cancels pending input. ## Why This Change Was Made Short text and near-limit fragments previously used separate collectors, and reassembly required consecutive message IDs. One shared keyed queue now collects both, preserves source metadata and cancellation, and orders forwarded batches without merging their origins into ordinary text. Ordinary batches are bounded to 12 messages, 50,000 characters, and 7.5 seconds of collection (or a longer configured initial quiet window). Likely continuations retain a 1.5-second allowance. The separate fragment maps, timers, and completion bookkeeping are removed. No config migration or dependency change is required. ## Evidence Real Telegram Test Server user → bot → OpenClaw Gateway → deterministic mock provider, with TDLib recording actual replies: | Scenario | Pinned baseline | Candidate | | --- | --- | --- | | 3,999 + 4,096 + 200 characters, sent about 100 ms apart | Two user turns: first chunk, then remaining chunks; two replies | One combined user turn; one reply | | 4,096 + 200 characters | One joined turn and one reply | One joined turn and one reply | | Buffered long text, then native stop, then fresh text | — | Canceled text never reached the provider; fresh text produced one turn and reply | The candidate mixed case exercised real transport deliveries 233 ms apart. Stop arrived 587 ms after the buffered text; the fresh message arrived at 2,999 ms. Counts above are primary user turns, not background session-recap requests. All proof leases, processes, listeners, and credential scratch were cleaned up. - The mixed-burst regression fails on baseline `6e1eddbb57cb40a30cbe85cbef5bf6cf85319de4` and passes on the candidate. - **328 focused tests passed** across shared debouncing, Telegram bot/media handling, durable ingress, cancellation, authorization, reply/quote context, entity formatting, and SDK mock conformance. - Targeted type-aware lint, generated SDK declaration checks, formatting, and line-count ratchets passed. Full repository checks remain for hosted CI. - The complete shared-debounce suite moved into its own directly imported test file; no existing coverage was dropped, and one obsolete oversized-file allowance was removed. - Independent correctness review completed. Its channel-post concern was checked against the ingress normalizer and passing sender-less channel-post reassembly case; channel posts already receive a stable synthetic sender before batching. <details> <summary>Measured test cost (one worker)</summary> - Shared debounce: 24 tests, 0.59 s test time. - Remaining inbound tests: 39 tests, 0.23 s test time; both shared files completed in 19.03 s command wall time including preparation. - Telegram bot boundary: 163 tests, 66.54 s test time. - Telegram channel-post/media boundary: 41 tests, 25.46 s test time; the two-file command completed in 120.38 s wall time. - SDK mock admission conformance: 1 targeted case, 16.56 s command wall time including preparation; it fails without the new mock member and passes with it. - The existing large bot suite exercises registered handlers and durable SQLite-backed admission. New timing cases reuse its fixtures and fake clock rather than adding Gateway/process boots. - Hosted CI timings will be available on the PR checks. </details> ### Hosted CI follow-up Regenerated the config-doc fingerprint for the intentional help change. Fixtures testing immediate delivery now explicitly disable ordinary batching, and typed Feishu debounce doubles expose the admission query. The SDK mock reuses the canonical debounce resolver rather than growing its duplicate policy. The 56 targeted repair tests, plugin test-typecheck lane, and size ratchet passed; Telegram production batching is unchanged from the live proof. The initial launcher failure came from an unchanged main-parent test and was fixed upstream in openclaw#155825; this PR does not change launcher code. The remaining bot context/media suite now explicitly opts out of ordinary batching through its shared config builders while retaining explicit debounce windows. All137 cases pass (58.75s test time,83.46s command wall time); no assertions or production batching behavior were weakened. The final integration includes current main rather than copying an unrelated wrapper repair into the Telegram code. The wrapper closure tests passed 2/2 on the integrated source. A newly added disabled-binding startup fixture was made explicitly immediate; all 9 cases pass. The mixed-burst registered-handler and forwarded-context controls passed on the integrated runtime; the original Test Server capture remains for the unchanged batching owner. Co-authored-by: Ayaan Zaidi <[email protected]>
Thanks @xilopaint for the detailed reproduction.
Fixes #144722.
What Problem This Solves
Fixes an issue where a short Telegram message could be processed after a later long message and its continuation when inbound debounce was enabled. Native stop could also leave a buffered fragment pending.
Why This Change Was Made
Reserve fragment work in the existing inbound debounce queue on arrival, so both text paths share processing order. Authorized native stop now cancels through the same pending-buffer operation. Fragment thresholds and source metadata remain unchanged.
User Impact
Earlier text is processed first, canceled fragments do not reach the provider, and fresh messages work after cancellation. Ordinary-only debounce retains its behavior.
Evidence
Real Telegram direct messages reproduced both bugs. Seven acceptance cases passed, covering mixed order, ordinary/long pairs, thresholds, pending stop and reuse. Seven provider requests matched eight visible messages, including the stop acknowledgement; canceled input was absent. The ordinary debounce timing matrix and focused handler tests passed.