Skip to content

fix(telegram): break infinite 409 conflict loop by not resetting counter on polling success (#63724) - #64082

Closed
webtecnica wants to merge 0 commit into
NousResearch:mainfrom
webtecnica:fix/63724-telegram-409-loop
Closed

fix(telegram): break infinite 409 conflict loop by not resetting counter on polling success (#63724)#64082
webtecnica wants to merge 0 commit into
NousResearch:mainfrom
webtecnica:fix/63724-telegram-409-loop

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Fixes #63724. The conflict counter was reset to 0 on every successful start_polling(), preventing the fatal path (count > 5) from ever being reached. Now uses monotonic timestamp to track recovery instead.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 14, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Competing fix for #63724 (Telegram 409 infinite loop, family anchor #58484) — three open PRs, three different mechanisms:

Same root cause, distinct approaches. Linking them so a maintainer can pick one; not marking duplicate. related: #58492, #64064, #63724, #58484.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment (token read-only)

PR 64082: fix(telegram): break infinite 409 conflict loop by not resetting counter on polling success

Correctness

  • Adds time-based counter decay to _handle_polling_conflict(): if the last successful start_polling() was more than 60 seconds ago, the counter is reset on a new 409.
  • Tracks _polling_conflict_last_ok_time to distinguish rapid-fire 409s (same episode, keep counter accumulated) from genuinely new conflicts.
  • On successful recovery, records last_ok_time but does NOT reset counter — ensuring the retry ladder eventually escalates to fatal.
  • Addresses #63724 infinite loop where every successful recovery reset the counter to 0 and a fresh 409 immediately fired again.

No issues found.


Reviewed by Hermes Agent

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment (token read-only)

PR 64082: fix(telegram): break infinite 409 conflict loop by not resetting counter on polling success

Correctness

  • Adds time-based counter decay to _handle_polling_conflict(): if the last successful start_polling() was more than 60 seconds ago, the counter is reset on a new 409.
  • Tracks _polling_conflict_last_ok_time to distinguish rapid-fire 409s (same episode, keep counter accumulated) from genuinely new conflicts.
  • On successful recovery, records last_ok_time but does NOT reset counter — ensuring the retry ladder eventually escalates to fatal.
  • Addresses #63724 infinite loop where every successful recovery reset the counter to 0 and a fresh 409 immediately fired again.

No issues found.


Reviewed by Hermes Agent

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment

Changes

Telegram polling conflict recovery: time-based counter decay prevents infinite 409 loops (#63724). The counter is now reset only if the last successful start_polling was more than 60 seconds ago, preventing rapid-fire 409s from masking a persistent conflict.

Assessment

  • Correctness: Well-reasoned fix. Without this, every successful start_polling after a 409 would reset the counter, and a persistent 409 would loop forever. Now the counter is only reset after COOLDOWN_SECONDS of successful polling.
  • Code quality: Clear comments explaining the guard against infinite loops. The CONFLICT_COOLDOWN_SECONDS constant is well-documented.
  • No debug artifacts.

Reviewed by Hermes Agent

@webtecnica webtecnica closed this Jul 14, 2026
@webtecnica
webtecnica force-pushed the fix/63724-telegram-409-loop branch from 73d47e2 to 46e87b1 Compare July 14, 2026 15:30
@webtecnica

Copy link
Copy Markdown
Contributor Author

Rebased onto upstream/main (46e87b1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram: persistent 409 Conflict loops forever — conflict counter resets on start_polling(), fatal/restart path unreachable, bot silently deaf

3 participants