AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

引用消息异常

Open mjy1113451 opened this issue 2 months ago • 13 comments

[2026-10-01 15:51:18.353] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1693]: enhance-mode | default:GroupMessage:1075920323 | [你没被移除群聊 ……/15:51:18] #msg-980057644: [Quote #msg-1338457822 小Q: 有瓜?] [At: 小Q] 没 [2026-10-01 15:51:18.354] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1716]: enhance-mode | group history updated | origin=default:GroupMessage:1075920323 size=55 [2026-10-01 15:51:18.354] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_parser - on_message [2026-10-01 15:51:18.359] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_welcome_group - on_group_increase [2026-10-01 15:51:18.359] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_welcome_group - on_group_decrease [2026-10-01 15:51:18.359] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_pokepro - on_message [2026-10-01 15:51:18.362] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_emoji_like - on_message [2026-10-01 15:51:18.363] [Core] [DBUG] [method.star_request:46]: plugin -> meme_manager - handle_upload_image [2026-10-01 15:51:18.363] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - on_message [2026-10-01 15:51:18.365] [Core] [DBUG] [agent_sub_stages.internal:201]: ready to request llm provider [2026-10-01 15:51:18.366] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnWaitingLLMRequestEvent) -> meme_manager - mark_llm_request_origin [2026-10-01 15:51:18.366] [Core] [DBUG] [agent_sub_stages.internal:239]: acquired session lock for llm request [2026-10-01 15:51:18.526] [Core] [DBUG] [tools.knowledge_base_tools:77]: [知识库] 使用全局配置,知识库数量: 0 [2026-10-01 15:51:18.527] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> meme_manager - inject_meme_prompt [2026-10-01 15:51:18.531] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot_plugin_recall_cancel - on_llm_request [2026-10-01 15:51:18.531] [Plug] [DBUG] [astrbot_plugin_recall_cancel.main:866]: [RecallCancel] Tracked LLM request | msg_id=-980057644 [2026-10-01 15:51:18.532] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> input_state_by_napcat - on_llm_req [2026-10-01 15:51:18.532] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot_plugin_astrbot_enhance_mode - inject_role [2026-10-01 15:51:18.532] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot_plugin_astrbot_enhance_mode - inject_group_context [2026-10-01 15:51:18.533] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1736]: enhance-mode | injecting group context | origin=default:GroupMessage:1075920323 history_size=55 [2026-10-01 15:51:18.533] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req [2026-10-01 15:51:18.534] [Core] [DBUG] [runners.base:70]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING [2026-10-01 15:51:18.534] [Core] [DBUG] [runners.tool_loop_agent_runner:695]: [BefCompact] messages -> [2] system,user [2026-10-01 15:51:18.534] [Core] [DBUG] [runners.tool_loop_agent_runner:695]: [AftCompact] messages -> [2] system,user [2026-10-01 15:51:19.785] [Core] [DBUG] [sources.openai_source:586]: completion: ChatCompletion(id='070d43f6200aba826d3486ee9383ae91', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='切', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1790841079, model='MiniMax-M3', object='chat.completion', moderation=None, service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=11, prompt_tokens=12570, total_tokens=12581, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=0, reasoning_tokens=0, rejected_prediction_tokens=None, text_tokens=0, image_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cache_write_tokens=None, cached_tokens=128, text_tokens=0, image_tokens=0), usage_semantic='openai', usage_source='anthropic', billing_usage={'source': 'claude_messages', 'semantic': 'anthropic', 'claude_usage': {'input_tokens': 12442, 'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 128, 'output_tokens': 11, 'claude_cache_creation_5_m_tokens': 0, 'claude_cache_creation_1_h_tokens': 0}}, input_tokens=12570, output_tokens=0, input_tokens_details=None, claude_cache_creation_5_m_tokens=0, claude_cache_creation_1_h_tokens=0)) [2026-10-01 15:51:19.785] [Core] [DBUG] [runners.base:70]: Agent state transition: AgentState.RUNNING -> AgentState.DONE [2026-10-01 15:51:19.786] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> meme_manager - resp [2026-10-01 15:51:19.786] [Plug] [INFO] [mixins.event_handlers:1113]: [meme_manager] 去重后的最终表情列表: [] [2026-10-01 15:51:19.787] [Plug] [DBUG] [mixins.event_handlers:1124]: [meme_manager] 清理后的最终文本内容长度: 25 [2026-10-01 15:51:19.787] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_recall_cancel - on_llm_response [2026-10-01 15:51:19.787] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_stealer - _prepare_emoji_after_llm [2026-10-01 15:51:19.787] [astrbot_plugin_stealer] [DBUG] [events.meme_sender_engine:249]: [Stealer] 当前轮次自动发表情判定: allowed=True, reason=chance_hit [2026-10-01 15:51:19.787] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_relationship_manager - on_llm_response [2026-10-01 15:51:19.788] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_astrbot_enhance_mode - record_bot_response [2026-10-01 15:51:19.788] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1849]: enhance-mode | recorded AI response: default:GroupMessage:1075920323 | [You/15:51:19]: 切 [2026-10-01 15:51:19.788] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1864]: enhance-mode | bot response recorded | origin=default:GroupMessage:1075920323 size=56 [2026-10-01 15:51:19.788] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> input_state_by_napcat - on_llm_resp [2026-10-01 15:51:19.791] [astrbot_plugin_stealer] [DBUG] [processing.natural_emotion_analyzer:370]: [情绪分析] 使用当前会话模型: openai_2/MiniMax-M3 [2026-10-01 15:51:19.791] [astrbot_plugin_stealer] [DBUG] [processing.natural_emotion_analyzer:326]: [情绪分析] 调用LLM,provider_id=openai_2/MiniMax-M3 [2026-10-01 15:51:20.038] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot - persist_llm_response [2026-10-01 15:51:20.038] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_recall_cancel - on_llm_response_recorded [2026-10-01 15:51:20.039] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> meme_manager - on_decorating_result [2026-10-01 15:51:20.039] [Plug] [DBUG] [mixins.event_handlers:1183]: [meme_manager] on_decorating_result 开始处理 [2026-10-01 15:51:20.039] [Plug] [DBUG] [mixins.event_handlers:1370]: [meme_manager] on_decorating_result 处理完成 [2026-10-01 15:51:20.040] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_stealer - _prepare_emoji_response [2026-10-01 15:51:20.040] [astrbot_plugin_stealer] [DBUG] [events.meme_sender_engine:249]:

Image_1790841189865_970.png bot离奇引用了1970年的空白消息

mjy1113451 avatar Oct 01 '26 07:10 mjy1113451

结论:插件问题 —— <quote id="..."> 不是本体的能力,核心生成引用的唯一路径取的是真实事件里的 id,没有幻觉空间 根因:模型输出了 <quote id="2279005773"/>,该 id 在所给日志的会话中并不存在,被原样透传到平台端,于是渲染成时间戳为 0 的空白引用;日志中 astrbot_plugin_astrbot_enhance_mode 正在注入带 #msg-<id> 的群历史(history_size=55),"由模型自选引用目标"的机制应来自该插件 —— astrbot/core/pipeline/result_decorate/stage.py:445 @ 6d50e1e3(静态定位,未实机复现) 建议:插件侧对 quote id 做白名单校验(只允许引用当前会话上下文中真实出现过的消息 id);本体侧可在消息组装时丢弃 id 无效的引用作为兜底 需要补充的信息:复现步骤、插件版本与完整插件列表

以上为 AI 生成内容。

silvaling avatar Oct 01 '26 12:10 silvaling

感谢反馈。现象可以确认:Bot 发出的消息带了一个引用(Reply)组件,但该引用指向的消息在客户端侧解析为空、时间戳为 0(即 Unix 纪元 1970-01-01),所以显示成"1970 年的空白消息"。

初步定位

AstrBot 的 Reply 组件里,时间默认值是 0:

# astrbot/core/message/components.py
class Reply(BaseMessageComponent):
    id: str | int
    chain: list[BaseMessageComponent] | None = []
    sender_id: int | None | str = 0
    sender_nickname: str | None = ""
    time: int | None = 0          # 0 -> 1970
    message_str: str | None = ""

出站引用目前只填了 id,没有携带被引用消息的元数据:

# astrbot/core/pipeline/result_decorate/stage.py:445
# 引用回复
if self.reply_with_quote:
    result.chain.insert(0, Reply(id=event.message_obj.message_id))

也就是说,是否能正常显示引用,完全取决于 event.message_obj.message_id 在协议端(NapCat/Lagrange 等)能否被解析到。一旦这个 id 无效、过期或为空,客户端就会回退成"空白 + 1970"。

对比一下入站引用的解析逻辑(aiocqhttp_platform_adapter.py:303),在 get_msg 成功时是会把 time、sender_nickname、message_str 一起带上的;失败时也会 fallback。问题更可能出在出站这条只用 id 的路径,或某个插件在 OnLLMResponseEvent / on_decorating_result 阶段插入了一个无效 Reply。

从你的日志看,这条消息还经过了 astrbot_enhance_mode、recall_cancel、meme_manager、stealer 等多个插件,它们都可能改写结果链,所以暂时无法断定是核心流程还是插件导致。

需要补充的信息(按需提供)

  1. 出站那条消息最终的消息链:能不能在发送前打印 result.chain,确认这个 Reply 的 id 到底是什么、由哪个阶段插入?
  2. 协议端与版本:NapCat / Lagrange 的具体版本,AstrBot 版本号。
  3. 是否开启引用回复:platform_settings.reply_with_quote 是否为 true?
  4. 插件清单与版本:尤其是 astrbot_enhance_mode、recall_cancel、meme_manager、stealer。
  5. 复现条件:是否稳定复现?触发时是否都伴随"用户引用某人 + @ + 短文本"这种结构?
  6. 完整原始日志:现在贴出的日志在关键位置被截断了,看不到最终发出的消息链。

临时规避

如果暂时影响使用,可以先在配置里关闭 platform_settings.reply_with_quote,看是否就不再出现 1970 空白引用——这也能帮我们判断问题是否出在核心的引用插入逻辑。

内容由 AI 生成,仅供参考

mantoujun12 avatar Oct 01 '26 13:10 mantoujun12

Snowluma 1.14.8 Astrbot为最新版 开启引用回复 提到的几个插件都为最新版本 复现条件为引用为1970.1.01日期的空白消息,未@任何用户,会出现1-2个字的短文本

mjy1113451 avatar Oct 01 '26 13:10 mjy1113451

近一两个小时,无复现,无法给出更多日志

mjy1113451 avatar Oct 01 '26 14:10 mjy1113451

近一两个小时,无复现,无法给出更多日志

复现不了先关了吧,下次如果还有这个问题再重新开启。

mantoujun12 avatar Oct 02 '26 01:10 mantoujun12

近一两个小时,无复现,无法给出更多日志

复现不了先关了吧,下次如果还有这个问题再重新开启。

没事,我再有复现再粘个日志就行

mjy1113451 avatar Oct 02 '26 01:10 mjy1113451

[2026-10-03 22:10:01.265] [Core] [INFO] [respond.stage:233]: Prepare to send - 𝗝𝘂𝗿𝘂𝗼𝘆𝗮𝟭/3303489145: [引用消息] 你真吃过啊 [2026-10-03 22:10:01.770] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_recall_cancel - after_message_sent [2026-10-03 22:10:01.771] [Plug] [DBUG] [astrbot_plugin_recall_cancel.main:966]: [RecallCancel] 消息已发送,清理记录 | 消息ID: 653666436 [2026-10-03 22:10:01.771] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_rg2 - _on_message_sent [2026-10-03 22:10:01.771] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_group_admin - after_message_sent [2026-10-03 22:10:01.906] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_astrbot_enhance_mode - after_message_sent [2026-10-03 22:10:01.907] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> input_state_by_napcat - after_message_sent [2026-10-03 22:10:01.907] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> meme_manager - _after_message_sent_impl [2026-10-03 22:10:01.907] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> meme_manager - after_message_sent [2026-10-03 22:10:01.908] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot - after_message_sent [2026-10-03 22:10:01.938] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_parser - on_message [2026-10-03 22:10:01.942] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_welcome_group - on_group_increase [2026-10-03 22:10:01.943] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_welcome_group - on_group_decrease [2026-10-03 22:10:01.943] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_pokepro - on_message [2026-10-03 22:10:01.944] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_emoji_like - on_message [2026-10-03 22:10:01.944] [Core] [DBUG] [method.star_request:46]: plugin -> meme_manager - handle_upload_image [2026-10-03 22:10:01.945] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - on_message [2026-10-03 22:10:01.945] [Core] [DBUG] [pipeline.scheduler:97]: pipeline execution completed.

又引用了1970的消息

mjy1113451 avatar Oct 03 '26 14:10 mjy1113451

这是从bot发言到日志最底下

mjy1113451 avatar Oct 03 '26 14:10 mjy1113451

[2026-10-03 22:09:58.555] [Core] [DBUG] [waking_check.stage:172]: enabled_plugins_name: ['*'] [2026-10-03 22:09:58.559] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - handle_session_control_agent [2026-10-03 22:09:58.559] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - handle_empty_mention [2026-10-03 22:09:58.559] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - persist_group_message [2026-10-03 22:09:58.560] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_astrbot_enhance_mode - guard_banned_user [2026-10-03 22:09:58.560] [Core] [DBUG] [method.star_request:46]: plugin -> qq_group_sign - _capture_bot_instance [2026-10-03 22:09:58.560] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_recall_cancel - on_all_message [2026-10-03 22:09:58.560] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_group_admin - on_group_message [2026-10-03 22:09:58.560] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_group_admin - on_group_event [2026-10-03 22:09:58.560] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_stealer - on_message [2026-10-03 22:09:58.561] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_relationship_manager - handle_event [2026-10-03 22:09:58.561] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_relationship_manager - handle_notice [2026-10-03 22:09:58.561] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_rg2 - on_group_message [2026-10-03 22:09:58.561] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_astrbot_enhance_mode - on_group_message [2026-10-03 22:09:58.561] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1492]: enhance-mode | active_reply probability | origin=default:GroupMessage:1075920323 sample=0.0392 threshold=0.1000 decision=True [2026-10-03 22:09:58.562] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1693]: enhance-mode | default:GroupMessage:1075920323 | [𝗝𝘂𝗿𝘂𝗼𝘆𝗮𝟭/22:09:58] #msg653666436: 吃 [2026-10-03 22:09:58.562] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1716]: enhance-mode | group history updated | origin=default:GroupMessage:1075920323 size=300 [2026-10-03 22:09:58.563] [astrbot_plugin_astrbot_enhance_mode] [INFO] [astrbot_plugin_astrbot_enhance_mode.main:1612]: enhance-mode | active_reply triggered | origin=default:GroupMessage:1075920323 mode=probability provider=ProviderOpenAIOfficial [2026-10-03 22:09:58.567] [Core] [DBUG] [agent_sub_stages.internal:201]: ready to request llm provider [2026-10-03 22:09:58.567] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnWaitingLLMRequestEvent) -> meme_manager - mark_llm_request_origin [2026-10-03 22:09:58.567] [Core] [DBUG] [agent_sub_stages.internal:239]: acquired session lock for llm request [2026-10-03 22:09:58.750] [Core] [DBUG] [tools.knowledge_base_tools:77]: [知识库] 使用全局配置,知识库数量: 0 [2026-10-03 22:09:58.751] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> meme_manager - inject_meme_prompt [2026-10-03 22:09:58.752] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot_plugin_recall_cancel - on_llm_request [2026-10-03 22:09:58.752] [Plug] [DBUG] [astrbot_plugin_recall_cancel.main:866]: [RecallCancel] Tracked LLM request | msg_id=653666436 [2026-10-03 22:09:58.753] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> input_state_by_napcat - on_llm_req [2026-10-03 22:09:58.753] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot_plugin_astrbot_enhance_mode - inject_role [2026-10-03 22:09:58.753] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot_plugin_astrbot_enhance_mode - inject_group_context [2026-10-03 22:09:58.753] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1736]: enhance-mode | injecting group context | origin=default:GroupMessage:1075920323 history_size=300 [2026-10-03 22:09:58.753] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req [2026-10-03 22:09:58.754] [Core] [DBUG] [runners.base:70]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING [2026-10-03 22:09:58.754] [Core] [DBUG] [runners.tool_loop_agent_runner:695]: [BefCompact] messages -> [2] system,user [2026-10-03 22:09:58.755] [Core] [DBUG] [runners.tool_loop_agent_runner:695]: [AftCompact] messages -> [2] system,user [2026-10-03 22:10:00.864] [Core] [DBUG] [sources.openai_source:586]: completion: ChatCompletion(id='07103fb6e95cfe1fa73f27fc2bea1d96', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='你真吃过啊', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1791036600, model='MiniMax-M3', object='chat.completion', moderation=None, service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=13, prompt_tokens=19821, total_tokens=19834, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=0, reasoning_tokens=0, rejected_prediction_tokens=None, text_tokens=0, image_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cache_write_tokens=None, cached_tokens=128, text_tokens=0, image_tokens=0), usage_semantic='openai', usage_source='anthropic', billing_usage={'source': 'claude_messages', 'semantic': 'anthropic', 'claude_usage': {'input_tokens': 19693, 'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 128, 'output_tokens': 13, 'claude_cache_creation_5_m_tokens': 0, 'claude_cache_creation_1_h_tokens': 0}}, input_tokens=19821, output_tokens=0, input_tokens_details=None, claude_cache_creation_5_m_tokens=0, claude_cache_creation_1_h_tokens=0)) [2026-10-03 22:10:00.864] [Core] [DBUG] [runners.base:70]: Agent state transition: AgentState.RUNNING -> AgentState.DONE [2026-10-03 22:10:00.865] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> meme_manager - resp [2026-10-03 22:10:00.865] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_recall_cancel - on_llm_response [2026-10-03 22:10:00.865] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_stealer - _prepare_emoji_after_llm [2026-10-03 22:10:00.865] [astrbot_plugin_stealer] [DBUG] [events.meme_sender_engine:249]: [Stealer] 当前轮次自动发表情判定: allowed=False, reason=chance_miss [2026-10-03 22:10:00.865] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_relationship_manager - on_llm_response [2026-10-03 22:10:00.866] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_astrbot_enhance_mode - record_bot_response [2026-10-03 22:10:00.866] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1849]: enhance-mode | recorded AI response: default:GroupMessage:1075920323 | [You/22:10:00]: 你真吃过啊 [2026-10-03 22:10:00.866] [astrbot_plugin_astrbot_enhance_mode] [DBUG] [astrbot_plugin_astrbot_enhance_mode.main:1864]: enhance-mode | bot response recorded | origin=default:GroupMessage:1075920323 size=300 [2026-10-03 22:10:00.866] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> input_state_by_napcat - on_llm_resp [2026-10-03 22:10:01.260] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot - persist_llm_response [2026-10-03 22:10:01.260] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnLLMResponseEvent) -> astrbot_plugin_recall_cancel - on_llm_response_recorded [2026-10-03 22:10:01.260] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> meme_manager - on_decorating_result [2026-10-03 22:10:01.261] [Plug] [DBUG] [mixins.event_handlers:1183]: [meme_manager] on_decorating_result 开始处理 [2026-10-03 22:10:01.261] [Plug] [DBUG] [mixins.event_handlers:1370]: [meme_manager] on_decorating_result 处理完成 [2026-10-03 22:10:01.261] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_stealer - _prepare_emoji_response [2026-10-03 22:10:01.261] [astrbot_plugin_stealer] [DBUG] [events.meme_sender_engine:249]: [Stealer] 当前轮次自动发表情判定: allowed=False, reason=chance_miss [2026-10-03 22:10:01.262] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_recall_cancel - on_decorating_result [2026-10-03 22:10:01.262] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_rg2 - _on_decorating_result [2026-10-03 22:10:01.262] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_relationship_manager - on_decorating_result [2026-10-03 22:10:01.262] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_astrbot_enhance_mode - parse_tags [2026-10-03 22:10:01.262] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> input_state_by_napcat - on_decorating_result [2026-10-03 22:10:01.265] [Core] [INFO] [respond.stage:233]: Prepare to send - 𝗝𝘂𝗿𝘂𝗼𝘆𝗮𝟭/3303489145: [引用消息] 你真吃过啊 [2026-10-03 22:10:01.770] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_recall_cancel - after_message_sent [2026-10-03 22:10:01.771] [Plug] [DBUG] [astrbot_plugin_recall_cancel.main:966]: [RecallCancel] 消息已发送,清理记录 | 消息ID: 653666436 [2026-10-03 22:10:01.771] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_rg2 - _on_message_sent [2026-10-03 22:10:01.771] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_group_admin - after_message_sent [2026-10-03 22:10:01.906] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_astrbot_enhance_mode - after_message_sent [2026-10-03 22:10:01.907] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> input_state_by_napcat - after_message_sent [2026-10-03 22:10:01.907] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> meme_manager - _after_message_sent_impl [2026-10-03 22:10:01.907] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> meme_manager - after_message_sent [2026-10-03 22:10:01.908] [Core] [DBUG] [pipeline.context_utils:98]: hook(OnAfterMessageSentEvent) -> astrbot - after_message_sent [2026-10-03 22:10:01.938] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_parser - on_message [2026-10-03 22:10:01.942] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_welcome_group - on_group_increase [2026-10-03 22:10:01.943] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_welcome_group - on_group_decrease [2026-10-03 22:10:01.943] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_pokepro - on_message [2026-10-03 22:10:01.944] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_emoji_like - on_message [2026-10-03 22:10:01.944] [Core] [DBUG] [method.star_request:46]: plugin -> meme_manager - handle_upload_image [2026-10-03 22:10:01.945] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - on_message [2026-10-03 22:10:01.945] [Core] [DBUG] [pipeline.scheduler:97]: pipeline execution completed.

mjy1113451 avatar Oct 03 '26 14:10 mjy1113451

@mantoujun12

mjy1113451 avatar Oct 03 '26 14:10 mjy1113451

结论:模型侧触发 —— 在较长的上下文下输出了错误的引用 id;插件侧对该 id 无校验、原样透传,使其到达平台端 根因:本次注入的群历史为 300 条(prompt_tokens=19821),其中含大量 #msg<id> 形式的标识;模型返回了 <quote id="666440198"/>,而该次触发消息的真实 id 是 653666436。插件的解析路径在取出该 id 后仅做去 #/msg 前缀的清理,随即构造 Reply —— astrbot_plugin_astrbot_enhance_mode/tag_utils.py:36,76(两个公开仓库副本内容一致;因日志行号与二者当前 HEAD 均不匹配,无法钉死具体版本) 建议:插件侧在 transform_result_chain() 中,将 quote_msg_id 与当前会话上下文中真实存在的消息 id 比对后再决定是否 insert,不匹配时丢弃该 Reply(正文里的 <quote> 标签已在 :58 被剔除,丢弃引用不影响文本内容);本体侧无需改动 建议标签:area:core

判定依据:

  1. 模型输出的 id 与真实 id 不一致。本次日志中,插件记录本次触发的消息为 #msg653666436: 吃,而模型返回 content='<quote id="666440198"/>你真吃过啊'。两者不同,说明该 id 由模型给出,并非取自事件对象。
  2. 上下文规模与其承载的 id 密度。同次请求中插件注入的群历史条数为 300(injecting group context | history_size=300),模型侧 prompt_tokens=19821。历史中每条消息都带 #msg<id>,可供抄取的候选数量很大。
  3. 插件的 prompt 本就要求模型自行填写该 id。tag_utils.py:105-113 的 ## Quote 段写明 place <quote id="msg_id"/>、The msg_id can be found in the chat history after the # symbol (e.g. #msg12345),即让模型从历史中抄一个,属模型可控输入。
  4. 解析与构造路径未做校验。tag_utils.py:34-36 用 QUOTE_RE 取出字符串并仅做前缀清理(:18-26),:75-76 直接 new_chain.insert(0, Reply(id=quote_msg_id));该构造只传 id,而 Reply.time 默认值为 0(astrbot/core/message/components.py:594 @ 79a988b24),toDict() 按 OneBot V11 只输出 id(同文件 :610),因此协议端解析不到该 id 时回退为时间戳 0 的空白引用。

本体链路已排除:astrbot/core/pipeline/result_decorate/stage.py:446-447 @ 79a988b24 的 reply_with_quote 插入的是 Reply(id=event.message_obj.message_id),取自事件真实 id。

以上为 AI 生成内容,基于插件源码与本次日志比对,未在本机复现。

silvaling avatar Oct 03 '26 14:10 silvaling

这个是插件的问题吧 下面是分析的实际代码链路

1. 插件把模型输出转换为 Reply

插件仓库:

Axi404/astrbot_plugin_astrbot_enhance_mode

当前 tag_utils.py 的逻辑是:

  if quote_msg_id:
      new_chain.insert(0, Reply(id=quote_msg_id))

它只做了:

  • 去掉 #
  • 去掉 msg 前缀
  • 保留模型提供的字符串

没有做:

  • 是否存在于当前会话历史
  • 是否属于当前群
  • 是否能通过 OneBot get_msg 查询到
  • 是否为合法消息 ID

所以:

  <quote id="666440198"/>你真吃过啊

会直接变成:

  Reply(id="666440198")

2. AstrBot 核心只发送这个 ID

当前核心代码:

astrbot/core/message/components.py:584

  class Reply(BaseMessageComponent):
      time: int | None = 0

但出站序列化在 toDict() 中只发送:

  return {"type": "reply", "data": {"id": str(self.id)}}

所以实际 OneBot payload 是:

  {
    "type": "reply",
    "data": {
      "id": "666440198"
    }
  }

time=0、sender_id=0、message_str="" 都不会发送到 OneBot。

3. NapCat/Snowluma 无法解析 ID

如果 OneBot 端无法找到该消息,客户端只能用空的引用对象渲染:

  • 消息正文为空
  • 时间戳默认为 0
  • 显示为 1970-01-01

因此 1970 是协议端解析失败后的表现,不是实际消息时间。

reply_with_quote 是否是根因

不是主要根因,但存在功能重叠。

AstrBot 核心的 reply_with_quote 逻辑位于:

astrbot/core/pipeline/result_decorate/stage.py:428-445

它只会在最终结果链全部是 Plain / Image 时,自动引用当前收到的消息:

  if self.reply_with_quote:
      result.chain.insert(0, Reply(id=event.message_obj.message_id))

而插件的处理顺序是:

  1. 插件先解析
  2. 插件插入 Reply(id=模型生成的 ID)
  3. 核心随后检查结果链
  4. 结果链已经包含 Reply
  5. can_decorate 为 False
  6. 核心不会再插入当前消息的合法 ID

所以本次异常路径中,真正发送的是插件生成的 ID。

插件 README 也明确建议关闭 AstrBot 内置 reply_with_quote,避免两套引用机制重叠。但要注意:

仅关闭核心 reply_with_quote 不能修复插件生成的无效 ,因为插件仍然会自行插入 Reply。

日志中的关键链路是:

  completion: ... <quote id="666440198"/>你真吃过啊
  ...
  hook(on_decorating_result) -> astrbot_plugin_astrbot_enhance_mode - parse_tags
  ...
  Prepare to send ... [引用消息] 你真吃过啊

为什么不是其他插件导致

这条链已经足够说明:

  • Quote 标签首先出现在 LLM completion 中
  • astrbot_enhance_mode.parse_tags 明确处理了它
  • 其他插件日志没有显示它们创建或修改了 Reply
  • meme_manager、stealer、recall_cancel 等插件目前没有直接证据是引用 ID 的来源

因此责任优先级是:

  1. astrbot_plugin_astrbot_enhance_mode:主要问题
  2. 模型输出不可靠:触发条件
  3. AstrBot 核心:缺少跨插件的最终兜底校验,但不是本次直接缺陷

[!NOTE] 所以该 issue 应优先转给插件仓库处理,而不是修改 AstrBot 的 Reply.time这个是插件自己的问题astrbot只是少了一层兜底罢了

piexian avatar Oct 03 '26 14:10 piexian

好的,那我fork一下那个插件仓库改下看看

mjy1113451 avatar Oct 04 '26 00:10 mjy1113451