diff --git a/src/main.rs b/src/main.rs index ddf5dd089..d5b6613e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -188,8 +188,8 @@ Examples: model: Option, /// Temperature (0.0 - 2.0) - #[arg(short, long, default_value = "0.7", value_parser = parse_temperature)] - temperature: f64, + #[arg(short, long, value_parser = parse_temperature)] + temperature: Option, /// Attach a peripheral (board:path, e.g. nucleo-f401re:/dev/ttyACM0) #[arg(long)] @@ -775,17 +775,25 @@ async fn main() -> Result<()> { model, temperature, peripheral, - } => agent::run( - config, - message, - provider, - model, - temperature, - peripheral, - true, - ) - .await - .map(|_| ()), + } => { + // Implement temperature fallback logic: + // 1. Use --temperature if provided + // 2. Use config.default_temperature if --temperature not provided + // 3. Use hardcoded 0.7 if config.default_temperature not set (though config always has default) + let final_temperature = temperature.unwrap_or(config.default_temperature); + + agent::run( + config, + message, + provider, + model, + final_temperature, + peripheral, + true, + ) + .await + .map(|_| ()) + } Commands::Gateway { port, host } => { let port = port.unwrap_or(config.gateway.port); @@ -1974,4 +1982,30 @@ mod tests { other => panic!("expected estop resume command, got {other:?}"), } } + + #[test] + fn agent_command_parses_with_temperature() { + let cli = Cli::try_parse_from(["zeroclaw", "agent", "--temperature", "0.5"]) + .expect("agent command with temperature should parse"); + + match cli.command { + Commands::Agent { temperature, .. } => { + assert_eq!(temperature, Some(0.5)); + } + other => panic!("expected agent command, got {other:?}"), + } + } + + #[test] + fn agent_command_parses_without_temperature() { + let cli = Cli::try_parse_from(["zeroclaw", "agent", "--message", "hello"]) + .expect("agent command without temperature should parse"); + + match cli.command { + Commands::Agent { temperature, .. } => { + assert_eq!(temperature, None); + } + other => panic!("expected agent command, got {other:?}"), + } + } }