AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug] 快速请求LLM,会导致历史记录丢失

Open nuomicici opened this issue 1 year ago • 4 comments

发生了什么

LLM对话回复时,在回复用户之前,用户再次发送消息,历史记录会被覆盖,只留下最后一轮回复

如何复现?

配置服务提供商后,进入任意对话

  1. 发送信息
  2. 在bot回复前再次发送信息
  3. 等待
  4. bot全部回复后发送“history”(或者直接查看对话数据里的内容)
  5. 问题出现

AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

4.x,Docker部署,任意提供商和消息平台。我会继续尝试旧版本是否会出现

操作系统

Linux

报错日志

[12:53:22] [Core] [DBUG] [webchat.webchat_adapter:127]: WebChatAdapter: [Plain(type=<ComponentType.Plain: 'Plain'>, text='1', convert=True)] 
 [12:53:22] [Core] [INFO] [core.event_bus:52]: [default] [webchat(webchat)] vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: 1  
 [12:53:22] [Core] [DBUG] [waking_check.stage:122]: enabled_plugins_name: ['*'] 
 [12:53:22] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_session_control_agent 
 [12:53:22] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_empty_mention 
 [12:53:22] [Core] [DBUG] [pipeline.context_utils:86]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req 
 [12:53:22] [Plug] [DBUG] [astrbot.main:1265]: Tool set for persona [%None]: ['reminder', 'python_interpreter', 'web_search', 'fetch_url', 'web_search_tavily', 'tavily_extract_web_page'] 
 [12:53:22] [Core] [DBUG] [method.llm_request:456]: handle provider[id: gemini_default] request: ProviderRequest(prompt=
[User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}1, session_id=webchat:FriendMessage:webchat!vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu!6d906efa-cc42-43e7-a3ee-81d86452ed67, image_urls=[], func_tool=ToolSet(tools=[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. Monday is 0 and Sunday is 6."}, '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=False, 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=web_search, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': '和用户的问题最相关的搜索关键词,用于在 Google 上搜索。'}, 'max_results': {'type': 'number', 'description': '返回的最大搜索结果数量,默认为 5。'}}}, 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), FuncTool(name=web_search_tavily, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': 'Required. Search query.'}, 'max_results': {'type': 'number', 'description': 'Optional. The maximum number of results to return. Default is 5. Range is 5-20.'}, 'search_depth': {'type': 'string', 'description': 'Optional. The depth of the search, must be one of \'basic\', \'advanced\'. Default is "basic".'}, 'topic': {'type': 'string', 'description': 'Optional. The topic of the search, must be one of \'general\', \'news\'. Default is "general".'}, 'days': {'type': 'number', 'description': "Optional. The number of days back from the current date to include in the search results. Please note that this feature is only available when using the 'news' search topic."}, 'time_range': {'type': 'string', 'description': "Optional. The time range back from the current date to include in the search results. This feature is available for both 'general' and 'news' search topics. Must be one of 'day', 'week', 'month', 'year'."}, 'start_date': {'type': 'string', 'description': "Optional. The start date for the search results in the format 'YYYY-MM-DD'."}, 'end_date': {'type': 'string', 'description': "Optional. The end date for the search results in the format 'YYYY-MM-DD'."}}}, description=A web search tool that uses Tavily to search the web for relevant content.
Ideal for gathering current information, news, and detailed web content analysis., active=False, origin=local), FuncTool(name=tavily_extract_web_page, parameters={'type': 'object', 'properties': {'url': {'type': 'string', 'description': 'Required. An URl to extract content from.'}, 'extract_depth': {'type': 'string', 'description': 'Optional. The depth of the extraction, must be one of \'basic\', \'advanced\'. Default is "basic".'}}}, description=Extract the content of a web page using Tavily., active=False, origin=local)]), contexts=prompt: 
[User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}1, image_count: 0, system_prompt=Current datetime: 2025-11-12 12:53 (CST), tool_calls_result=None) 
 [12:53:22] [Core] [DBUG] [runners.tool_loop_agent_runner:59]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING 
 [12:53:23] [Core] [DBUG] [webchat.webchat_adapter:127]: WebChatAdapter: [Plain(type=<ComponentType.Plain: 'Plain'>, text='2', convert=True)] 
 [12:53:23] [Core] [INFO] [core.event_bus:52]: [default] [webchat(webchat)] vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: 2  
 [12:53:23] [Core] [DBUG] [waking_check.stage:122]: enabled_plugins_name: ['*'] 
 [12:53:23] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_session_control_agent 
 [12:53:23] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_empty_mention 
 [12:53:23] [Core] [DBUG] [pipeline.context_utils:86]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req 
 [12:53:23] [Plug] [DBUG] [astrbot.main:1265]: Tool set for persona [%None]: ['reminder', 'python_interpreter', 'web_search', 'fetch_url', 'web_search_tavily', 'tavily_extract_web_page'] 
 [12:53:23] [Core] [DBUG] [method.llm_request:456]: handle provider[id: gemini_default] request: ProviderRequest(prompt=
[User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}2, session_id=webchat:FriendMessage:webchat!vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu!6d906efa-cc42-43e7-a3ee-81d86452ed67, image_urls=[], func_tool=ToolSet(tools=[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. Monday is 0 and Sunday is 6."}, '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=False, 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=web_search, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': '和用户的问题最相关的搜索关键词,用于在 Google 上搜索。'}, 'max_results': {'type': 'number', 'description': '返回的最大搜索结果数量,默认为 5。'}}}, 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), FuncTool(name=web_search_tavily, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': 'Required. Search query.'}, 'max_results': {'type': 'number', 'description': 'Optional. The maximum number of results to return. Default is 5. Range is 5-20.'}, 'search_depth': {'type': 'string', 'description': 'Optional. The depth of the search, must be one of \'basic\', \'advanced\'. Default is "basic".'}, 'topic': {'type': 'string', 'description': 'Optional. The topic of the search, must be one of \'general\', \'news\'. Default is "general".'}, 'days': {'type': 'number', 'description': "Optional. The number of days back from the current date to include in the search results. Please note that this feature is only available when using the 'news' search topic."}, 'time_range': {'type': 'string', 'description': "Optional. The time range back from the current date to include in the search results. This feature is available for both 'general' and 'news' search topics. Must be one of 'day', 'week', 'month', 'year'."}, 'start_date': {'type': 'string', 'description': "Optional. The start date for the search results in the format 'YYYY-MM-DD'."}, 'end_date': {'type': 'string', 'description': "Optional. The end date for the search results in the format 'YYYY-MM-DD'."}}}, description=A web search tool that uses Tavily to search the web for relevant content.
Ideal for gathering current information, news, and detailed web content analysis., active=False, origin=local), FuncTool(name=tavily_extract_web_page, parameters={'type': 'object', 'properties': {'url': {'type': 'string', 'description': 'Required. An URl to extract content from.'}, 'extract_depth': {'type': 'string', 'description': 'Optional. The depth of the extraction, must be one of \'basic\', \'advanced\'. Default is "basic".'}}}, description=Extract the content of a web page using Tavily., active=False, origin=local)]), contexts=prompt: 
[User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}2, image_count: 0, system_prompt=Current datetime: 2025-11-12 12:53 (CST), tool_calls_result=None) 
 [12:53:23] [Core] [DBUG] [runners.tool_loop_agent_runner:59]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING 
 [12:53:24] [Core] [DBUG] [sources.openai_source:119]: completion: ChatCompletion(id='chatcmpl-1762923204', choices=[Choice(finish_reason='STOP', index=0, logprobs=None, message=ChatCompletionMessage(content='I can help you set a reminder! What would you like to be reminded of, and when should I remind you?', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content="**Missing Piece in the Reminder Request**\n\nOkay, so I'm looking at this request to set a reminder, but something's off. The prompt, `{{prompt}}1`, is just hanging there like a data placeholder that never got filled in. It's supposed to be where the actual reminder content would be, the *what* and the *when*. But it's blank! Without that information, I can't do anything. I mean, how can I set a reminder without knowing what it's for or when it should go off?\n\nSo, I need to go back to the source. I need to get some clarification from the user, figure out what they actually want to be reminded about and exactly when they need that reminder. A solid reminder requires solid details, and right now, the details are MIA. Let's get that missing information and get this reminder set up properly.\n"))], created=1762923204, model='gemini-2.5-flash-lite', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=24, prompt_tokens=1011, total_tokens=1116, completion_tokens_details=None, prompt_tokens_details=None)) 
 [12:53:24] [Core] [DBUG] [runners.tool_loop_agent_runner:59]: Agent state transition: AgentState.RUNNING -> AgentState.DONE 
 [12:53:24] [Core] [DBUG] [pipeline.context_utils:86]: hook(OnLLMResponseEvent) -> thinking_filter - resp 
 [12:53:24] [Core] [DBUG] [result_decorate.stage:107]: hook(on_decorating_result) -> astrbot - decorate_result 
 [12:53:24] [Plug] [DBUG] [astrbot.main:1195]: Decorating result for event: <astrbot.core.platform.sources.webchat.webchat_event.WebChatMessageEvent object at 0x7e5f8c626a70> 
 [12:53:25] [Core] [DBUG] [webchat.webchat_adapter:127]: WebChatAdapter: [Plain(type=<ComponentType.Plain: 'Plain'>, text='3', convert=True)] 
 [12:53:25] [Core] [INFO] [core.event_bus:52]: [default] [webchat(webchat)] vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: 3  
 [12:53:25] [Core] [DBUG] [waking_check.stage:122]: enabled_plugins_name: ['*'] 
 [12:53:25] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_session_control_agent 
 [12:53:25] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_empty_mention 
 [12:53:25] [Core] [DBUG] [pipeline.context_utils:86]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req 
 [12:53:25] [Plug] [DBUG] [astrbot.main:1265]: Tool set for persona [%None]: ['reminder', 'python_interpreter', 'web_search', 'fetch_url', 'web_search_tavily', 'tavily_extract_web_page'] 
 [12:53:25] [Core] [DBUG] [method.llm_request:456]: handle provider[id: gemini_default] request: ProviderRequest(prompt=
[User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}3, session_id=webchat:FriendMessage:webchat!vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu!6d906efa-cc42-43e7-a3ee-81d86452ed67, image_urls=[], func_tool=ToolSet(tools=[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. Monday is 0 and Sunday is 6."}, '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=False, 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=web_search, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': '和用户的问题最相关的搜索关键词,用于在 Google 上搜索。'}, 'max_results': {'type': 'number', 'description': '返回的最大搜索结果数量,默认为 5。'}}}, 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), FuncTool(name=web_search_tavily, parameters={'type': 'object', 'properties': {'query': {'type': 'string', 'description': 'Required. Search query.'}, 'max_results': {'type': 'number', 'description': 'Optional. The maximum number of results to return. Default is 5. Range is 5-20.'}, 'search_depth': {'type': 'string', 'description': 'Optional. The depth of the search, must be one of \'basic\', \'advanced\'. Default is "basic".'}, 'topic': {'type': 'string', 'description': 'Optional. The topic of the search, must be one of \'general\', \'news\'. Default is "general".'}, 'days': {'type': 'number', 'description': "Optional. The number of days back from the current date to include in the search results. Please note that this feature is only available when using the 'news' search topic."}, 'time_range': {'type': 'string', 'description': "Optional. The time range back from the current date to include in the search results. This feature is available for both 'general' and 'news' search topics. Must be one of 'day', 'week', 'month', 'year'."}, 'start_date': {'type': 'string', 'description': "Optional. The start date for the search results in the format 'YYYY-MM-DD'."}, 'end_date': {'type': 'string', 'description': "Optional. The end date for the search results in the format 'YYYY-MM-DD'."}}}, description=A web search tool that uses Tavily to search the web for relevant content.
Ideal for gathering current information, news, and detailed web content analysis., active=False, origin=local), FuncTool(name=tavily_extract_web_page, parameters={'type': 'object', 'properties': {'url': {'type': 'string', 'description': 'Required. An URl to extract content from.'}, 'extract_depth': {'type': 'string', 'description': 'Optional. The depth of the extraction, must be one of \'basic\', \'advanced\'. Default is "basic".'}}}, description=Extract the content of a web page using Tavily., active=False, origin=local)]), contexts=prompt: 
[User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}3, image_count: 0, system_prompt=Current datetime: 2025-11-12 12:53 (CST), tool_calls_result=None) 
 [12:53:25] [Core] [DBUG] [runners.tool_loop_agent_runner:59]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING 
 [12:53:26] [Core] [DBUG] [sources.openai_source:119]: completion: ChatCompletion(id='chatcmpl-1762923205', choices=[Choice(finish_reason='STOP', index=0, logprobs=None, message=ChatCompletionMessage(content="I'm sorry, I'm unable to help with that. Is there something else you need assistance with?", refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content="**My Analysis of this Query**\n\nOkay, here's what I'm thinking. The input I've received looks a bit off, with that `{{prompt}}2` in there. It's not the usual structure, and I don't see any obvious way to process it using my available tools. It's like the user started a request but didn't finish it, or perhaps there's a formatting issue. It's definitely not something I can just run with.  My programming tells me I need to be straightforward and helpful in situations like this. So, rather than making assumptions or guessing, I'll need to tell the user that I can't quite understand what they are trying to achieve with this particular input. I'll need to politely ask them to clarify or rephrase their request so I can be more effective. No tools would make sense here; I simply need to request more information.\n"))], created=1762923205, model='gemini-2.5-flash-lite', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=23, prompt_tokens=1011, total_tokens=1102, completion_tokens_details=None, prompt_tokens_details=None)) 
 [12:53:26] [Core] [DBUG] [runners.tool_loop_agent_runner:59]: Agent state transition: AgentState.RUNNING -> AgentState.DONE 
 [12:53:26] [Core] [DBUG] [pipeline.context_utils:86]: hook(OnLLMResponseEvent) -> thinking_filter - resp 
 [12:53:26] [Core] [DBUG] [result_decorate.stage:107]: hook(on_decorating_result) -> astrbot - decorate_result 
 [12:53:26] [Plug] [DBUG] [astrbot.main:1195]: Decorating result for event: <astrbot.core.platform.sources.webchat.webchat_event.WebChatMessageEvent object at 0x7e5f8c266da0> 
 [12:53:27] [Core] [INFO] [respond.stage:212]: AstrBot -> vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: I can help you set a reminder! What would you like to be reminded of, and when should I remind you?  
 [12:53:27] [Core] [DBUG] [respond.stage:221]: hook(on_after_message_sent) -> astrbot - after_llm_req 
 [12:53:27] [Core] [DBUG] [pipeline.scheduler:80]: pipeline 执行完毕。 
 [12:53:27] [Core] [DBUG] [method.llm_request:521]: WebChat 对话标题生成请求,清理后的文本: User: [User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}1 
 [12:53:28] [Core] [DBUG] [sources.openai_source:119]: completion: ChatCompletion(id='chatcmpl-1762923207', choices=[Choice(finish_reason='STOP', index=0, logprobs=None, message=ChatCompletionMessage(content="I'm sorry, I'm unable to help with that because your request is unclear. Could you please rephrase your request?", refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content='**Analyzing a Fuzzy Request**\n\nOkay, so I\'ve got this prompt, and it\'s kind of... wonky. It\'s got this `{{prompt}}3` thing in it.  My first thought is, "What the heck does that mean?" This isn\'t a well-formed request.  I need to figure out what the user is *actually* asking for here.  \n\nSince the goal is to *understand*, I won\'t jump the gun and start fiddling with any tools.  I need more information before I can even *think* about doing something.  My internal checklist is screaming for clarification.  I have to ask, "Hey, can you clarify what you mean by that `{{prompt}}3` part? What are you actually trying to achieve?"  Without that, I\'m completely in the dark.\n'))], created=1762923207, model='gemini-2.5-flash-lite', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=27, prompt_tokens=1011, total_tokens=1103, completion_tokens_details=None, prompt_tokens_details=None)) 
 [12:53:28] [Core] [DBUG] [runners.tool_loop_agent_runner:59]: Agent state transition: AgentState.RUNNING -> AgentState.DONE 
 [12:53:28] [Core] [DBUG] [pipeline.context_utils:86]: hook(OnLLMResponseEvent) -> thinking_filter - resp 
 [12:53:28] [Core] [DBUG] [result_decorate.stage:107]: hook(on_decorating_result) -> astrbot - decorate_result 
 [12:53:28] [Plug] [DBUG] [astrbot.main:1195]: Decorating result for event: <astrbot.core.platform.sources.webchat.webchat_event.WebChatMessageEvent object at 0x7e5f8d7c4790> 
 [12:53:29] [Core] [DBUG] [sources.openai_source:119]: completion: ChatCompletion(id='chatcmpl-1762923209', choices=[Choice(finish_reason='STOP', index=0, logprobs=None, message=ChatCompletionMessage(content='`<None>`', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content="**Ambiguous Input Requires No Summary**\n\nOkay, I've got this. The user wants a summary of a prompt, but the prompt is just `{{prompt}}1`.  That's...nothing!  It's like a placeholder.  Given the instructions, and especially that `<None>` fallback for insufficient input, my output has to be `<None>`.  That's the only reasonable choice here.\n"))], created=1762923209, model='gemini-2.5-flash-lite', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=3, prompt_tokens=154, total_tokens=381, completion_tokens_details=None, prompt_tokens_details=None)) 
 [12:53:29] [Core] [DBUG] [method.llm_request:533]: WebChat 对话标题生成响应: `<None>` 
 [12:53:29] [Core] [INFO] [respond.stage:212]: AstrBot -> vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: I'm sorry, I'm unable to help with that. Is there something else you need assistance with?  
 [12:53:29] [Core] [DBUG] [respond.stage:221]: hook(on_after_message_sent) -> astrbot - after_llm_req 
 [12:53:29] [Core] [DBUG] [pipeline.scheduler:80]: pipeline 执行完毕。 
 [12:53:29] [Core] [DBUG] [method.llm_request:521]: WebChat 对话标题生成请求,清理后的文本: User: [User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}2 
 [12:53:32] [Core] [DBUG] [sources.openai_source:119]: completion: ChatCompletion(id='chatcmpl-1762923212', choices=[Choice(finish_reason='STOP', index=0, logprobs=None, message=ChatCompletionMessage(content='`<None>`', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content='**Processing a Brief, Unclear Query**\n\nOkay, so I\'m presented with a task. My "user" (though that\'s not relevant here) wants a summary of a prompt. The prompt itself is just `{{prompt}}2`.  That\'s...sparse. Really sparse. Basically, it\'s not a query at all, more like a variable or reference. My instructions are to summarize it in under ten words, and output something concise. But there\'s no way to summarize this meaningfully; there\'s no *there* there. Given this lack of substance, I have to assume the special case applies. I\'ll output `<None>`.\n'))], created=1762923212, model='gemini-2.5-flash-lite', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=3, prompt_tokens=154, total_tokens=407, completion_tokens_details=None, prompt_tokens_details=None)) 
 [12:53:32] [Core] [DBUG] [method.llm_request:533]: WebChat 对话标题生成响应: `<None>` 
 [12:53:33] [Core] [INFO] [respond.stage:212]: AstrBot -> vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: I'm sorry, I'm unable to help with that because your request is unclear. Could you please rephrase your request?  
 [12:53:33] [Core] [DBUG] [respond.stage:221]: hook(on_after_message_sent) -> astrbot - after_llm_req 
 [12:53:33] [Core] [DBUG] [pipeline.scheduler:80]: pipeline 执行完毕。 
 [12:53:33] [Core] [DBUG] [method.llm_request:521]: WebChat 对话标题生成请求,清理后的文本: User: [User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}3 
 [12:53:34] [Core] [DBUG] [sources.openai_source:119]: completion: ChatCompletion(id='chatcmpl-1762923214', choices=[Choice(finish_reason='STOP', index=0, logprobs=None, message=ChatCompletionMessage(content='<None>', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content="**Incomplete Query Detected**\n\nI see a request for a summary, but the prompt itself is too short and unclear. I'll output `<None>`.\n"))], created=1762923214, model='gemini-2.5-flash-lite', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=3, prompt_tokens=154, total_tokens=307, completion_tokens_details=None, prompt_tokens_details=None)) 
 [12:53:34] [Core] [DBUG] [method.llm_request:533]: WebChat 对话标题生成响应: <None> 
 [12:53:46] [Core] [DBUG] [webchat.webchat_adapter:127]: WebChatAdapter: [Plain(type=<ComponentType.Plain: 'Plain'>, text='history', convert=True)] 
 [12:53:46] [Core] [INFO] [core.event_bus:52]: [default] [webchat(webchat)] vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: history  
 [12:53:46] [Core] [DBUG] [waking_check.stage:122]: enabled_plugins_name: ['*'] 
 [12:53:46] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_session_control_agent 
 [12:53:46] [Core] [DBUG] [method.star_request:40]: plugin -> session_controller - handle_empty_mention 
 [12:53:46] [Core] [DBUG] [method.star_request:40]: plugin -> astrbot - his 
 [12:53:46] [Core] [DBUG] [result_decorate.stage:107]: hook(on_decorating_result) -> astrbot - decorate_result 
 [12:53:46] [Plug] [DBUG] [astrbot.main:1195]: Decorating result for event: <astrbot.core.platform.sources.webchat.webchat_event.WebChatMessageEvent object at 0x7e5f8d7c5270> 
 [12:53:49] [Core] [INFO] [respond.stage:212]: AstrBot -> vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu/vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu: 当前对话历史记录:User: 
[User ID: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu, Nickname: vnIXu5Ea159ov4DB80P15mzgcdaFB9jUSdwuIrRMhJwX3NkOGu]
{{prompt}}3
Assistant: I'm sorry, I'm unable to help with that because your request is unclear. Could you please rephrase your request?


第 1 页 | 共 1 页
*输入 /history 2 跳转到第 2 页  
 [12:53:49] [Core] [DBUG] [respond.stage:221]: hook(on_after_message_sent) -> astrbot - after_llm_req 
 [12:53:49] [Core] [DBUG] [pipeline.scheduler:80]: pipeline 执行完毕。 

你愿意提交 PR 吗?

  • [x] 是的,我愿意提交 PR!

Code of Conduct

  • [x] 我已阅读并同意遵守该项目的 行为准则。

nuomicici avatar Nov 12 '25 05:11 nuomicici

3.5.26也同样出现了这样的问题

nuomicici avatar Nov 12 '25 05:11 nuomicici

确认问题存在。 待排查。

Dt8333 avatar Nov 12 '25 10:11 Dt8333

确认问题在LLMRequestSubStage中。

在请求LLM后将信息储存到conv_manager时,目前的实现方式是将整个对话链加上最新用户和LLM信息后整体更新于数据库。 这会导致在一个对话请求结束前,后续发起的对话缺失先前未完成对话的上下文。 更新时后面缺失上下文的对话数据会整体覆盖先前的对话数据,导致该上下文彻底丢失。

也许需要一个appendConversation或者类似的实现来避免直接覆盖对话数据? 但是这样也没法解决乱序和高并发丢信息的问题……

又或者……每个会话里加个队列,每次每会话只处理一个信息? @Soulter

Dt8333 avatar Nov 12 '25 11:11 Dt8333

确认问题在LLMRequestSubStage中。

在请求LLM后将信息储存到conv_manager时,目前的实现方式是将整个对话链加上最新用户和LLM信息后整体更新于数据库。 这会导致在一个对话请求结束前,后续发起的对话缺失先前未完成对话的上下文。 更新时后面缺失上下文的对话数据会整体覆盖先前的对话数据,导致该上下文彻底丢失。

也许需要一个appendConversation或者类似的实现来避免直接覆盖对话数据? 但是这样也没法解决乱序和高并发丢信息的问题……

又或者……每个会话里加个队列,每次每会话只处理一个信息? @Soulter

https://github.com/AstrBotDevs/AstrBot/pull/2775 试图通过会话级锁解决这个问题,不过当时在研究是否有死锁的风险。

Soulter avatar Nov 12 '25 11:11 Soulter