Skip to content

fix(qqbot): salvage 4 fixes from #27944 (intent, op 7/9, filename, SILK) - #30843

Merged
teknium1 merged 4 commits into
mainfrom
hermes/hermes-3ed57629
May 23, 2026
Merged

fix(qqbot): salvage 4 fixes from #27944 (intent, op 7/9, filename, SILK)#30843
teknium1 merged 4 commits into
mainfrom
hermes/hermes-3ed57629

Conversation

@teknium1

@teknium1 teknium1 commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvages 4 of 5 commits from #27944 (@WideLee, commits by walli@tencent.com) onto current main. Deferred the 5th commit — a ~255-line WS-thread architecture rewrite + media send support — for separate review with live testing.

Changes (cherry-picked)

  • INTERACTION intent (1 << 26)_send_identify() was missing the INTERACTION bit, so QQ gateway never dispatched INTERACTION_CREATE and approval button clicks were silently lost.
  • Video/file path exposure_process_attachments() now formats non-image/voice attachments as [video: name (path)] / [file: name (path)] instead of opaque [Attachment: name], so the LLM can reference local paths for send-back.
  • WS op 7 / op 9 — op 7 (Server Reconnect) closes the WS to trigger reconnect with Resume; op 9 (Invalid Session) checks d to pick Resume vs re-Identify. Both were previously ignored.
  • Close code classification — 4009 (connection timeout) removed from session-clearing set (resumable per QQ protocol); 4001/4002/4010-4014 added to fatal set.
  • Original filename_download_and_cache() accepts original_name, prefers attachment metadata filename over the CDN URL hash basename.
  • SILK magic byte slicedata[:5]/data[:4]data[:6] so the 6-byte b"#!SILK" literal can actually match.

Deferred (not included)

Commit 310cd3e3b "dedicated WS thread + heartbeat restart + media send support" — moves WS lifecycle to a dedicated daemon thread with its own asyncio loop, switches _token_lock from asyncio.Lock to threading.Lock, adds sync httpx variants, dispatches inbound messages via run_coroutine_threadsafe. Substantial concurrency rewrite that supersedes #28167 (8199ec3, magic524's "keep QQBot reconnect loop alive" fix). Wants live gateway validation before merge.

Validation

Result
pytest tests/gateway/test_qqbot.py 158 passed
Authorship walli (preserved via cherry-pick; in AUTHOR_MAP)
Conflicts Auto-merged (no manual resolution needed)

Original PR: #27944

Infographic

qqbot-salvage

WideLee added 4 commits May 23, 2026 01:46
1. Add INTERACTION intent bit (1<<26) to _send_identify, fixing approval
   button clicks not being received (INTERACTION_CREATE events were never
   dispatched by the gateway)
2. Include local cached path in video/file attachment descriptions so the
   LLM can reference files for re-sending to users
3. Add unit tests (TestIdentifyIntents, TestProcessAttachmentsPathExposure)
1. Handle op 7 (Server Reconnect): close WS to trigger reconnect loop
   while preserving session for Resume
2. Handle op 9 (Invalid Session): check d value to determine if session
   is resumable; clear session only when not resumable
3. Remove 4009 from session-clearing set (connection timeout is resumable)
4. Expand fatal close codes: 4001/4002/4010-4014 now stop reconnect
   immediately instead of retrying uselessly
5. Add unit tests
Add original_name parameter to _download_and_cache, preferring the
attachment metadata filename over the CDN URL path basename. Previously
files were cached with meaningless QQ CDN hash names (e.g.
qqdownload_...oadftnv5), causing ugly filenames when sent back to users.

Aligns with qqbot-agent-sdk's AttachmentDownloader.download_document.
_guess_ext_from_data: data[:5] == b"#!SILK" -> data[:6] (6-byte string)
_looks_like_silk: data[:4] == b"#!SILK" -> data[:6]

The previous slices were too short to ever match the 6-byte "#!SILK"
literal, relying entirely on the "#!SILK_V3" (9-byte) and 0x02! (2-byte)
fallback paths for SILK format detection.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-3ed57629 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8998 on HEAD, 8998 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4776 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/qqbot QQ Bot adapter labels May 23, 2026
@teknium1
teknium1 merged commit 60b0a0e into main May 23, 2026
25 of 26 checks passed
@teknium1
teknium1 deleted the hermes/hermes-3ed57629 branch May 23, 2026 09:27
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 platform/qqbot QQ Bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants