Skip to content

fix(yuanbao): restore active singleton after WS reconnect - #58378

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-58363-yuanbao-reconnect-set-active
Closed

fix(yuanbao): restore active singleton after WS reconnect#58378
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:liuhao/cron-bugfix-58363-yuanbao-reconnect-set-active

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a bug where Yuanbao cron delivery silently fails after any WS disconnect/reconnect cycle. The _do_reconnect() method successfully reconnects but never calls YuanbaoAdapter.set_active(adapter), leaving get_active_adapter() permanently returning None. This causes _send_yuanbao() in send_message_tool.py to fail immediately with "Yuanbao adapter is not running" on every subsequent cron delivery attempt.

Related Issue

Fixes #58363

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/platforms/yuanbao.py: Added YuanbaoAdapter.set_active(adapter) call in _do_reconnect() after successful reconnect, matching the pattern already used in connect().
  • tests/test_yuanbao_reconnect_set_active.py: Added regression tests verifying that get_active_adapter() returns the adapter after successful reconnect and remains None after failed reconnect.

How to Test

  1. Set up a recurring cron job with deliver pointing at Yuanbao.
  2. Let it run a few ticks — works fine initially.
  3. Trigger a Yuanbao WS disconnect (network blip, server restart, etc.).
  4. After reconnect, subsequent cron ticks should deliver successfully.
  5. Run pytest tests/test_yuanbao_reconnect_set_active.py -v — both tests should pass.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

The fix is a single line addition that restores the active singleton after reconnect:

# In _do_reconnect(), after successful reconnect:
YuanbaoAdapter.set_active(adapter)  # ← added
return True

This matches the existing pattern in connect() (line 3377) and disconnect() (line 5189, which calls set_active(None)).

_do_reconnect() succeeded but never called
YuanbaoAdapter.set_active(adapter), leaving get_active()
permanently returning None after any WS disconnect/reconnect
cycle. This caused cron delivery to silently fail because
_send_yuanbao() checks get_active_adapter() and gives up
immediately when it returns None.

Fix: call set_active(adapter) after successful reconnect,
matching the pattern in connect().

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Yuanbao cron delivery silently fails after WS reconnect (three causes)

2 participants