From 3792472b83d839229322e245759555e9ce9415e9 Mon Sep 17 00:00:00 2001 From: ooodc <549496103@qq.com> Date: Sat, 25 Apr 2026 16:09:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=92=8C=E4=B8=8A=E4=B8=8B=E6=96=87=E6=91=98?= =?UTF-8?q?=E8=A6=81=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.json | 5 ++++- src/agent/context_compressor.rs | 8 +++++++- src/config/mod.rs | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/config.json b/config.json index 84df243..0f78f6f 100644 --- a/config.json +++ b/config.json @@ -16,7 +16,10 @@ "agents": { "default": { "provider": "default", - "model": "default" + "model": "default", + "tool_result_max_chars": 20000, + "context_summary_max_chars": 20000, + "context_tool_result_trim_chars": 2000 } }, "gateway": { diff --git a/src/agent/context_compressor.rs b/src/agent/context_compressor.rs index e0adb7f..77f6757 100644 --- a/src/agent/context_compressor.rs +++ b/src/agent/context_compressor.rs @@ -36,7 +36,7 @@ impl Default for ContextCompressionConfig { protect_last_n: 4, max_passes: 3, summary_max_chars: 20_000, - tool_result_trim_chars: 20_000, + tool_result_trim_chars: 2_000, } } } @@ -395,6 +395,12 @@ mod tests { assert!(messages[0].content.is_char_boundary(messages[0].content.len())); } + #[test] + fn test_default_tool_result_trim_chars() { + let config = ContextCompressionConfig::default(); + assert_eq!(config.tool_result_trim_chars, 2_000); + } + #[test] fn test_threshold() { let compressor = ContextCompressor::new(128_000); diff --git a/src/config/mod.rs b/src/config/mod.rs index f5612a7..fec8ca5 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -189,7 +189,7 @@ fn default_context_summary_max_chars() -> usize { } fn default_context_tool_result_trim_chars() -> usize { - 20_000 + 2_000 } fn default_llm_timeout_secs() -> u64 { @@ -733,7 +733,7 @@ mod tests { assert_eq!(provider_config.llm_timeout_secs, 120); assert_eq!(provider_config.tool_result_max_chars, 20_000); assert_eq!(provider_config.context_summary_max_chars, 20_000); - assert_eq!(provider_config.context_tool_result_trim_chars, 20_000); + assert_eq!(provider_config.context_tool_result_trim_chars, 2_000); } #[test] @@ -958,7 +958,7 @@ mod tests { assert_eq!(config.agents["default"].max_tool_iterations, 100); assert_eq!(config.agents["default"].tool_result_max_chars, 20_000); assert_eq!(config.agents["default"].context_summary_max_chars, 20_000); - assert_eq!(config.agents["default"].context_tool_result_trim_chars, 20_000); + assert_eq!(config.agents["default"].context_tool_result_trim_chars, 2_000); } #[test]