feat: 调整工具结果和上下文摘要字符限制,优化性能

This commit is contained in:
ooodc 2026-04-25 16:09:19 +08:00
parent 6b7822048a
commit 3792472b83
3 changed files with 14 additions and 5 deletions

View File

@ -16,7 +16,10 @@
"agents": { "agents": {
"default": { "default": {
"provider": "default", "provider": "default",
"model": "default" "model": "default",
"tool_result_max_chars": 20000,
"context_summary_max_chars": 20000,
"context_tool_result_trim_chars": 2000
} }
}, },
"gateway": { "gateway": {

View File

@ -36,7 +36,7 @@ impl Default for ContextCompressionConfig {
protect_last_n: 4, protect_last_n: 4,
max_passes: 3, max_passes: 3,
summary_max_chars: 20_000, 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())); 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] #[test]
fn test_threshold() { fn test_threshold() {
let compressor = ContextCompressor::new(128_000); let compressor = ContextCompressor::new(128_000);

View File

@ -189,7 +189,7 @@ fn default_context_summary_max_chars() -> usize {
} }
fn default_context_tool_result_trim_chars() -> usize { fn default_context_tool_result_trim_chars() -> usize {
20_000 2_000
} }
fn default_llm_timeout_secs() -> u64 { fn default_llm_timeout_secs() -> u64 {
@ -733,7 +733,7 @@ mod tests {
assert_eq!(provider_config.llm_timeout_secs, 120); assert_eq!(provider_config.llm_timeout_secs, 120);
assert_eq!(provider_config.tool_result_max_chars, 20_000); 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_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] #[test]
@ -958,7 +958,7 @@ mod tests {
assert_eq!(config.agents["default"].max_tool_iterations, 100); 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"].tool_result_max_chars, 20_000);
assert_eq!(config.agents["default"].context_summary_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] #[test]