fix(gateway): keep tool-progress edits alive after Telegram flood control

When a progress-message edit hits Telegram flood control (RetryAfter),
can_edit was unconditionally set to False, permanently disabling coalescing
for the rest of the run. Subsequent tool updates were posted as separate
new messages instead of updating the existing progress bubble.

Fix: only set can_edit=False for non-recoverable edit errors. On flood
control, back off by resetting _last_edit_ts so the throttle interval is
respected before the next edit attempt.

Fixes #25188
This commit is contained in:
Erhnysr 2026-05-13 22:09:10 +03:00 committed by Teknium
parent 256c4c1b4a
commit 1b3c51bccc

View file

@ -15463,14 +15463,15 @@ class GatewayRunner:
if not result.success:
_err = (getattr(result, "error", "") or "").lower()
if "flood" in _err or "retry after" in _err:
# Flood control hit — disable further edits,
# switch to sending new messages only for
# important updates. Don't block 23s.
# Flood control hit — backoff but keep editing.
# Only disable edits for non-recoverable errors.
logger.info(
"[%s] Progress edits disabled due to flood control",
"[%s] Progress edit flood control, backing off",
adapter.name,
)
can_edit = False
_last_edit_ts = time.monotonic()
else:
can_edit = False
_flood_result = await adapter.send(
chat_id=source.chat_id,
content=msg,