Marcelle/verbose tool output (#1230)

This commit is contained in:
marcelle
2025-02-13 21:12:39 -05:00
committed by GitHub
parent 07b89c80ef
commit 8bc43f4219
2 changed files with 39 additions and 3 deletions

View File

@@ -150,12 +150,18 @@ pub async fn handle_configure() -> Result<(), Box<dyn Error>> {
"Enable or disable connected extensions", "Enable or disable connected extensions",
) )
.item("remove", "Remove Extension", "Remove an extension") .item("remove", "Remove Extension", "Remove an extension")
.item(
"tool_output",
"Adjust Tool Output",
"Show more or less tool output",
)
.interact()?; .interact()?;
match action { match action {
"toggle" => toggle_extensions_dialog(), "toggle" => toggle_extensions_dialog(),
"add" => configure_extensions_dialog(), "add" => configure_extensions_dialog(),
"remove" => remove_extension_dialog(), "remove" => remove_extension_dialog(),
"tool_output" => configure_tool_output_dialog(),
"providers" => configure_provider_dialog().await.and(Ok(())), "providers" => configure_provider_dialog().await.and(Ok(())),
_ => unreachable!(), _ => unreachable!(),
} }
@@ -614,3 +620,30 @@ pub fn remove_extension_dialog() -> Result<(), Box<dyn Error>> {
Ok(()) Ok(())
} }
pub fn configure_tool_output_dialog() -> Result<(), Box<dyn Error>> {
let config = Config::global();
let tool_log_level = cliclack::select("Which tool output would you like to show?")
.item("high", "High Importance", "")
.item("medium", "Medium Importance", "Ex. results of file-writes")
.item("all", "All", "Ex. shell command output")
.interact()?;
match tool_log_level {
"high" => {
config.set("GOOSE_CLI_MIN_PRIORITY", Value::from(0.8))?;
cliclack::outro("Showing tool output of high importance only.")?;
}
"med" => {
config.set("GOOSE_CLI_MIN_PRIORITY", Value::from(0.2))?;
cliclack::outro("Showing tool output of medium importance.")?;
}
"all" => {
config.set("GOOSE_CLI_MIN_PRIORITY", Value::from(0.0))?;
cliclack::outro("Showing all tool output.")?;
}
_ => unreachable!(),
};
Ok(())
}

View File

@@ -1,5 +1,6 @@
use bat::WrappingMode; use bat::WrappingMode;
use console::style; use console::style;
use goose::config::Config;
use goose::message::{Message, MessageContent, ToolRequest, ToolResponse}; use goose::message::{Message, MessageContent, ToolRequest, ToolResponse};
use mcp_core::tool::ToolCall; use mcp_core::tool::ToolCall;
use serde_json::Value; use serde_json::Value;
@@ -113,6 +114,8 @@ fn render_tool_request(req: &ToolRequest, theme: Theme) {
} }
fn render_tool_response(resp: &ToolResponse, theme: Theme) { fn render_tool_response(resp: &ToolResponse, theme: Theme) {
let config = Config::global();
match &resp.tool_result { match &resp.tool_result {
Ok(contents) => { Ok(contents) => {
for content in contents { for content in contents {
@@ -122,14 +125,14 @@ fn render_tool_response(resp: &ToolResponse, theme: Theme) {
} }
} }
let min_priority = std::env::var("GOOSE_CLI_MIN_PRIORITY") let min_priority = config
.get::<f32>("GOOSE_CLI_MIN_PRIORITY")
.ok() .ok()
.and_then(|val| val.parse::<f32>().ok())
.unwrap_or(0.0); .unwrap_or(0.0);
if content if content
.priority() .priority()
.is_some_and(|priority| priority <= min_priority) .is_some_and(|priority| priority < min_priority)
|| content.priority().is_none() || content.priority().is_none()
{ {
continue; continue;