Skip to content

fix(channel): telegram network retry#4039

Open
Leirunlin wants to merge 1 commit intoagentscope-ai:mainfrom
Leirunlin:fix/telegram-polling-reconnect
Open

fix(channel): telegram network retry#4039
Leirunlin wants to merge 1 commit intoagentscope-ai:mainfrom
Leirunlin:fix/telegram-polling-reconnect

Conversation

@Leirunlin
Copy link
Copy Markdown
Collaborator

Description

This change makes TelegramChannel handle polling failures more explicitly instead of relying on PTB internals alone. It now:

  • detects polling network error vs conflict
  • tracks consecutive retries separately for each case
  • requests a clean outer reconnect by stopping the updater and rebuilding the application
  • applies reason-specific retry delays:
    • network errors: exponential backoff
    • conflicts: fixed delay

This fixes the case where Telegram stops receiving messages after a brief disconnect and only recovers after manually restarting QwenPaw or toggling the channel.

Related Issue: Fixes #4017

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactoring

Component(s) Affected

  • Core / Backend (app, agents, config, providers, utils, local_models)
  • Console (frontend web UI)
  • Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
  • Skills
  • CLI
  • Documentation (website)
  • Tests
  • CI/CD
  • Scripts / Deploy

Checklist

  • I ran pre-commit run --all-files locally and it passes
  • If pre-commit auto-fixed files, I committed those changes and reran checks
  • I ran tests locally (pytest or as relevant) and they pass
  • Documentation updated (if needed)
  • Ready for review

For Channel Changes (DingTalk, Feishu, QQ, Console, etc.)

  • I ran ./scripts/check-channels.sh (or ./scripts/check-channels.sh --changed) and it passes
  • Contract test exists in tests/contract/channels/test_<channel>_contract.py (REQUIRED)
  • Contract test implements create_instance() with proper channel initialization
  • All 19 contract verification points pass (see tests/contract/channels/__init__.py)
  • Optional: Unit tests in tests/unit/channels/test_<channel>.py for complex internal logic

Testing

I test it manually. It now reconnects successfully when QwenPaw encounters a network issue.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Welcome to QwenPaw! 🐾

Hi @Leirunlin, this is your 58th Pull Request.

🙌 Join Developer Community

Thanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page:
https://qwenpaw.agentscope.io/docs/community

We truly appreciate your enthusiasm—and look forward to your future contributions! 😊

We'll review your PR soon.

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

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

[Bug]:开启默认HEARTBEAT.md时,网络中断并恢复网络后消息渠道无法自动重连

1 participant