fix(telegram): clip mid-stream overflow instead of splitting (#48648) - #51736
Merged
Conversation
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-attribute |
2 |
First entries
run_agent.py:2984: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
✅ Fixed issues (1):
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
Unchanged: 5899 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
This was referenced Jun 24, 2026
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Telegram streamed replies that grow past 4096 chars no longer spawn an infinite nested-reply duplication loop.
Root cause:
edit_message's overflow split ran on every streamed edit (finalize=Falseincluded). Splitting moves the active message ID to a continuation, so the next accumulated-token edit re-splits the full text — looping once per token after the limit is hit.Changes
plugins/platforms/telegram/adapter.py: gate_edit_overflow_splitonfinalize. Mid-stream, truncate to a single preview message via new_truncate_stream_overflow_previewhelper (keeps editing the same ID). Fixes both the pre-flight path and the reactivemessage_too_longcatch. Full content is still split-and-delivered onfinalize=True.tests/gateway/test_telegram_format.py: flip the existing continuation-split test tofinalize=True(splitting is now finalize-only), add two mid-stream truncation tests.Validation
Targeted tests: 4 passed. E2E (real
edit_message, mocked bot): mid-stream continuation sends = 0, ID stays put, finalize delivers full content.Credit
Salvaged from #50408 by @Tranquil-Flow (authorship preserved via rebase-merge). Closes #48648. Supersedes duplicate fixes #48663 (@liuhao1024, earliest submitter), #48718 (@kyssta-exe), #51266 (@RichardAtCT) — those targeted the pre-refactor path
gateway/platforms/telegram.py, which no longer exists.Infographic