fix(qqbot): cap stale resume retries and fallback to identify - #22422
Open
chongru1988 wants to merge 1 commit into
Open
fix(qqbot): cap stale resume retries and fallback to identify#22422chongru1988 wants to merge 1 commit into
chongru1988 wants to merge 1 commit into
Conversation
Prevent endless resume loops on stale QQ sessions by limiting consecutive resume attempts and forcing Identify once the cap is reached.
Collaborator
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for targeting the stale QQ Resume path. The premise remains present on current main: the Hello handler still chooses Resume solely from _session_id / _last_seq (gateway/platforms/qqbot/adapter.py:830-834).
Problems
- The cap cannot recover the PR's stated “immediately closes” case. The PR sends Resume for attempts 1–3 and selects Identify only on Hello 4, but current main exits after the third quick disconnect (
gateway/platforms/qqbot/adapter.py:515-534). That prevents the fallback from running. - The new tests seed
_resume_attemptsat the cap, so they do not exercise the current listener's immediate-close / quick-disconnect path.
Suggested changes
- Reconcile the Resume cap with the quick-disconnect cutoff so stale sessions reach Identify before listener termination, while retaining the current 4009-resumable behavior at
gateway/platforms/qqbot/adapter.py:600-627. - Add an async regression covering consecutive immediate closes through the actual reconnect loop.
Automated hermes-sweeper review.
| @@ -772,8 +776,21 @@ def _dispatch_payload(self, payload: Dict[str, Any]) -> None: | |||
| # Authenticate: send Resume if we have a session, else Identify. | |||
Contributor
There was a problem hiding this comment.
This fallback is only entered on the fourth Hello: the first three Hellos increment and send Resume. For the stated immediate-close failure, current main exits after its third quick disconnect (_listen_loop, gateway/platforms/qqbot/adapter.py:515-534), so this branch is never reached. Please coordinate the threshold with that guard and add a reconnect-loop regression.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resumeattempts to avoid endless reconnect loops on stale sessions.Identifyafter the resume cap is reached.READY,RESUMED, session-invalid, and resume-send failure).Why
Some stale-session reconnect flows can repeatedly attempt
Resumewithout making progress. This change makes recovery deterministic by forcing a cleanIdentifyhandshake after bounded retries.Changes
gateway/platforms/qqbot/constants.pyMAX_RESUME_ATTEMPTSgateway/platforms/qqbot/adapter.pytests/gateway/test_qqbot.pyTest Plan
python -m pytest tests/gateway/test_qqbot.py -k "HelloAuthModeSelection or ReadyHandling" -q -n 44 passedLinked Issue