fix(agent): honor configured default temperature (#3167)
This commit is contained in:
parent
5c432daba4
commit
cfb2d548be
@ -1808,7 +1808,7 @@ pub async fn run(
|
||||
message: Option<String>,
|
||||
provider_override: Option<String>,
|
||||
model_override: Option<String>,
|
||||
temperature: f64,
|
||||
temperature: Option<f64>,
|
||||
peripheral_overrides: Vec<String>,
|
||||
interactive: bool,
|
||||
) -> Result<String> {
|
||||
@ -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,
|
||||
|
||||
@ -173,7 +173,7 @@ async fn run_agent_job(
|
||||
Some(prefixed_prompt),
|
||||
None,
|
||||
model_override,
|
||||
config.default_temperature,
|
||||
Some(config.default_temperature),
|
||||
vec![],
|
||||
false,
|
||||
)
|
||||
|
||||
@ -272,7 +272,7 @@ async fn run_heartbeat_worker(config: Config) -> Result<()> {
|
||||
Some(prompt),
|
||||
None,
|
||||
None,
|
||||
temp,
|
||||
Some(temp),
|
||||
vec![],
|
||||
false,
|
||||
)
|
||||
|
||||
42
src/main.rs
42
src/main.rs
@ -195,8 +195,8 @@ Examples:
|
||||
model: Option<String>,
|
||||
|
||||
/// 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<f64>,
|
||||
|
||||
/// 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"])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user