Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add goose configure flow for adjusting amt of tool output shown #1048

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions crates/goose-cli/src/commands/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,17 @@ pub async fn handle_configure() -> Result<(), Box<dyn Error>> {
"Enable or disable connected extensions",
)
.item("add", "Add Extension", "Connect to a new extension")
.item(
"tool_output",
"Adjust Tool Output",
"Show more or less tool output",
)
.interact()?;

match action {
"toggle" => toggle_extensions_dialog(),
"add" => configure_extensions_dialog(),
"tool_output" => configure_tool_output_dialog(),
"providers" => configure_provider_dialog().await.and(Ok(())),
_ => unreachable!(),
}
Expand Down Expand Up @@ -545,3 +551,30 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {

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(())
}
11 changes: 6 additions & 5 deletions crates/goose-cli/src/prompt/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use std::collections::HashMap;
use std::io::{self, Write};
use std::path::PathBuf;

use super::Theme;
use bat::WrappingMode;
use console::style;
use goose::config::Config;
use goose::message::{Message, MessageContent, ToolRequest, ToolResponse};
use mcp_core::role::Role;
use mcp_core::{content::Content, tool::ToolCall};
use serde_json::Value;

use super::Theme;

const MAX_STRING_LENGTH: usize = 40;
const MAX_PATH_LENGTH: usize = 60;
const INDENT: &str = " ";
Expand Down Expand Up @@ -267,6 +267,7 @@ pub fn render(message: &Message, theme: &Theme, renderers: HashMap<String, Box<d
}

pub fn default_response_renderer(tool_response: &ToolResponse, theme: &str) {
let config = Config::global();
match &tool_response.tool_result {
Ok(contents) => {
for content in contents {
Expand All @@ -277,15 +278,15 @@ pub fn default_response_renderer(tool_response: &ToolResponse, theme: &str) {
continue;
}

let min_priority = std::env::var("GOOSE_CLI_MIN_PRIORITY")
let min_priority = config
.get::<f32>("GOOSE_CLI_MIN_PRIORITY")
.ok()
.and_then(|val| val.parse::<f32>().ok())
.unwrap_or(0.0);

// if priority is not set OR less than or equal to min_priority, do not render
if content
.priority()
.is_some_and(|priority| priority <= min_priority)
.is_some_and(|priority| priority < min_priority)
|| content.priority().is_none()
{
continue;
Expand Down
Loading