Skip to content

fix(qqbot): accept is_reconnect kwarg in connect() to fix reconnection loop - #54037

Closed
danbao wants to merge 1 commit into
NousResearch:mainfrom
danbao:fix/qqbot-is-reconnect-param
Closed

fix(qqbot): accept is_reconnect kwarg in connect() to fix reconnection loop#54037
danbao wants to merge 1 commit into
NousResearch:mainfrom
danbao:fix/qqbot-is-reconnect-param

Conversation

@danbao

@danbao danbao commented Jun 28, 2026

Copy link
Copy Markdown

Problem

The gateway reconnection watcher calls adapter.connect(is_reconnect=True) on failed platforms (gateway/run.py L3176), but QQAdapter.connect() does not accept this keyword argument. This causes every reconnect attempt to fail with:

QQAdapter.connect() got an unexpected keyword argument 'is_reconnect'

The watcher retries with exponential backoff (60s → 120s → 240s → 300s) indefinitely, filling the log with errors.

Root Cause

QQAdapter.connect() (line 281) has signature async def connect(self) -> bool: — missing the is_reconnect parameter that BasePlatformAdapter.connect() defines and all other platform adapters implement:

Adapter is_reconnect
base.py
weixin.py
signal.py
api_server.py
bluebubbles.py
webhook.py
whatsapp_cloud.py
yuanbao.py
msgraph_webhook.py
qqbot

Fix

One-line change: add *, is_reconnect: bool = False to match the base class contract.

# Before
async def connect(self) -> bool:

# After  
async def connect(self, *, is_reconnect: bool = False) -> bool:

Verification

✓ qqbot connected
Gateway running with 3 platform(s)
[QQBot:1903051698] Ready, session_id=...

No more reconnection loop in gateway.log.

…n loop

The gateway reconnection watcher calls adapter.connect(is_reconnect=True)
on failed platforms, but QQAdapter.connect() did not accept this parameter,
causing every reconnect attempt to fail with:

  QQAdapter.connect() got an unexpected keyword argument 'is_reconnect'

All other platform adapters (weixin, signal, api_server, bluebubbles,
webhook, whatsapp_cloud, yuanbao, msgraph_webhook) already accept
is_reconnect. This one-line fix brings QQBot in line with the
BasePlatformAdapter.connect() contract.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/qqbot QQ Bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #52922 (the earliest open canonical fix for #52914). This PR makes the identical one-line is_reconnect signature fix to QQAdapter.connect(). Saturated fix cluster: #54029 / #53948 / #53546 / #52966 are also duplicates of #52922 for the same is_reconnect contract gap. Flagging for maintainer to pick the canonical PR to merge and close the rest.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Adds is_reconnect keyword argument to QQAdapter.connect() to match the BasePlatformAdapter.connect contract. The gateway reconnect loop calls connect(is_reconnect=True) on every reconnect attempt, so every adapter must accept it. Without this fix, QQ reconnection raised TypeError: unexpected keyword argument 'is_reconnect'. Test verifies the signature accepts the kwarg and that the reconnect call path doesn't raise TypeError.


Reviewed by Hermes Agent

@scutken

scutken commented Jul 6, 2026

Copy link
Copy Markdown

Encountered the same issue on v0.18.0 — QQ bot goes into infinite retry loop after any gateway restart with .

Applied this same one-line fix locally, restarted gateway, and QQ bot reconnects successfully. Can confirm this PR resolves the problem.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused QQBot reconnect fix. The exact behavior is already implemented on current main.

  • Automated hermes-sweeper review verified QQAdapter.connect(self, *, is_reconnect: bool = False) at gateway/platforms/qqbot/adapter.py:281.
  • Commit 276542c729c10ff9d093760897f4c2d1256a79ce added that signature and the regression coverage in tests/gateway/test_qqbot.py:193.
  • The reconnect path still forwards is_reconnect=True at gateway/run.py:7910-7912, and the current QQBot test exercises that accepted keyword form.

This supersedes the duplicate fix cluster noted in the prior discussion.

@teknium1 teknium1 closed this Jul 15, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 15, 2026
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 duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/qqbot QQ Bot adapter sweeper:implemented-on-main Sweeper: behavior already present on current main 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.

5 participants