fix(qqbot): approval button clicks rejected for DM sessions - #49399
Closed
RCMartinChen wants to merge 1 commit into
Closed
RCMartinChen wants to merge 1 commit into
RCMartinChen wants to merge 1 commit into
Conversation
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.
Contributor
|
Duplicate of #31593 — both fix the QQBot DM approval-button rejection by changing |
Author
|
Closing as duplicate of #31593, which has the same fix with test coverage. Added production performance data there to help push for merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(ingateway/session.py) uses"dm"as the chat_type for private chats, producing session keys like:But
_is_authorized_interaction_for_session(ingateway/platforms/qqbot/adapter.py) checks for"c2c":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:
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:Only the authorization check in
_is_authorized_interaction_for_sessionis changed. The otherchat_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.