From 2b6b31a013cf416425fd1c9b99bbd442a251845b Mon Sep 17 00:00:00 2001 From: PeiPei233 <49641967+PeiPei233@users.noreply.github.com> Date: Sun, 27 Sep 2026 10:52:32 +0800 Subject: [PATCH] fix: refresh queued conversation history under the session lock (#10238) * fix: refresh queued conversation history under the session lock * style: format queued conversation history refresh * Delete tests/unit/test_queued_conversation_history.py --------- Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com> --- astrbot/core/astr_main_agent.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/astrbot/core/astr_main_agent.py b/astrbot/core/astr_main_agent.py index c8c4621dc..9374e973a 100644 --- a/astrbot/core/astr_main_agent.py +++ b/astrbot/core/astr_main_agent.py @@ -1440,7 +1440,22 @@ async def collect_initial_request( list(req.contexts) if isinstance(req.contexts, list) else req.contexts ) if req.conversation: - req.contexts = json.loads(req.conversation.history) + # Handler requests can be prepared before the pipeline acquires + # the session lock. Reload the bound conversation here so queued + # turns include replies saved while they were waiting. + conversation = ( + await plugin_context.conversation_manager.get_conversation( + event.unified_msg_origin, req.conversation.cid + ) + ) + if conversation is None: + _set_llm_error_message( + event, + "The requested conversation no longer exists. Please send a new message.", + ) + return None, None + req.conversation = conversation + req.contexts = json.loads(conversation.history) else: req = ProviderRequest() req.prompt = ""