From b4e3b7243bc16343a87fe1902bdf75d141d4c10b Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Sat, 21 Mar 2026 04:25:12 +0800 Subject: [PATCH] Update tool_loop_agent_runner.py --- astrbot/core/agent/runners/tool_loop_agent_runner.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/astrbot/core/agent/runners/tool_loop_agent_runner.py b/astrbot/core/agent/runners/tool_loop_agent_runner.py index 93f45475e5..ba4f7908a5 100644 --- a/astrbot/core/agent/runners/tool_loop_agent_runner.py +++ b/astrbot/core/agent/runners/tool_loop_agent_runner.py @@ -139,9 +139,9 @@ async def reset( # TODO: 2. after LLM output a tool call self.context_config = ContextConfig( # <=0 will never do compress - max_context_tokens=provider.provider_config.get("max_context_tokens", 0), + max_context_tokens=provider.provider_config.get("max_context_tokens", 4096), # enforce max turns before compression - enforce_max_turns=self.enforce_max_turns, + enforce_max_turns=self.enforce_max_turns if self.enforce_max_turns != -1 else 15, truncate_turns=self.truncate_turns, llm_compress_instruction=self.llm_compress_instruction, llm_compress_keep_recent=self.llm_compress_keep_recent, @@ -606,6 +606,8 @@ async def step_until_done( ) -> T.AsyncGenerator[AgentResponse, None]: """Process steps until the agent is done.""" step_count = 0 + # TODO:将max_step由30改为一个较小的值 + max_step = min(max_step, 3) while not self.done() and step_count < max_step: step_count += 1 async for resp in self.step():