Repository navigation
fix(qqbot): streaming improvements — idle flush, remove splitText, replyMsgId TTL, markdown pipe - #5902
Closed
Eric-GoodBoy-Tech wants to merge 134 commits into
Closed
fix(qqbot): streaming improvements — idle flush, remove splitText, replyMsgId TTL, markdown pipe#5902Eric-GoodBoy-Tech wants to merge 134 commits into
Eric-GoodBoy-Tech wants to merge 134 commits into
Conversation
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.
What this PR does
Refactors QQ Bot streaming behavior: replaces BlockStreamer coalescing with a 2-second idle flush, removes a self-imposed 2000-character limit, adds 5-minute TTL to passive reply tracking, and fixes markdown table detection.
Adds P1 group features: full-message handling with groupAllPolicy, slash command unification across all message paths, noreply mechanism for non-@ messages, and @mention support with default Markdown replies.
Why it's needed
BlockStreamer incompatible with QQ Bot. BlockStreamer coalesces text by paragraph boundary (
\n\nat minChars=400). QQ Bot cannot edit sent messages, so coalesced chunks arrive as a single undecipherable message — e.g., 15 short tool-call progress updates get merged into one.Self-imposed character limit.
splitText()capped messages at 2000 characters with no API basis. QQ Bot Open Platform imposes no content length limit on text or markdown messages.Expired replyMsgId. Passive replies require
msg_idwithin a 5-minute window. Old code never removed expired entries, causing API rejections.Tables sent as plain text.
hasMarkdownSyntaxdid not detect pipe tables, so pure tables (no other markdown markers) were sent asmsg_type=0and rendered as raw text in QQ.No group full-message support. QQ Bot API v2 supports
GROUP_MESSAGE_CREATEevents (since 2025-06-22) when the group owner enables full-message permission. Previously all non-@ messages were silently dropped.Slash commands only worked in one path. C2C and full-message paths lacked slash command detection, causing
/help,/new,/clearto be treated as plain text.Changes
Streaming & Reply Infrastructure
BlockStreamer+splitTextwithonResponseChunkidle-flush (2-second timer)replyMsgIdCleanupTimer(5-minute TTL) to prevent stale passive replieshasMarkdownSyntax— all replies default to markdown (msg_type=2), API rejection triggers plain-text fallbacksplitText(no API character limit exists)P1 Group Features
handleGroupAll()withgroupAllPolicy(log|keyword|all) andkeywordTriggersGROUP_ADD_ROBOT,GROUP_DEL_ROBOT,GROUP_MSG_REJECT,GROUP_MSG_RECEIVEgroupActiveMsgEnabledper-group with state persistencehandleGroup,handleGroupAll, andhandleC2Cmsg_type=2) for @mention supportopenid/member_openidinto message context prefixbotOpenIdto model context[可选回复]prefix for non-@ messages, model outputs{{skip}}to skipSecurity hardening
api.ts: validate gateway URL protocol (wss:only) vianew URL()parsingQQChannel.ts: usesanitizeSenderName()andsanitizeLogText()from@qwen-code/channel-basefor all user-controlled input in prompts and audit logsQQChannel.ts:sanitizePromptText()applied to user message content in all three handlers to prevent prompt injection via invisible charactersQQChannel.ts: bot messages tagged with[bot]prefix for model judgment instead of hard blockReviewer Test Plan
How to verify
cd packages/channels/qqbot && npx vitest run— all 158 tests pass.settings.jsonwithblockStreaming: "off".groupAllPolicy: "all", and send/newin a group (with and without @mention).Evidence (Before & After)
Before: Model outputs 10 lines of tool-call progress → BlockStreamer merges them → one massive message.
After: Each status line appears as a separate message. The 2-second idle timer ensures complete sentences are sent as units.
Before (slash commands):
/newin C2C or full-message paths → treated as plain text → sent to LLM.After:
/newcorrectly intercepted byparseCommand()in all three paths.Tested on
Risk & Scope
contentfield (documented as required for groups but API appears to tolerate its absence).blockStreamingconfig for QQ Bot should be set to "off" — existing users with "on" will see no change unless they update their config. ThesplitTextfunction is removed.groupAllPolicy,keywordTriggers,groups.*.requireMention,allowMention,chatTypes— all backward-compatible with sensible defaults.cron-msg-experimental(replacesexperimentalfrom earlier draft) — gates all cron/non-prompt textChunk handling;falseby defaultLinked Issues
Closes #5901
Refs #6094 — cron/blockStreaming interaction resolved,
cron-msg-experimentalconfig replacesexperimental