fix(gateway): fallback immediately on Telegram finalized edit flood control - #55869
Open
johnwalke wants to merge 1 commit into
Open
fix(gateway): fallback immediately on Telegram finalized edit flood control#55869johnwalke wants to merge 1 commit into
johnwalke wants to merge 1 commit into
Conversation
…st-chunk edit When overflow split first-chunk edit hits flood control (RetryAfter), the old code only handled finalize=True + is_turn_final=True, missing the overflow-split path (finalize=True, is_turn_final=False). Change the guard from 'finalize and is_turn_final' to 'finalize' so ANY finalize-d edit that hits flood immediately enters fallback mode instead of wasting 3 flood-strike retries. Fallback preserves the visible prefix and sends only the missing tail on got_done. Fixes: - No full final duplicate (only tail sent) - State flags (final_content_delivered / already_sent) consistent - Flood control does not cause duplicate spam - Immediate fallback on first flood strike (no 3-strike delay) New regression test: test_flood_on_overflow_split_first_chunk_enters_fallback_immediately Updated existing test: test_failed_final_cleanup_edit_marks_visible_content_delivered All 157 stream-consumer tests GREEN.
19 tasks
13 tasks
teknium1
reviewed
Jul 15, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for isolating the overflow-first-chunk flood path. The premise remains on current main: the split loop calls _send_or_edit(..., finalize=True, is_turn_final=False) in gateway/stream_consumer.py:727-730, while immediate fallback still requires is_turn_final in gateway/stream_consumer.py:1871-1879.
Problems
gateway/stream_consumer.py:1595changes the policy for every adapter:if finalize:bypasses the existing Telegram opt-in capability gate. Current main scopes immediate final fallback throughFALLBACK_ON_FINAL_EDIT_FLOOD; preserve that boundary while covering the overflow case.tests/gateway/test_telegram_overflow_partial.py:157-214uses a generic mock and calls the consumer directly. It does not run the real Telegram oversized-final route inplugins/platforms/telegram/adapter.py:3980-3984/_edit_overflow_split, so it cannot validate the prefix retained after a first-chunk failure.
Suggested changes
- Make overflow immediate fallback adapter-capability-gated rather than unconditional.
- Add a real
TelegramAdapteroverflow/RetryAfter regression and a non-opt-in adapter control.
Automated hermes-sweeper review.
| self._MAX_FLOOD_STRIKES, | ||
| self._current_edit_interval, | ||
| ) | ||
| if finalize: |
Contributor
There was a problem hiding this comment.
finalize is also used by non-Telegram adapters and interim segment finalization. Please retain an explicit adapter capability gate when extending immediate fallback to the overflow-first-chunk case; current main scopes this behavior through FALLBACK_ON_FINAL_EDIT_FLOOD.
13 tasks
1 task
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
finalize=True, is_turn_final=False).Test plan
PYTHONPATH=. python3 -m pytest tests/gateway/test_telegram_overflow_partial.py tests/gateway/test_stream_consumer_fresh_final.py -q -o addopts=Notes
This targets a Telegram duplicate-delivery bug where flood-controlled finalized edits previously went through the generic retry loop before fallback. Retrying finalized edits wastes Telegram flood budget and delays the tail message; fallback is already the safer path once visible content exists.