[Bug] 唤醒词对ai不显示
Description
@bot 还有发出唤醒词(比如bot)的时候,“@bot”“bot”都不显示在对话数据里,导致ai认知出现混乱,更容易认错人了
Reproduction Steps
希望还是能原模原样存在对话数据,包括只是"@bot"没有追加文本的时候,也希望是原样发给ai,ai自然能理解
AstrBot Version
latest
Operating System
Windows
Deployment Method
windows
Message Platform Adapter
1738076005
Error Log
无
Supplementary Information
No response
Checklist
- [x] I have searched the Issue list for related issues and could not resolve the problem, or this issue has never been reported before.
- [x] I have tried disabling all plugins to rule out issues caused by plugins.
- [x] The issue I am reporting is related to AstrBot itself, not to a specific plugin.
- [x] I have read and agree to the project's Code of Conduct.
- [ ] (Optional) I am willing to submit a PR to help fix this issue.
Hi @joy040216-create! I'm Dosu and I'm helping the AstrBotTeam team.
这是代码中有意设计的行为,但确实会引发你描述的问题。唤醒词在两个地方被剥离:
1. @bot 在适配器层被移除
在 aiocqhttp 适配器中,第一个 @自身 的 mention 不会加入 message_str,只保留为 At 消息段对象 [1]。AI 收到的文本里因此不含 @bot。
2. 唤醒词前缀在 pipeline 层被截断
在 WakingCheckStage 中,当消息以 wake_prefix(如 bot)开头时,会直接从 message_str 里切掉该前缀 [2]:
event.message_str = event.message_str[len(wake_prefix):].strip()
传给 AI 的 prompt
build_main_agent 直接使用处理后的 event.message_str 作为 req.prompt [3],所以 AI 看到的是已经剥离了唤醒词的内容。
只发 @bot 或 bot 没有额外文本的情况: 此时 message_str 变成空字符串。代码中有空消息检查——InternalAgentSubStage 里的 has_valid_message [4] 以及 build_main_agent 中 prompt 为空且无附件时直接 return None [5]——都会导致跳过 LLM 请求,与你描述的现象一致。
如果想修复,需要改动两处:
astrbot/core/pipeline/waking_check/stage.py第 123 行:不完全剥离唤醒词,或者将其以某种标记保留。astrbot/core/astr_main_agent.py中build_main_agent构建 prompt 的部分(第 1602-1606 行):当 prompt 为空时补充一个默认占位文本(如空消息提示),让 AI 知道用户进行了无文字唤醒。
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.