fix: avoid Telegram overflow duplicate retries - #50965
Conversation
|
Thanks for picking this up — I pulled this PR onto current I verified: The core diagnosis looks right to me: a Telegram A couple of merge-readiness concerns though:
So: I think the PR is directionally right and the tests are useful, but I’d tighten these before merge: remove the new env-var knob, cover the short |
|
Thanks for the focused reproduction and regression test. The underlying retry classification remains relevant on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
Summary
Fixes a Telegram long-response duplicate/flood-control path I reproduced from a live gateway log.
When a streamed Telegram response exceeds the message limit,
edit_message()splits it into the edited preview plus continuation messages. If Telegram returnsRetryAfterwhile sending an overflow continuation, the adapter previously treated the Markdown send as a formatting failure and immediately retried the same chunk as plain text. The gateway then fell back to sending the full final response, which can duplicate already-visible chunks and amplify flood-control failures.This PR:
RetryAfterconsistently from Telegram exceptions and error text.send()honor an active chat cooldown instead of attempting another full-response fallback during the cooldown window.RetryAfteron an overflow continuation only attempts one send and returns partial-overflow metadata.Reproduction evidence
Observed from a live Telegram gateway log while handling a 13,061-character response:
That sequence shows a partial overflow delivery followed by a normal full-response send attempt for the same final response.
Tests
Passed:
Also ran adjacent Telegram tests:
Result:
152 passed, 3 failed. The 3 failures were intest_telegram_thread_fallback.pyasserting mocked group chat type resolution ('dm' == 'group') and are unrelated to this change; this PR only touchesplugins/platforms/telegram/adapter.pyandtests/gateway/test_telegram_overflow_partial.py.