From 4e97ffacd69edbb852b200c2912a4396ad5cffe8 Mon Sep 17 00:00:00 2001 From: Chaitanya Rahalkar Date: Wed, 18 Jun 2025 14:23:12 -0500 Subject: [PATCH] feat(cli): Add `--quiet /-q` flag to goose run (#2939) --- crates/goose-cli/src/cli.rs | 14 +++++++++++++- crates/goose-cli/src/commands/bench.rs | 1 + crates/goose-cli/src/session/builder.rs | 22 +++++++++++++++------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/crates/goose-cli/src/cli.rs b/crates/goose-cli/src/cli.rs index 83333626..047f7b15 100644 --- a/crates/goose-cli/src/cli.rs +++ b/crates/goose-cli/src/cli.rs @@ -491,6 +491,14 @@ enum Command { value_delimiter = ',' )] builtins: Vec, + + /// Quiet mode - suppress non-response output + #[arg( + short = 'q', + long = "quiet", + help = "Quiet mode. Suppress non-response output, printing only the model response to stdout" + )] + quiet: bool, }, /// Recipe utilities for validation and deeplinking @@ -644,7 +652,8 @@ pub async fn cli() -> Result<()> { settings: None, debug, max_tool_repetitions, - interactive: true, // Session command is always interactive + interactive: true, + quiet: false, }) .await; setup_logging( @@ -688,6 +697,7 @@ pub async fn cli() -> Result<()> { builtins, params, explain, + quiet, }) => { let (input_config, session_settings) = match (instructions, input_text, recipe, explain) { @@ -773,6 +783,7 @@ pub async fn cli() -> Result<()> { debug, max_tool_repetitions, interactive, // Use the interactive flag from the Run command + quiet, }) .await; @@ -889,6 +900,7 @@ pub async fn cli() -> Result<()> { debug: false, max_tool_repetitions: None, interactive: true, // Default case is always interactive + quiet: false, }) .await; setup_logging( diff --git a/crates/goose-cli/src/commands/bench.rs b/crates/goose-cli/src/commands/bench.rs index 01cbd6a0..093ca3a9 100644 --- a/crates/goose-cli/src/commands/bench.rs +++ b/crates/goose-cli/src/commands/bench.rs @@ -44,6 +44,7 @@ pub async fn agent_generator( debug: false, max_tool_repetitions: None, interactive: false, // Benchmarking is non-interactive + quiet: false, }) .await; diff --git a/crates/goose-cli/src/session/builder.rs b/crates/goose-cli/src/session/builder.rs index 9a1eb880..2140a6dc 100644 --- a/crates/goose-cli/src/session/builder.rs +++ b/crates/goose-cli/src/session/builder.rs @@ -42,6 +42,8 @@ pub struct SessionBuilderConfig { pub max_tool_repetitions: Option, /// Whether this session will be used interactively (affects debugging prompts) pub interactive: bool, + /// Quiet mode - suppress non-response output + pub quiet: bool, } /// Offers to help debug an extension failure by creating a minimal debugging session @@ -457,13 +459,16 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session { session.agent.override_system_prompt(override_prompt).await; } - output::display_session_info( - session_config.resume, - &provider_name, - &model_name, - &session_file, - Some(&provider_for_display), - ); + // Display session information unless in quiet mode + if !session_config.quiet { + output::display_session_info( + session_config.resume, + &provider_name, + &model_name, + &session_file, + Some(&provider_for_display), + ); + } session } @@ -486,6 +491,7 @@ mod tests { debug: true, max_tool_repetitions: Some(5), interactive: true, + quiet: false, }; assert_eq!(config.extensions.len(), 1); @@ -494,6 +500,7 @@ mod tests { assert!(config.debug); assert_eq!(config.max_tool_repetitions, Some(5)); assert!(config.interactive); + assert!(!config.quiet); } #[test] @@ -511,6 +518,7 @@ mod tests { assert!(!config.debug); assert!(config.max_tool_repetitions.is_none()); assert!(!config.interactive); + assert!(!config.quiet); } #[tokio::test]