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
7 changes: 6 additions & 1 deletion crates/goose-cli/src/commands/agent_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ impl AgentCommand {

let versions = AgentFactory::available_versions();
let default_version = AgentFactory::default_version();
let configured_version = AgentFactory::configured_version();

for version in versions {
if version == default_version {
if version == default_version && version == configured_version {
writeln!(output, "* {} (default)", version)?;
} else if version == default_version {
writeln!(output, " {} (default)", version)?;
} else if version == configured_version {
writeln!(output, "* {}", version)?;
} else {
writeln!(output, " {}", version)?;
}
Expand Down
8 changes: 2 additions & 6 deletions crates/goose-cli/src/session/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ pub async fn build_session(
goose::providers::create(&provider_name, model_config).expect("Failed to create provider");

// Create the agent
let agent_version: Option<String> = config.get("GOOSE_AGENT").ok();
let mut agent = match agent_version {
Some(version) => AgentFactory::create(&version, provider),
None => AgentFactory::create(AgentFactory::default_version(), provider),
}
.expect("Failed to create agent");
let mut agent = AgentFactory::create(&AgentFactory::configured_version(), provider)
.expect("Failed to create agent");

// Setup extensions for the agent
for extension in ExtensionManager::get_all().expect("should load extensions") {
Expand Down
8 changes: 8 additions & 0 deletions crates/goose/src/agents/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::sync::{OnceLock, RwLock};

pub use super::Agent;
use crate::config::Config;
use crate::providers::base::Provider;

type AgentConstructor = Box<dyn Fn(Box<dyn Provider>) -> Box<dyn Agent> + Send + Sync>;
Expand Down Expand Up @@ -46,6 +47,13 @@ impl AgentFactory {
.unwrap_or_default()
}

pub fn configured_version() -> String {
let config = Config::global();
config
.get::<String>("GOOSE_AGENT")
.unwrap_or_else(|_| Self::default_version().to_string())
}

/// Get the default version name
pub fn default_version() -> &'static str {
"truncate"
Expand Down
1 change: 1 addition & 0 deletions crates/goose/src/agents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod extension;
mod factory;
mod permission_judge;
mod reference;
mod summarize;
mod truncate;

pub use agent::Agent;
Expand Down
Loading