Skip to content

fix(astrbot): preserve follow-ups after empty mentions - #10940

Open
zzlg-git wants to merge 4 commits into
AstrBotDevs:masterfrom
zzlg-git:fix/10937-empty-mention-waiting
Open

zzlg-git wants to merge 4 commits into
AstrBotDevs:masterfrom
zzlg-git:fix/10937-empty-mention-waiting

Conversation

@zzlg-git

@zzlg-git zzlg-git commented Nov 1, 2026 •

Copy link
Copy Markdown

Fixes #10937.

QQ Official can deliver an empty mention as [At(bot), Plain("")], causing the built-in handler to skip waiting. Once recognized, an empty mention also has a second failure window: the waiter is registered only after the optional LLM greeting, so follow-ups received during greeting generation can be missed.

Modifications / 改动点

  • Ignore whitespace-only Plain components when detecting empty mentions, without modifying the original message chain. Preserve normal handling of real text, images and files.
  • Start the existing 60-second waiter before yielding the optional greeting. Cancel and await its task when the handler exits.
  • Add 26 regression cases using the real handler, message event, ProcessStage and SessionWaiter, with controlled model-stage substitutes.

The waiting window now starts before greeting generation. Configuration defaults, session keys and access controls are unchanged.

  • This is NOT a breaking change.

Screenshots or Test Results / 运行截图或测试结果

Base: master at 2481b8346444f329b583dd9c9362ec060a1db603.
Environment: Windows, Python 3.12.16, isolated checkout and test data directory.

Command:

python -m pytest tests/unit/test_empty_mention_waiting.py tests/unit/test_session_waiter_pipeline.py tests/unit/test_group_chat_context_wiring.py tests/test_qqofficial_group_message_create.py -q --tb=short

Results:

  • New regression file against the unpatched base: 14 failed, 12 passed.
  • Patched combined run: 86 passed, including all 26 new cases.
  • ruff check .: passed.
  • ruff format --check .: 544 files already formatted.
  • git diff --check: passed.

Coverage includes follow-ups during and after greeting generation, silent waiting, timeout, cancellation, generator closure, greeting setup failure, concurrent follow-ups on one active waiter, and conversation separation. Existing audioop deprecation and pytest-asyncio fixture-scope warnings remain.

Validation limits: the full test suite and live QQ delivery were not run against this checkout. The same production patch on a local 4.29.4 instance successfully handled two live follow-ups sent after the greeting. The exact during-generation timing is verified offline only. Cross-member isolation and overlapping registrations for the same session are outside scope; greeting/reply delivery order is not guaranteed.


Checklist / 检查清单

Summary by Sourcery

Preserve empty-mention follow-ups by registering the waiting session before greeting generation and reliably replaying captured messages after the greeting.

Bug Fixes:

  • Preserve follow-up messages received while generating an empty-mention greeting, including messages delivered during greeting setup.
  • Recognize whitespace-only text alongside bot mentions as empty mentions without altering the original message chain.

Enhancements:

  • Ensure empty-mention session waiters are registered and cleaned up reliably across greeting failures, cancellation, timeout, and generator closure.
  • Maintain correct group-chat context separation between the greeting and replayed follow-up.

Tests:

  • Add regression coverage for empty-mention classification, follow-up capture timing, waiter lifecycle, greeting failures, cancellation, timeout, and group-context behavior.

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Nov 3, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Linked issues

#10937 [Bug] QQ 官方机器人单独 @ 无法进入等待,且问候生成期间可能漏接后续消息 · 3 of 3 met

# Requirement Status Notes
1 A standalone @ with an empty or whitespace-only Plain component starts waiting. ✅ Met Detection ignores whitespace-only Plain components in a filtered copy, leaving the original message chain unchanged.
2 Real text, images and files are not mistaken for an empty mention. ✅ Met Only whitespace-only Plain components are ignored; remaining components must still be exactly one mention or wake-prefix component.
3 Follow-ups received within the 60-second waiting window, including during greeting generation, are handled. ✅ Met The 60-second waiter is started and given a scheduling turn before the optional greeting is yielded.

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@sourcery-ai

sourcery-ai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Linked issues

Checked at commit b708402

#10937 [Bug] QQ 官方机器人单独 @ 无法进入等待,且问候生成期间可能漏接后续消息 · 3 of 3 met

# Requirement Status Notes
1 A standalone @ with empty or whitespace-only text starts the waiting period. ✅ Met Detection ignores whitespace-only Plain components in a filtered copy, leaving the original message chain unchanged.
2 Follow-ups received while the optional greeting is being generated are not lost. ✅ Met The waiter task is started and given a chance to register before greeting setup; captured follow-ups are re-enqueued after that setup.
3 Real text, images, and attachments are not misclassified as an empty mention. ✅ Met Only whitespace-only Plain components are filtered; real text and non-Plain components remain in the detection list.

@sourcery-ai
sourcery-ai Bot dismissed their stale review November 19, 2026 09:05

Sourcery withdrew this approval because the latest commits introduced blocking findings.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

This branch has not been deployed

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[Bug] QQ 官方机器人单独 @ 无法进入等待,且问候生成期间可能漏接后续消息

2 participants