diff --git a/astrbot/core/pipeline/process_stage/method/llm_request.py b/astrbot/core/pipeline/process_stage/method/llm_request.py index d13a101ef..b49cd6581 100644 --- a/astrbot/core/pipeline/process_stage/method/llm_request.py +++ b/astrbot/core/pipeline/process_stage/method/llm_request.py @@ -77,14 +77,21 @@ class LLMRequestSubStage(Stage): conversation_id = await self.conv_manager.get_curr_conversation_id( event.unified_msg_origin ) + req.session_id = event.unified_msg_origin if not conversation_id: conversation_id = await self.conv_manager.new_conversation( event.unified_msg_origin ) - req.session_id = event.unified_msg_origin conversation = await self.conv_manager.get_conversation( event.unified_msg_origin, conversation_id ) + if not conversation: + conversation_id = await self.conv_manager.new_conversation( + event.unified_msg_origin + ) + conversation = await self.conv_manager.get_conversation( + event.unified_msg_origin, conversation_id + ) req.conversation = conversation req.contexts = json.loads(conversation.history)