fix(qqofficial): send proactively before passive reply window expires - #9615
Open
TheRainstorm wants to merge 2 commits into
Open
fix(qqofficial): send proactively before passive reply window expires#9615TheRainstorm wants to merge 2 commits into
TheRainstorm wants to merge 2 commits into
Conversation
QQ official passive replies are only valid for 5 minutes. Long-running tasks (e.g. agent tool loops) that exceed the window fail with "回复消息msg_id已过期". When the reply age approaches the limit, skip msg_id and send proactively (active-message API), avoiding a wasted request and the expired-msg_id error.
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider using a monotonic clock (e.g.,
time.monotonic()) or a precomputedcreated_at_monotonicfield rather thantime.time()for the passive window check to avoid issues if system time changes while a long-running task is executing. - The proactive margin constants (
_QQOFFICIAL_PASSIVE_REPLY_SECONDSand_QQOFFICIAL_PROACTIVE_MARGIN_SECONDS) are hard-coded; if different bots or environments require different timing, it may be useful to make these values configurable via existing settings or environment variables.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using a monotonic clock (e.g., `time.monotonic()`) or a precomputed `created_at_monotonic` field rather than `time.time()` for the passive window check to avoid issues if system time changes while a long-running task is executing.
- The proactive margin constants (`_QQOFFICIAL_PASSIVE_REPLY_SECONDS` and `_QQOFFICIAL_PROACTIVE_MARGIN_SECONDS`) are hard-coded; if different bots or environments require different timing, it may be useful to make these values configurable via existing settings or environment variables.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Author
|
Addressed the review feedback:
|
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 official passive replies (
msg_id-based) are only valid for 5 minutes. Long-running tasks (e.g. an agent running tools for several minutes) exceed this window, and the final reply fails with:The existing fallback then retries once without
msg_id, wasting a request and often failing again for group messages.Fix
When a group reply's age approaches the 5-minute passive window (60s margin), build the payload without
msg_idfrom the start, i.e. send via the proactive (active-message) API directly:_QQOFFICIAL_PASSIVE_REPLY_SECONDS = 300,_QQOFFICIAL_PROACTIVE_MARGIN_SECONDS = 60force_proactivecomputed in_post_send_oneforGroupMessageC2C/other sources keep the existing
msg_idbehavior; themsg_id-less proactive retry in_send_with_markdown_fallbackremains as a safety net.Notes
Summary by Sourcery
Bug Fixes: