Skip to content
Merged
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
26 changes: 26 additions & 0 deletions crates/goose-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,24 @@ enum Command {
action = clap::ArgAction::Append
)]
additional_sub_recipes: Vec<String>,

/// Provider to use for this run (overrides environment variable)
#[arg(
long = "provider",
value_name = "PROVIDER",
help = "Specify the LLM provider to use (e.g., 'openai', 'anthropic')",
long_help = "Override the GOOSE_PROVIDER environment variable for this run. Available providers include openai, anthropic, ollama, databricks, gemini-cli, claude-code, and others."
)]
provider: Option<String>,

/// Model to use for this run (overrides environment variable)
#[arg(
long = "model",
value_name = "MODEL",
help = "Specify the model to use (e.g., 'gpt-4o', 'claude-3.5-sonnet')",
long_help = "Override the GOOSE_MODEL environment variable for this run. The model must be supported by the specified provider."
)]
model: Option<String>,
},

/// Recipe utilities for validation and deeplinking
Expand Down Expand Up @@ -700,6 +718,8 @@ pub async fn cli() -> Result<()> {
extensions_override: None,
additional_system_prompt: None,
settings: None,
provider: None,
model: None,
debug,
max_tool_repetitions,
max_turns,
Expand Down Expand Up @@ -761,6 +781,8 @@ pub async fn cli() -> Result<()> {
scheduled_job_id,
quiet,
additional_sub_recipes,
provider,
model,
}) => {
let (input_config, session_settings, sub_recipes, final_output_response) = match (
instructions,
Expand Down Expand Up @@ -845,6 +867,8 @@ pub async fn cli() -> Result<()> {
extensions_override: input_config.extensions_override,
additional_system_prompt: input_config.additional_system_prompt,
settings: session_settings,
provider,
model,
debug,
max_tool_repetitions,
max_turns,
Expand Down Expand Up @@ -970,6 +994,8 @@ pub async fn cli() -> Result<()> {
extensions_override: None,
additional_system_prompt: None,
settings: None::<SessionSettings>,
provider: None,
model: None,
debug: false,
max_tool_repetitions: None,
max_turns: None,
Expand Down
2 changes: 2 additions & 0 deletions crates/goose-cli/src/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub async fn agent_generator(
extensions_override: None,
additional_system_prompt: None,
settings: None,
provider: None,
model: None,
debug: false,
max_tool_repetitions: None,
interactive: false, // Benchmarking is non-interactive
Expand Down
26 changes: 20 additions & 6 deletions crates/goose-cli/src/session/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ pub struct SessionBuilderConfig {
pub additional_system_prompt: Option<String>,
/// Settings to override the global Goose settings
pub settings: Option<SessionSettings>,
/// Provider override from CLI arguments
pub provider: Option<String>,
/// Model override from CLI arguments
pub model: Option<String>,
/// Enable debug printing
pub debug: bool,
/// Maximum number of consecutive identical tool calls allowed
Expand Down Expand Up @@ -167,16 +171,24 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session {
let config = Config::global();

let provider_name = session_config
.settings
.as_ref()
.and_then(|s| s.goose_provider.clone())
.provider
.or_else(|| {
session_config
.settings
.as_ref()
.and_then(|s| s.goose_provider.clone())
})
.or_else(|| config.get_param("GOOSE_PROVIDER").ok())
.expect("No provider configured. Run 'goose configure' first");

let model_name = session_config
.settings
.as_ref()
.and_then(|s| s.goose_model.clone())
.model
.or_else(|| {
session_config
.settings
.as_ref()
.and_then(|s| s.goose_model.clone())
})
.or_else(|| config.get_param("GOOSE_MODEL").ok())
.expect("No model configured. Run 'goose configure' first");

Expand Down Expand Up @@ -523,6 +535,8 @@ mod tests {
extensions_override: None,
additional_system_prompt: Some("Test prompt".to_string()),
settings: None,
provider: None,
model: None,
debug: true,
max_tool_repetitions: Some(5),
max_turns: None,
Expand Down
Loading