Skip to content

fix(qqbot): approval button clicks rejected for DM sessions - #49399

Closed
RCMartinChen wants to merge 1 commit into
NousResearch:mainfrom
RCMartinChen:fix/qqbot-approval-auth-dm
Closed

RCMartinChen wants to merge 1 commit into
NousResearch:mainfrom
RCMartinChen:fix/qqbot-approval-auth-dm

Conversation

@RCMartinChen

Copy link
Copy Markdown

Problem

QQ Bot approval button clicks are always rejected in DM (private chat) sessions, causing the agent to wait the full 60-second approval timeout on every tool call that requires approval.

Root cause: build_session_key (in gateway/session.py) uses "dm" as the chat_type for private chats, producing session keys like:

agent:main:qqbot:dm:3760DA980EE3BBA3476394E834F7A3AE

But _is_authorized_interaction_for_session (in gateway/platforms/qqbot/adapter.py) checks for "c2c":

if chat_type == "c2c":  # "dm" != "c2c" → always returns False

This means every approval button click is rejected as unauthorized. The agent falls back to waiting for the 60-second timeout, adding massive latency to any operation involving tool approval.

Evidence

From gateway logs — 72 total approval rejections, all with the same pattern:

[QQBot:1903948564] Rejected unauthorized approval click for session
agent:main:qqbot:dm:3760DA980EE3BBA3476394E834F7A3AE
(operator=3760DA980EE3BBA3476394E834F7A3AE)

Average response time was 277 seconds (median 56s), with the worst case at 3744 seconds (~62 minutes). After the fix, operations that don't need tool approval complete in 10-40 seconds.

Fix

Accept both "c2c" (QQ API native term) and "dm" (canonical session key form) in the authorization check:

# Before
if chat_type == "c2c":
# After
if chat_type in {"c2c", "dm"}:

Only the authorization check in _is_authorized_interaction_for_session is changed. The other chat_type == "c2c" checks in the message sending path (lines 2475, 2602, 2924) correctly use _guess_chat_type() which returns QQ-native types — those are unaffected.

Testing

Verified by analyzing 113 QQ bot responses from gateway logs spanning June 3-20, 2026. The fix is live on my instance and approval buttons now work correctly in DM sessions.

The session key builder uses 'dm' for private chats (from
build_session_key), but _is_authorized_interaction_for_session checked
for 'c2c'. This mismatch caused every approval button click in QQ DM
sessions to be rejected as unauthorized, forcing the agent to wait the
full 60-second approval timeout on each tool call that required approval.

Accept both 'c2c' (QQ API native term) and 'dm' (session key canonical
form) in the authorization check.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/qqbot QQ Bot adapter P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 20, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Duplicate of #31593 — both fix the QQBot DM approval-button rejection by changing _is_authorized_interaction_for_session in gateway/platforms/qqbot/adapter.py so the c2c branch also accepts the dm chat_type (if chat_type in {"c2c", "dm"}:). #31593 (opened 2026-05-24) is the earliest still-open PR with this identical one-line fix. Related open items: issue #35760 / #40655 (root cause), competing fix PRs #40926 and #43957.

@RCMartinChen

Copy link
Copy Markdown
Author

Closing as duplicate of #31593, which has the same fix with test coverage. Added production performance data there to help push for merge.

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 duplicate This issue or pull request already exists 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.

2 participants