Skip to content

fix: support QQBot direct sends and media - #15215

Open
q654517651 wants to merge 1 commit into
NousResearch:mainfrom
q654517651:local/qqbot-send-message-fix
Open

fix: support QQBot direct sends and media#15215
q654517651 wants to merge 1 commit into
NousResearch:mainfrom
q654517651:local/qqbot-send-message-fix

Conversation

@q654517651

@q654517651 q654517651 commented Apr 24, 2026

Copy link
Copy Markdown

Summary

  • treat QQBot OpenIDs as explicit send_message targets instead of resolving them as channel names
  • support QQBot C2C/user, group, and guild direct text sends through the appropriate REST endpoints
  • support QQBot MEDIA attachments for C2C users and groups via /files upload + msg_type=MEDIA send
  • allow QQBOT_HOME_CHANNEL from the environment as a fallback, matching gateway config loading

Why

QQBot direct sends currently fall back to the home channel for alphanumeric OpenIDs and then use the guild channel endpoint. This breaks C2C targets such as qqbot: and reports a missing home channel even when the target was explicit.

QQBot was also treated as a non-media platform in send_message, so MEDIA:/path attachments were omitted while the text send still returned success. That made file delivery appear successful even though no file was sent.

Testing

  • python3 -m py_compile tools/send_message_tool.py
  • locally verified QQBot target parsing for raw OpenID, user:, and group:
  • locally verified generated C2C/group and guild message bodies
  • sent a real CSV attachment through send_message using MEDIA:/path and received a successful QQBot media response

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/qqbot QQ Bot adapter comp/tools Tool registry, model_tools, toolsets labels Apr 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the QQBot media investigation. The MEDIA defect is still present on current main: tools/send_message_tool.py:1034-1047 rejects or omits QQBot attachments, and :1079 calls text-only _send_qqbot.

Problems

  • The C2C/group text portion is already on main via 3792b77bd11dcccab3b0994bd31086969fb9f5fb: tools/send_message_tool.py:1893-1918 tries channel, C2C, then group endpoints. Replacing that fallback with the PR's nonnumeric→C2C default can regress raw group OpenIDs.
  • The PR's new sequence generator permits values above the adapter's documented 0..65535 range (gateway/platforms/qqbot/adapter.py:908-912).
  • Current media handling is already implemented in the adapter, including chunked local uploads (gateway/platforms/qqbot/adapter.py:2840-3012); the direct base64 uploader duplicates that path and lacks PR tests.

Suggested changes

  • Preserve fallback behavior for untyped IDs, use typed routing only when explicit, and share the adapter media implementation or a standalone sender.
  • Add hermetic parser, endpoint, media-upload, and failure-path coverage under tests/tools/.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
@ijevin

ijevin commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

I can confirm this fixes a real production incident in a Hermes QQBot setup.

Observed failure mode:

  • A cron job generated a news brief and attempted to send it to two QQBot C2C OpenIDs via send_message / hermes send --to qqbot:<openid>.
  • Both OpenIDs were 32-character hex strings.
  • Because QQBot OpenIDs were not parsed as explicit targets, the second target fell back to the configured home channel.
  • Result: the home user received the same brief twice, while the second intended recipient received nothing.

This PR's explicit QQBot target parsing (qqbot:<openid>, plus typed user: / group: forms) addresses exactly that issue and is more complete than the small local workaround I had applied locally. The media and endpoint fixes are also aligned with the same direct-send path.

Thanks for pushing this upstream — this would remove the need for local patches after upgrades.

@GottZ

GottZ commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Summary

Five PRs address the QQBot direct-send failure: #16937, #17971, #19230, and #19422 add C2C/group endpoint routing, while #15215 additionally adds explicit typed-target parsing, QQBOT_HOME_CHANNEL fallback, and QQBot MEDIA delivery. The merged routing implementation in #19422 addresses the reported guild-only endpoint cause; #15215 retains a distinct media-focused scope but overlaps on routing.

Related pull requests

Duplicates

#16937, #17971, and #19230 are substantially duplicate reports of the QQBot C2C/group endpoint-routing fix; #19230 was salvaged into #19422, which supersedes those routing changes. #15215 overlaps on core text routing but is not wholly duplicative because its QQBot MEDIA support and typed-target handling are additional scope.

Suggested consolidation

Keep #15215 open with a salvage path: retain its QQBot MEDIA delivery and explicit typed-target work, rebase or split it against the merged routing in #19422, preserve untyped-ID fallback, constrain msg_seq to the documented range, reuse the adapter media implementation, and add hermetic tests. Close #16937 as a duplicate of #19422, close #17971 as already implemented on main using the cited file locations and SHAs, and close #19230 as salvaged by #19422; keep #19422 as the merged reference implementation.

Cross-PR triage: Reviewed 5 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 41 kB of PR diffs, 7 kB of issue/PR text, 4 kB of discussion (11 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists platform/qqbot QQ Bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades 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