diff --git a/astrbot/core/pipeline/process_stage/method/llm_request.py b/astrbot/core/pipeline/process_stage/method/llm_request.py index c6a87b37c..35e9f5f50 100644 --- a/astrbot/core/pipeline/process_stage/method/llm_request.py +++ b/astrbot/core/pipeline/process_stage/method/llm_request.py @@ -38,6 +38,9 @@ class LLMRequestSubStage(Stage): self.max_context_length = ctx.astrbot_config["provider_settings"][ "max_context_length" ] # int + self.dequeue_context_length = ctx.astrbot_config["provider_settings"][ + "dequeue_context_length" + ] # int self.streaming_response = ctx.astrbot_config["provider_settings"][ "streaming_response" ] # bool @@ -135,7 +138,7 @@ class LLMRequestSubStage(Stage): and len(req.contexts) // 2 > self.max_context_length ): logger.debug("上下文长度超过限制,将截断。") - req.contexts = req.contexts[-self.max_context_length * 2 :] + req.contexts = req.contexts[-(self.max_context_length - self.dequeue_context_length) * 2 :] # session_id if not req.session_id: