Repository navigation
Description
Bug Description
When running Hermes with the Yuanbao platform enabled, stopping the gateway consistently takes approximately 5 seconds even when there are no active sessions.
The shutdown sequence completes immediately for all phases except Yuanbao adapter disconnection.
Relevant logs:
INFO gateway.run: Received SIGINT as a planned gateway stop — exiting cleanly
INFO gateway.run: Stopping gateway...
INFO gateway.run: Shutdown phase: notify_active_sessions done at +0.00s
INFO gateway.run: Shutdown phase: drain done at +0.00s (drain took 0.00s, timed_out=False, active_at_start=0, active_now=0)
INFO gateway.platforms.yuanbao: [Yuanbao] Disconnected
INFO gateway.run: ✓ yuanbao disconnected (5.01s)
INFO gateway.run: Shutdown phase: all adapters disconnected at +5.02s
INFO gateway.run: Gateway stopped (total teardown 5.02s)
The shutdown delay appears to come entirely from the Yuanbao adapter disconnect path.
Steps to Reproduce
- Configure and start Hermes with the Yuanbao platform enabled.
- Ensure there are no active conversations or running tasks.
- Stop the gateway with SIGINT (Ctrl+C).
- Observe shutdown timing in logs.
Expected Behavior
Gateway shutdown should complete almost immediately when there are no active sessions or pending Yuanbao operations.
Adapter disconnect should not introduce a fixed multi-second delay.
Actual Behavior
The Yuanbao adapter consistently requires approximately 5 seconds to disconnect:
✓ yuanbao disconnected (5.01s)
As a result, total gateway teardown time is approximately 5 seconds even when the system is otherwise idle.
Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp)
Messaging Platform (if gateway-related)
No response
Debug Report
Report https://paste.rs/pNwc6
agent.log https://paste.rs/Pct7f
gateway.log https://paste.rs/llN7QOperating System
Debian GNU/Linux 12 (bookworm)
Python Version
3.11.2
Hermes Version
0.16.0
Additional Logs / Traceback (optional)
Root Cause Analysis (optional)
No response
Proposed Fix (optional)
No response
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Activity
maxmilian commentedon Jun 6, 2026
Picking this up — PR incoming.
Root cause confirmed against
main:ConnectionManager._cleanup_ws()(gateway/platforms/yuanbao.py) awaitsws.close(), and the WS is opened withclose_timeout=5. Thewebsocketsclose handshake blocks up toclose_timeoutwaiting for the server's close-frame echo; on an idle shutdown the server doesn't reply, so it always waits the full ~5s — matching your✓ yuanbao disconnected (5.01s)log. Fix is to bound the close await on the shutdown path so a non-responsive server can't stall teardown.@libo1106 you'd flagged you might PR this yourself — happy to hand it back if you've already started; otherwise I'll have a fix + regression test up shortly.
libo1106 commentedon Jun 8, 2026
I saw that this has already been merged in #40607. Thanks, @maxmilian
fix(yuanbao): sync the bounded WS-close teardown from upstream (NousR…
fix(yuanbao): sync the bounded WS-close teardown from upstream (NousR…