From 52d8161b0ef0a1c087081c76f728884d6c466fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Wed, 4 Mar 2026 14:08:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A1=AE=E4=BF=9D=20max=5Fle?= =?UTF-8?q?ngth=20=E6=B0=B8=E8=BF=9C=E4=B8=8D=E4=BC=9A=E6=98=AF=20None?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/deep_assistant.py | 2 +- agent/tool_output_length_middleware.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/deep_assistant.py b/agent/deep_assistant.py index 7933792..f8183aa 100644 --- a/agent/deep_assistant.py +++ b/agent/deep_assistant.py @@ -220,7 +220,7 @@ async def init_agent(config: AgentConfig): middleware.append(ToolUseCleanupMiddleware()) # 添加工具输出长度控制中间件 tool_output_middleware = ToolOutputLengthMiddleware( - max_length=getattr(config.generate_cfg, 'tool_output_max_length', None) if config.generate_cfg else None or TOOL_OUTPUT_MAX_LENGTH, + max_length=(getattr(config.generate_cfg, 'tool_output_max_length', None) if config.generate_cfg else None) or TOOL_OUTPUT_MAX_LENGTH, truncation_strategy=getattr(config.generate_cfg, 'tool_output_truncation_strategy', 'smart') if config.generate_cfg else 'smart', tool_filters=getattr(config.generate_cfg, 'tool_output_filters', None) if config.generate_cfg else None, exclude_tools=getattr(config.generate_cfg, 'tool_output_exclude', []) if config.generate_cfg else [], diff --git a/agent/tool_output_length_middleware.py b/agent/tool_output_length_middleware.py index 96b6c1e..18fc3b6 100644 --- a/agent/tool_output_length_middleware.py +++ b/agent/tool_output_length_middleware.py @@ -53,7 +53,7 @@ class ToolOutputLengthMiddleware(AgentMiddleware): preserve_json: Whether to preserve JSON structure in smart mode ellipsis: Text to append when truncating """ - self.max_length = max_length + self.max_length = max_length if max_length is not None else 2000 # 确保 max_length 不为 None self.truncation_strategy = truncation_strategy self.tool_filters = tool_filters self.exclude_tools = exclude_tools or []