From cfb2d548be027526f45abdcf2c66776e7f7816e2 Mon Sep 17 00:00:00 2001 From: Argenis Date: Wed, 11 Mar 2026 18:41:06 -0400 Subject: [PATCH] fix(agent): honor configured default temperature (#3167) --- src/agent/loop_.rs | 3 ++- src/cron/scheduler.rs | 2 +- src/daemon/mod.rs | 2 +- src/main.rs | 42 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/agent/loop_.rs b/src/agent/loop_.rs index e3851de17..078fa2e8e 100644 --- a/src/agent/loop_.rs +++ b/src/agent/loop_.rs @@ -1808,7 +1808,7 @@ pub async fn run( message: Option, provider_override: Option, model_override: Option, - temperature: f64, + temperature: Option, peripheral_overrides: Vec, interactive: bool, ) -> Result { @@ -1881,6 +1881,7 @@ pub async fn run( .as_deref() .or(config.default_model.as_deref()) .unwrap_or("anthropic/claude-sonnet-4"); + let temperature = temperature.unwrap_or(config.default_temperature); let provider_runtime_options = providers::ProviderRuntimeOptions { auth_profile_override: None, diff --git a/src/cron/scheduler.rs b/src/cron/scheduler.rs index 26d09875f..e1516b1a9 100644 --- a/src/cron/scheduler.rs +++ b/src/cron/scheduler.rs @@ -173,7 +173,7 @@ async fn run_agent_job( Some(prefixed_prompt), None, model_override, - config.default_temperature, + Some(config.default_temperature), vec![], false, ) diff --git a/src/daemon/mod.rs b/src/daemon/mod.rs index 48793221a..89fe6541b 100644 --- a/src/daemon/mod.rs +++ b/src/daemon/mod.rs @@ -272,7 +272,7 @@ async fn run_heartbeat_worker(config: Config) -> Result<()> { Some(prompt), None, None, - temp, + Some(temp), vec![], false, ) diff --git a/src/main.rs b/src/main.rs index 9fb5a3f51..fb1cb39f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -195,8 +195,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)] @@ -2235,6 +2235,44 @@ mod tests { ); } + #[test] + fn agent_cli_does_not_force_temperature_override_when_flag_is_absent() { + let cli = Cli::try_parse_from(["zeroclaw", "agent", "--provider", "openrouter", "-m", "hi"]) + .expect("agent invocation should parse without temperature"); + + match cli.command { + Commands::Agent { temperature, .. } => { + assert_eq!( + temperature, None, + "temperature should stay unset so config.default_temperature is preserved" + ); + } + other => panic!("expected agent command, got {other:?}"), + } + } + + #[test] + fn agent_cli_parses_explicit_temperature_override() { + let cli = Cli::try_parse_from([ + "zeroclaw", + "agent", + "--provider", + "openrouter", + "-m", + "hi", + "--temperature", + "1.1", + ]) + .expect("agent invocation should parse explicit temperature"); + + match cli.command { + Commands::Agent { temperature, .. } => { + assert_eq!(temperature, Some(1.1)); + } + other => panic!("expected agent command, got {other:?}"), + } + } + #[test] fn gateway_cli_accepts_new_pairing_flag() { let cli = Cli::try_parse_from(["zeroclaw", "gateway", "--new-pairing"])