fix(qqbot): use resume for 4009 session timeout instead of re-identify - #21073
fix(qqbot): use resume for 4009 session timeout instead of re-identify#21073husttsq wants to merge 2 commits into
Conversation
When QQ Bot WebSocket disconnects with code 4009 (Session timed out), the adapter was clearing session_id and last_seq, forcing a full re-identify on reconnect. This is incorrect per QQ's official docs. QQ docs state 4009 should use Resume (op 6) to restore the session, not re-identify (op 2). This fix: - Preserves session_id and last_seq on 4009 errors - Allows the reconnect flow to send Resume instead of Identify - Reduces recovery time and message loss during 30-min timeouts Reference: https://bot.q.qq.com/wiki/develop/api-v2/dev-prepare/error-trace/websocket.html See also: openclaw/openclaw#65579
Bartok9
left a comment
There was a problem hiding this comment.
Verified the fix against the surrounding reconnect logic in adapter.py.
The _handle_dispatch() Hello handler at line 742:
if self._session_id and self._last_seq is not None:
self._create_task(self._send_resume())…already selects Resume vs Identify based purely on whether session_id / last_seq are set. So the fix is correct: removing 4009 from the clear session block is all that's needed.
One thought: the inline comment # Keep session_id and last_seq for resume is good documentation but could be even clearer — the reader has to scroll down to see when resume fires. A one-liner like:
# 4009 = Session timed out → preserve state; next Hello will trigger _send_resume() (op 6)would tie the behavior together without having to trace the code path. Minor suggestion, not blocking.
|
Verified the fix against the surrounding reconnect logic in The Hello handler (~line 742) already selects Resume vs Identify based purely on whether if self._session_id and self._last_seq is not None:
self._create_task(self._send_resume())So removing 4009 from the 'clear session' block is all that's needed — correct and minimal. One suggestion: the inline comment # 4009 = Session timed out → preserve state; the next Hello will trigger _send_resume() (op 6)Minor — not blocking. |
Improve inline comments to explain when resume fires (next Hello triggers _send_resume op 6) instead of just saying 'preserve state'. Also split 4009 out of the docstring's 'session invalid' group since it now has distinct behavior.
|
Automated hermes-sweeper review: this fix is already present on current Evidence:
Thanks for the focused QQBot fix and for the review follow-up here; the same 4009 resume behavior has since been salvaged onto main. |
Problem
QQ Bot WebSocket disconnects every 30 minutes with code 4009 (Session timed out). The adapter incorrectly clears
session_idandlast_seq, forcing a full re-identify instead of resume.Fix
session_idandlast_seqon 4009 errorsReferences