Skip to content

fix(dingtalk): add liveness watchdog to recover stream after system sleep#5224

Merged
rayrayraykk merged 3 commits into
agentscope-ai:mainfrom
hongxicheng:ding-reconnect
Jun 16, 2026
Merged

fix(dingtalk): add liveness watchdog to recover stream after system sleep#5224
rayrayraykk merged 3 commits into
agentscope-ai:mainfrom
hongxicheng:ding-reconnect

Conversation

@hongxicheng

Copy link
Copy Markdown
Collaborator

Description

Add a liveness_watchdog coroutine in _stream_loop() that detects
system sleep/wake via wall-clock time jump. Every 30s it compares
time.time() elapsed against the expected interval — if >90s, force-
close the stale websocket (with 15s timeout) so the SDK's built-in
while True reconnect loop takes over.

Zero network overhead; keeps running across repeated sleep/wake cycles.

Related Issue: Fixes #5214

Security Considerations: [If applicable, e.g. channel auth, env/config handling]

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

[How to test these changes]

Local Verification Evidence

pre-commit run --all-files
# paste summary result

pytest
# paste summary result

Additional Notes

[Optional: any other context]

@github-actions

Copy link
Copy Markdown

Welcome to QwenPaw! 🐾

Hi @hongxicheng, this is your 122nd 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.

@hongxicheng hongxicheng requested a deployment to maintainer-approved June 16, 2026 08:11 — with GitHub Actions Waiting
@hongxicheng hongxicheng requested a deployment to maintainer-approved June 16, 2026 09:01 — with GitHub Actions Waiting
@rayrayraykk rayrayraykk merged commit 3625891 into agentscope-ai:main Jun 16, 2026
6 of 7 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in QwenPaw Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: 钉钉 Stream 频道在笔记本睡眠唤醒后静默失效,进程存活但消息永久无响应

2 participants