add configurability for a tool_params_max_length (#2448)

Co-authored-by: Yingjie He <yingjiehe@squareup.com>
This commit is contained in:
Raduan Al-Shedivat
2025-05-21 19:03:46 +02:00
committed by GitHub
parent 9a7abfec9e
commit 302ac81990
2 changed files with 11 additions and 3 deletions
+9 -3
View File
@@ -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::<usize>("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,