Skip to content

fix(qqbot): refactor C2C media routing and fix event loop binding issues - #35153

Closed
zz327455573 wants to merge 2 commits into
NousResearch:mainfrom
zz327455573:main
Closed

fix(qqbot): refactor C2C media routing and fix event loop binding issues#35153
zz327455573 wants to merge 2 commits into
NousResearch:mainfrom
zz327455573:main

Conversation

@zz327455573

Copy link
Copy Markdown

Description

This PR fixes the media delivery failure in the QQBot platform and resolves an event loop conflict.

Key Changes:

  1. Media Routing: Refactored send_message_tool.py to inject MEDIA: and VOICE: tags for the QQ channel, delegating the actual upload and delivery to the running QQAdapter singleton.
  2. Event Loop Fix: Moved the initialization of asyncio.Lock() in QQAdapter from __init__ to connect() to prevent "Task attached to a different loop" errors during gateway reconnects.

测试环境 (Test Environment):

  • Ubuntu 24.04
  • Harris Agent
  • Tencent Cloud

中文说明

修复了跨通道发多媒体报错以及 QQBot 异步锁冲突的 Bug。

  1. 工具层重构:不再走原生 REST 接口强发,而是拼装标签交由底层网关统一分发媒体文件,彻底打通 Agent 发图链路。
  2. 事件循环修复:将 asyncio.Lock() 的创建推迟到 connect() 中,避免了网关重连时的协程锁崩溃问题。

@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins comp/gateway Gateway runner, session dispatch, delivery platform/qqbot QQ Bot adapter P2 Medium — degraded but workaround exists labels May 30, 2026
@alpindiay

Copy link
Copy Markdown

Automated Triage: Merge Blocker

This PR is submitted from the main branch. Merge state: blocked. Branch protection requires PRs to originate from feature branches, not main/master. Please recreate from a feature branch.

zz327455573 added a commit to zz327455573/hermes-agent that referenced this pull request Jul 30, 2026
- adapter.py: Add active instance registry (ClassVar singleton) so
  send_message_tool can reach the running QQAdapter without importing
  internal gateway state. Move asyncio.Lock() creation from __init__
  to connect() to avoid 'no running event loop' errors.

- adapter.py: Refactor send() to extract MEDIA: tags and deliver
  images/audio/video/documents natively via the QQ Bot API before
  sending remaining text content.

- send_message_tool.py: Replace REST-based _send_qqbot() (manual
  token + httpx + 3 endpoint fallback) with adapter-based approach
  that delegates to the running QQAdapter singleton via get_active_adapter().
  This fixes C2C message routing and eliminates event loop conflicts.

- send_message_tool.py: Add QQBot to the media-capable platform list
  alongside telegram, discord, matrix, weixin, signal, yuanbao, feishu.

Closes NousResearch#35153
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 comp/plugins Plugin system and bundled plugins 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