-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug]3.5.18版本更新后,调用插件函数的对话不会被正确记录到对话历史内 #2498
Description
发生了什么
在3.5.18版本更新后,调用插件函数的对话不会被正确记录到对话历史内,导致在使用插件的时候无法正确关联上下文,目前是在插件astrbot_plugin_xiaoxue中发现,其他插件暂未测试
如何复现?
1.更新到3.5.18版本或以后的版本
2.使用插件调用函数,例如使用插件插件astrbot_plugin_xiaoxue,调用工具函数:generate_image 画图
3.查看对话数据库-对话管理,和调用函数相关的对话全都没有被记录
4.以上问题会导致后续对插件调用无法正确关联上下文,例如原先可以在第一次生成的图片基础上修改画图内容,现在无法记录后会导致LLM错误的认为之前没有调用过插件
AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
3.5.18,Docker,Gemini,QQ平台
操作系统
Other
报错日志
[15:49:08] [Core] [INFO] [core.event_bus:50]: [aiocqhttp] ミクがだいすき/357844208: 画个飞机
[15:49:08] [Core] [DBUG] [method.star_request:50]: plugin -> session_controller - handle_session_control_agent
[15:49:08] [Core] [DBUG] [method.star_request:50]: plugin -> session_controller - handle_empty_mention
[15:49:08] [Core] [DBUG] [method.star_request:50]: plugin -> astrbot_plugin_xiaoxue - save_upload_image
[15:49:08] [Core] [DBUG] [method.star_request:50]: plugin -> astrbot - on_message
[15:49:08] [Core] [DBUG] [method.llm_request:138]: hook(on_llm_request) -> astrbot - decorate_llm_req
[15:49:08] [Core] [DBUG] [method.llm_request:184]: 提供商请求 Payload: ProviderRequest(prompt=
[User ID: 357844208, Nickname: ミクがだいすき]
画个飞机, session_id=aiocqhttp:FriendMessage:357844208, image_urls=[], func_tool=[FuncTool(name=generate_image, parameters={'type': 'object', 'properties': {'model': {'type': 'string', 'description': '默认为oneObsession_15Noobai,如果用户指明了模型名,就在oneObsession_13,oneObsessionBranch_v4CS,waiNSFWIllustrious_v140,ILV miaomiaoHarem_vPredDogma10,miaomiaoHarem_v16G,JANKUV40TrainedNoobaiEPS_v40,oneObsession_1424D,oneObsessionBranch_v5Mature,oneObsession_07Noob,copycatNoob_mrV10VPred,shadowforgeVpred_V,oneObsession_15Noobai,oneObsessionBranch_v3MatureepsA,AniShadow_Forge,03-hassakuXLIllustrious_v22,04-novaAnimeXL_ilV90,08-ntrMIXIllustriousXL_xiii,09-novaFurryXL_illustriousV9b,12-ilustmix_v80,16-prefectIllustriousXL_v20p,miaomiaoHarem_vPredDogma11,noobaiV10,oneObsession_v155noobai中选择最接近的。'}, 'prompt': {'type': 'string', 'description': '需要把用户的需求翻译成danbooru的tag形式,要选用danbooru.donmai.us里存在的tag,作为输入参数。需要注意,tag不需要带下划线,并且需要保留\符号'}, 'width': {'type': 'number', 'description': '根据图片需求设定合适的宽度,范围是1024-1536, 用户可以自定义。'}, 'height': {'type': 'number', 'description': '根据图片需求设定合适的高度,范围是1024-1536, 用户可以自定义。'}, 'cfg': {'type': 'number', 'description': '默认为5,以0.5为单位,用户可以自定义。'}, 'gaoqing': {'type': 'boolean', 'description': '默认为False,只有当用户明确表达需要高清的时候才能设定为True'}, 'xiulian': {'type': 'boolean', 'description': '默认为False,只有当用户明确表达需要修脸的时候才能设定为True'}, 'fangda': {'type': 'boolean', 'description': '默认为False,只有当用户明确表达需要放大的时候才能设定为True'}, 'CNLX': {'type': 'number', 'description': '默认为1,如果用户指明了CN类型:深度预处理或接近的为1,线稿预处理或接近的为2,姿态预处理或接近的为3,只能从1,2,3中选择一个'}, 'yuce': {'type': 'string', 'description': '默认为eps,只有用户指明了模型为ILV miaomiaoHarem_vPredDogma10或copycatNoob_mrV10VPred或miaomiaoHarem_vPredDogma11,noobaiV10的时候才能设定为v_prediction'}, 'iti': {'type': 'boolean', 'description': '默认为False,只有当用户明确表达需要用图片生成图片的时候才能设定为True'}, 'xiushou': {'type': 'boolean', 'description': '默认为False,只有当用户明确表达需要修手的时候才能设定为True'}, 'neg': {'type': 'string', 'description': '用户表达不要或不希望或者直接说加入负面的时候,需要把用户不需要的翻译成danbooru的tag形式,要选用danbooru.donmai.us里存在的tag,作为输入参数。需要注意,tag不需要带下划线,并且需要保留\符号'}}}, description=根据用户需求生成图片, 通过上下文判断用户需要图片生成的时候调用。, active=True, origin=local), FuncTool(name=download_lora, parameters={'type': 'object', 'properties': {'roomId': {'type': 'string', 'description': '需要传入room_id'}, 'search_str': {'type': 'string', 'description': '用户需求的lora检索名,从当前对话或者上下文中,查找类似"XXXX的lora"中的"XXXX"部分,作为search_str'}, 'select_id': {'type': 'number', 'description': '需要下载的lora的番号1-3'}}}, description=用户非常明确的提出要下载lora时调用。, active=True, origin=local), FuncTool(name=get_lora_trigger, parameters={'type': 'object', 'properties': {'search_str': {'type': 'string', 'description': '用户需求的lora检索名,从当前对话或者上下文,查找类似"XXXX的lora"中的"XXXX"部分,作为search_str'}}}, description=用户非常明确的提出要获取lora触发词时调用。, active=True, origin=local), FuncTool(name=python_interpreter, parameters={'type': 'object', 'properties': {}}, description=Use this tool only if user really want to solve a complex problem and the problem can be solved very well by Python code.
For example, user can use this tool to solve math problems, edit image, docx, pptx, pdf, etc., active=False, origin=local), FuncTool(name=reminder, parameters={'type': 'object', 'properties': {'text': {'type': 'string', 'description': 'Must Required. The content of the reminder.'}, 'datetime_str': {'type': 'string', 'description': "Required when user's reminder is a single reminder. The datetime string of the reminder, Must format with %Y-%m-%d %H:%M"}, 'cron_expression': {'type': 'string', 'description': "Required when user's reminder is a repeated reminder. The cron expression of the reminder."}, 'human_readable_cron': {'type': 'string', 'description': 'Optional. The human readable cron expression of the reminder.'}}}, description=Call this function when user is asking for setting a reminder., active=True, origin=local), FuncTool(name=web_search, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': '和用户的问题最相关的搜索关键词,用于在 Google 上搜索。'}}}, description=搜索网络以回答用户的问题。当用户需要搜索网络以获取即时性的信息时调用此工具。, active=False, origin=local), FuncTool(name=fetch_url, parameters={'type': 'object', 'properties': {'url': {'type': 'string', 'description': 'The url of the website to fetch content from'}}}, description=fetch the content of a website with the given web url, active=False, origin=local)], contexts=['user: \n[User ID: 357844208, Nickname: ミクがだいすき]\n画个飞机', 'assistant: 好的,我这就为您绘制一架飞机。', 'user: \n[User ID: 357844208, Nickname: ミクがだいすき]\n画个飞机', 'assistant: ', 'tool: 告诉用户正在画图中', 'assistant: 好的,正在为您绘制一架飞机!请稍等片刻。'], system_prompt=Current datetime: 2025-08-19 15:49 (UTC)
一个AI画师, tool_calls_result=None)
[15:49:10] [Core] [DBUG] [sources.openai_source:117]: completion: ChatCompletion(id='chatcmpl-20250819234909152732108tC3hFmGo', choices=[Choice(finish_reason='tool_calls', index=0, logprobs=None, message=ChatCompletionMessage(content='', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_be219e68a48c4fbb948dcd06402c473d', function=Function(arguments='{"prompt":"airplane"}', name='generate_image'), type='function')]))], created=1755618550, model='gemini-2.5-flash', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=81, prompt_tokens=1463, total_tokens=1544, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=0, reasoning_tokens=66, rejected_prediction_tokens=None, text_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0, text_tokens=1463, image_tokens=0), input_tokens=0, output_tokens=0, input_tokens_details=None))
[15:49:10] [Core] [INFO] [method.llm_request:445]: 触发 1 个函数调用: ['generate_image']
[15:49:10] [Core] [INFO] [method.llm_request:532]: 调用工具函数:generate_image,参数:{'prompt': 'airplane'}
[15:49:11] [Core] [INFO] [respond.stage:212]: AstrBot -> ミクがだいすき/357844208: [引用消息] 正在努力画图中喵♡~~~
[15:49:11] [Core] [DBUG] [respond.stage:221]: hook(on_after_message_sent) -> astrbot - after_llm_req
[15:49:11] [Core] [DBUG] [method.llm_request:184]: 提供商请求 Payload: ProviderRequest(prompt=
[User ID: 357844208, Nickname: ミクがだいすき]
画个飞机, session_id=aiocqhttp:FriendMessage:357844208, image_urls=[], func_tool=None, contexts=['user: \n[User ID: 357844208, Nickname: ミクがだいすき]\n画个飞机', 'assistant: 好的,我这就为您绘制一架飞机。', 'user: \n[User ID: 357844208, Nickname: ミクがだいすき]\n画个飞机', 'assistant: ', 'tool: 告诉用户正在画图中', 'assistant: 好的,正在为您绘制一架飞机!请稍等片刻。'], system_prompt=Current datetime: 2025-08-19 15:49 (UTC)
一个AI画师, tool_calls_result=ToolCallsResult(tool_calls_info=AssistantMessageSegment(content=None, tool_calls=[{'id': 'call_be219e68a48c4fbb948dcd06402c473d', 'function': {'name': 'generate_image', 'arguments': '{"prompt": "airplane"}'}, 'type': 'function'}], role='assistant'), tool_calls_result=[ToolCallMessageSegment(tool_call_id='call_be219e68a48c4fbb948dcd06402c473d', content='告诉用户正在画图中', role='tool')]))
[15:49:11] [Core] [DBUG] [sources.openai_source:117]: completion: ChatCompletion(id='chatcmpl-202508192349111462828485eipDzLb', 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=1755618551, model='gemini-2.5-flash', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=15, prompt_tokens=217, total_tokens=232, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=0, reasoning_tokens=0, rejected_prediction_tokens=None, text_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0, text_tokens=217, image_tokens=0), input_tokens=0, output_tokens=0, input_tokens_details=None))
[15:49:12] [Core] [INFO] [respond.stage:212]: AstrBot -> ミクがだいすき/357844208: [引用消息] 好的,正在为您绘制一架飞机!请稍等片刻。
[15:49:12] [Core] [DBUG] [respond.stage:221]: hook(on_after_message_sent) -> astrbot - after_llm_req
[15:49:12] [Core] [DBUG] [pipeline.scheduler:79]: pipeline 执行完毕。
以上是3.5.17,对话记录内能正常看到调用函数的对话
[15:58:11] [Core] [INFO] [core.event_bus:50]: [aiocqhttp] ミクがだいすき/357844208: 画个飞机
[15:58:11] [Core] [DBUG] [method.star_request:50]: plugin -> session_controller - handle_session_control_agent
[15:58:11] [Core] [DBUG] [method.star_request:50]: plugin -> session_controller - handle_empty_mention
[15:58:11] [Core] [DBUG] [method.star_request:50]: plugin -> astrbot_plugin_xiaoxue - save_upload_image
[15:58:11] [Core] [DBUG] [method.star_request:50]: plugin -> astrbot - on_message
[15:58:11] [Core] [DBUG] [pipeline.context:33]: hook(on_llm_request) -> astrbot - decorate_llm_req
[15:58:11] [Core] [DBUG] [agent_runner.tool_loop_agent:60]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING
[15:58:12] [Core] [DBUG] [sources.openai_source:111]: completion: ChatCompletion(id='chatcmpl-20250819235811527783947TgLvuBWA', choices=[Choice(finish_reason='tool_calls', index=0, logprobs=None, message=ChatCompletionMessage(content='', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_a5313f08dfa349c18de50f5094eb1d83', function=Function(arguments='{"prompt":"airplane"}', name='generate_image'), type='function')]))], created=1755619092, model='gemini-2.5-flash', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=75, prompt_tokens=1386, total_tokens=1461, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=0, reasoning_tokens=60, rejected_prediction_tokens=None, text_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0, text_tokens=1386, image_tokens=0), input_tokens=0, output_tokens=0, input_tokens_details=None))
[15:58:12] [Core] [DBUG] [agent_runner.tool_loop_agent:109]: LLMResp: LLMResponse(role='tool', result_chain=None, tools_call_args=[{'prompt': 'airplane'}], tools_call_name=['generate_image'], tools_call_ids=['call_a5313f08dfa349c18de50f5094eb1d83'], raw_completion=ChatCompletion(id='chatcmpl-20250819235811527783947TgLvuBWA', choices=[Choice(finish_reason='tool_calls', index=0, logprobs=None, message=ChatCompletionMessage(content='', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_a5313f08dfa349c18de50f5094eb1d83', function=Function(arguments='{"prompt":"airplane"}', name='generate_image'), type='function')]))], created=1755619092, model='gemini-2.5-flash', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=75, prompt_tokens=1386, total_tokens=1461, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=0, reasoning_tokens=60, rejected_prediction_tokens=None, text_tokens=0), prompt_tokens_details=PromptTokensDetails(audio_tokens=0, cached_tokens=0, text_tokens=1386, image_tokens=0), input_tokens=0, output_tokens=0, input_tokens_details=None)), _new_record=None, _completion_text='', is_chunk=False)
[15:58:12] [Core] [INFO] [agent_runner.tool_loop_agent:184]: Agent 使用工具: ['generate_image']
[15:58:12] [Core] [INFO] [agent_runner.tool_loop_agent:256]: 使用工具:generate_image,参数:{'prompt': 'airplane'}
[15:58:12] [Core] [DBUG] [agent_runner.tool_loop_agent:60]: Agent state transition: AgentState.RUNNING -> AgentState.DONE
[15:58:12] [Core] [DBUG] [pipeline.scheduler:79]: pipeline 执行完毕
在切换到3.5.18后,调用插件相关的对话在对话历史内就看不到了
你愿意提交 PR 吗?
- 是的,我愿意提交 PR!
Code of Conduct
- 我已阅读并同意遵守该项目的 行为准则。