From 302ac81990a6e9a8dbdd469f21ffbc7ae8f57d9d Mon Sep 17 00:00:00 2001 From: Raduan Al-Shedivat <88370223+dbraduan@users.noreply.github.com> Date: Wed, 21 May 2025 19:03:46 +0200 Subject: [PATCH] add configurability for a tool_params_max_length (#2448) Co-authored-by: Yingjie He --- crates/goose-cli/src/session/output.rs | 12 +++++++++--- documentation/docs/guides/environment-variables.md | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/goose-cli/src/session/output.rs b/crates/goose-cli/src/session/output.rs index a3f7f9c939..873eec017d 100644 --- a/crates/goose-cli/src/session/output.rs +++ b/crates/goose-cli/src/session/output.rs @@ -405,9 +405,15 @@ fn print_markdown(content: &str, theme: Theme) { .unwrap(); } -const MAX_STRING_LENGTH: usize = 40; const INDENT: &str = " "; +fn get_tool_params_max_length() -> usize { + Config::global() + .get_param::("GOOSE_CLI_TOOL_PARAMS_TRUNCATION_MAX_LENGTH") + .ok() + .unwrap_or(40) +} + fn print_params(value: &Value, depth: usize, debug: bool) { let indent = INDENT.repeat(depth); @@ -427,7 +433,7 @@ fn print_params(value: &Value, depth: usize, debug: bool) { } } Value::String(s) => { - if !debug && s.len() > MAX_STRING_LENGTH { + if !debug && s.len() > get_tool_params_max_length() { println!("{}{}: {}", indent, style(key).dim(), style("...").dim()); } else { println!("{}{}: {}", indent, style(key).dim(), style(s).green()); @@ -452,7 +458,7 @@ fn print_params(value: &Value, depth: usize, debug: bool) { } } Value::String(s) => { - if !debug && s.len() > MAX_STRING_LENGTH { + if !debug && s.len() > get_tool_params_max_length() { println!( "{}{}", indent, diff --git a/documentation/docs/guides/environment-variables.md b/documentation/docs/guides/environment-variables.md index ca9b4c0daf..7888b813ba 100644 --- a/documentation/docs/guides/environment-variables.md +++ b/documentation/docs/guides/environment-variables.md @@ -72,6 +72,7 @@ These variables control how Goose handles [tool permissions](/docs/guides/tool-p | `GOOSE_TOOLSHIM` | Enables/disables tool call interpretation | "1", "true" (case insensitive) to enable | false | | `GOOSE_TOOLSHIM_OLLAMA_MODEL` | Specifies the model for [tool call interpretation](/docs/guides/experimental-features/#ollama-tool-shim) | Model name (e.g. llama3.2, qwen2.5) | System default | | `GOOSE_CLI_MIN_PRIORITY` | Controls verbosity of [tool output](/docs/guides/adjust-tool-output) | Float between 0.0 and 1.0 | 0.0 | +| `GOOSE_CLI_TOOL_PARAMS_TRUNCATION_MAX_LENGTH` | Maximum length for tool parameter values before truncation in CLI output (not in debug mode) | Integer | 40 | **Examples** @@ -81,6 +82,7 @@ export GOOSE_TOOLSHIM=true export GOOSE_TOOLSHIM_OLLAMA_MODEL=llama3.2 export GOOSE_MODE="auto" export GOOSE_CLI_MIN_PRIORITY=0.2 # Show only medium and high importance output +export GOOSE_CLI_TOOL_PARAMS_MAX_LENGTH=100 # Show up to 100 characters for tool parameters in CLI output ``` ## Security Configuration