Skip to content

fix(telegram): log the first confirmed getUpdates progress per generation - #90560

Merged
kshitijk4poor merged 2 commits into
NousResearch:mainfrom
kshitijk4poor:fix/telegram-polling-health-confirmation-90521
Aug 20, 2026
Merged

fix(telegram): log the first confirmed getUpdates progress per generation#90560
kshitijk4poor merged 2 commits into
NousResearch:mainfrom
kshitijk4poor:fix/telegram-polling-health-confirmation-90521

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

After a Telegram polling reconnect, the log stream for "reconnected and healthy" was byte-identical to "reconnected and hung" — a wedged long-poll (#87057 / #69314 / #71239 class) was invisible until a user noticed silence. This PR emits one INFO log line on the first confirmed getUpdates round-trip of each polling generation, turning the pending line into a resolvable pair whose absence after a reconnect is a reliable hung-poll signature.

Fixes #90504

Changes

  • plugins/platforms/telegram/adapter.py_record_polling_progress: when the generation's progress event transitions unset → set, log Telegram polling confirmed healthy: getUpdates progressing (generation N). No behavior change beyond the log line; counters/degraded-flag resets are untouched. Placed inside the existing not event.is_set() branch so steady-state polling adds zero log volume.
  • tests/gateway/test_telegram_polling_health_confirmation.py — 4 tests: first progress emits the confirmation (with generation number), subsequent progress in the same generation is silent, a new generation re-emits after a reconnect, and progress from a stale generation neither logs nor sets the current event.

Salvage of #90521 by @liuhao1024 — cherry-picked with authorship preserved. Follow-up: removed unused import pytest from the test file.

Validation

Before After
Bug on main _record_polling_progress completes silently First progress logs confirmed healthy
Hung-poll detection Send bot a test message Absence of confirmed healthy after reconnect
Test suite 0 tests 4 passed
Baseline tests 44 passed (conflict + polling timeout + error redaction + network)
Mutation check Removing log line fails 2 emission tests
Ruff Clean

liuhao1024 and others added 2 commits August 20, 2026 11:18
…tion

Both polling reconnect paths end on the same 'health pending getUpdates
progress' line, and _record_polling_progress completed silently — so the
log stream for 'reconnected and healthy' was byte-identical to
'reconnected and hung', and a wedged long-poll (NousResearch#87057 / NousResearch#69314 /
NousResearch#71239 class) stayed invisible until a user noticed silence. The only
detection method was sending the bot a test message (NousResearch#90504).

Emit one INFO on the first confirmed getUpdates round-trip of each
generation, inside the existing event-set branch so steady-state polling
adds no log volume. This turns the pending line into a resolvable pair
('health pending' -> 'confirmed healthy') whose absence after a
reconnect is a reliable hung-poll signature.

Fixes NousResearch#90504
Follow-up cleanup from simplify-code review on PR NousResearch#90521 salvage.
@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) August 20, 2026 05:53
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins platform/telegram Telegram bot adapter P1 High — major feature broken, no workaround sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 20, 2026
@kshitijk4poor
kshitijk4poor merged commit 37fa4a7 into NousResearch:main Aug 20, 2026
49 checks passed
kshitijk4poor added a commit to kshitijk4poor/hermes-agent that referenced this pull request Aug 21, 2026
…eway tests

tests/gateway/conftest.py already installs a comprehensive telegram mock
at collection time (line 330), before any test module's imports run.
The per-file copies were fully redundant — each was a simpler subset
(plain strings, setdefault, fewer error classes) of the conftest version
(which uses _fake_str_enum for PTB-faithful StrEnum semantics, sys.modules
overwrite to win over partial/broken imports, and a full error hierarchy
including BadRequest, Forbidden, RetryAfter, Conflict, InvalidToken).

Removed: function def + module-level call + now-unused imports (sys,
MagicMock where no longer referenced) + dangling comment blocks that
referenced the deleted mock, in 27 test files.
Left untouched: tests/gateway/conftest.py (canonical source) and
tests/e2e/conftest.py (separate conftest tree that may run in isolation).

Found by /simplify-code review of PR NousResearch#90560.
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…eway tests

tests/gateway/conftest.py already installs a comprehensive telegram mock
at collection time (line 330), before any test module's imports run.
The per-file copies were fully redundant — each was a simpler subset
(plain strings, setdefault, fewer error classes) of the conftest version
(which uses _fake_str_enum for PTB-faithful StrEnum semantics, sys.modules
overwrite to win over partial/broken imports, and a full error hierarchy
including BadRequest, Forbidden, RetryAfter, Conflict, InvalidToken).

Removed: function def + module-level call + now-unused imports (sys,
MagicMock where no longer referenced) + dangling comment blocks that
referenced the deleted mock, in 27 test files.
Left untouched: tests/gateway/conftest.py (canonical source) and
tests/e2e/conftest.py (separate conftest tree that may run in isolation).

Found by /simplify-code review of PR NousResearch#90560.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P1 High — major feature broken, no workaround 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

4 participants