Repository navigation
[codex] fix telegram polling liveness health monitor - #51931
aidenwildenbadt wants to merge 9 commits into
Conversation
606bd32 to
ca438cb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca438cb2ff
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Greptile SummaryThis PR closes a liveness blind spot in the Telegram polling path: the poller now publishes Key changes:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/telegram/src/polling-session.ts
Line: 278-279
Comment:
**Redundant `setStatus` call in catch block**
`setStatus?.({ connected: false })` is called here in the `catch` block and then called again unconditionally in the `finally` block (line 299). Since `finally` always runs — both on the error and the normal-stop paths — the `catch`-block call is redundant and can be removed. Removing it also makes the intent cleaner: "on exit of any polling cycle, clear connected state."
```suggestion
} catch (err) {
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/telegram/src/polling-session.ts
Line: 278-298
Comment:
**`connected: false` set before the backoff wait in the error path**
In the error branch, `setStatus?.({ connected: false })` fires at line 279, and then `#waitBeforeRestart()` is awaited inside the same `catch` block. This means the snapshot shows `connected: false` for the entire backoff duration (up to ~30 s at max backoff).
In the normal-stop path the situation is reversed — `#waitBeforeRestart()` runs inside the `try` block and only after it returns does `finally` set `connected: false`, so the reconnection gap is only the brief time needed to create a new bot and get the first `getUpdates` back. The error path therefore exposes a wider window where the health monitor could observe `connected: false` and classify the account as `disconnected`.
With the default 5-minute check interval this is unlikely to cause spurious restarts in practice, but it is an asymmetry worth being aware of. If you want the error path to behave the same as the normal-stop path (only clearing connected state at the end of backoff, not the start), the `setStatus` call could be moved to immediately before the `return shouldRestart ? …` line instead of to the top of the catch block.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(telegram): surface polling liveness ..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de1fe120b0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c19e2d616
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a73e30e104
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b746524425
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27aca9429a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c917475 to
4bbe369
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4bbe3693e5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Add typeof check for snapshot.mode before comparing normalized mode to "polling" for Telegram accounts. Prevents non-string status patches from being misclassified as polling mode during webhook restarts. Co-Authored-By: Claude Opus 4.6 <[email protected]>
3bc5f78 to
213e688
Compare
|
Maintainer triage: good direction, but I would land this after the transport fixes and with one behavior tweak. The core idea is right: Telegram polling needs to publish Concern in the latest patch: Suggested fix: keep Recommended path: rebase after #68128/#69243, make that status transition less eager, then merge. |
|
Thanks for the polling-health work. I landed a refactored version via #69476 / 60fea81: Telegram now publishes explicit |
This fixes a Telegram-specific failure mode where the provider could stop processing new inbound messages even though the gateway still showed the channel as running.
In the failing case, Telegram polling was interrupted by a
getUpdatesconflict or another poll-loop failure. The provider retried internally, but it never published channel liveness into the gateway runtime snapshot. At the same time, the gateway health monitor intentionally skipped stale-event checks for Telegram. The result was that a wedged or preempted Telegram poller could remain marked as running indefinitely, so new Telegram DMs would stop reaching agent session creation without triggering automatic recovery.The fix does two things. First, the Telegram polling session now reports successful
getUpdatesactivity back into the channel runtime snapshot by publishing connected and event-liveness state on successful poll cycles, and it clears the connected flag when the polling cycle exits or fails. Second, the gateway health policy now treats Telegram polling the same way as other non-webhook channels when event-liveness data is present, so a stalled Telegram poller can be restarted automatically instead of remaining falsely healthy forever.I also threaded the Telegram gateway
setStatussink through the provider startup path so the polling monitor can update the runtime snapshot directly, and I added regression coverage for the polling-session liveness behavior and the health-policy evaluation.Validation was done with:
pnpm vitest run --config vitest.config.ts extensions/telegram/src/polling-session.test.ts src/gateway/channel-health-policy.test.tsThis is related to the recent Telegram incident work but addresses a separate root cause from the earlier session-reset/followup fix.
Contribution Notes
Codex)