AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug] Bare @ mention skips group chat context injection

Open OMSociety opened this issue 1 week ago • 0 comments

Description

When a group message consists of only an @ to the bot (no text), AstrBot does not inject the group chat context (messages sent since the bot's last reply) into the LLM request. The same @ with any text does get the context.

Steps to reproduce

  1. Enable group chat context awareness (group_icl_enable), keep empty_mention_waiting and empty_mention_waiting_need_reply at their defaults.
  2. In a group, users send a few ordinary messages that do not wake the bot.
  3. Send a message that contains only @bot.
  4. Inspect the LLM request: the <system_reminder>You are in a group chat... block is missing. Send @bot hello instead and the block is present.

Cause

handle_empty_mention (priority maxsize - 1) handles single-@ messages first, calls event.request_llm(..., contexts=[]) and always ends with event.stop_event(). on_message (priority maxsize - 2), the only place that calls group_chat_context.handle_message, never runs, so the event has no _group_context_record_id. GroupChatContext.on_req_llm then returns immediately because it has no record to anchor on.

This is different from #10723 (context is injected but the model ignores it): here nothing is injected at all.

Expected

A bare @ should be recorded like any other group message, so the pending group context is injected into the request it triggers.

Environment

AstrBot master (0cd42bd4d), Windows desktop, aiocqhttp (OneBot v11, via an external bridge).

OMSociety avatar Nov 23 '26 16:11 OMSociety