{"record":{"id":"080ba6191d8ab0d3","repo":"zeroclaw-labs/zeroclaw","slug":"grok-cli-model-provider-received-a-non-finite-temp","errorCode":null,"errorMessage":"Grok CLI model provider received a non-finite temperature value","messagePattern":"Grok CLI model provider received a non-finite temperature value","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-providers/src/grok_cli.rs","lineNumber":652,"sourceCode":"            index += 1;\n        }\n        policy\n    }\n\n    fn should_forward_model(model: &str) -> bool {\n        let trimmed = model.trim();\n        !trimmed.is_empty() && trimmed != DEFAULT_MODEL_MARKER\n    }\n\n    fn supports_temperature(temperature: f64) -> bool {\n        GROK_CLI_SUPPORTED_TEMPERATURES\n            .iter()\n            .any(|value| (temperature - value).abs() < TEMP_EPSILON)\n    }\n\n    fn validate_temperature(temperature: f64) -> anyhow::Result<()> {\n        if !temperature.is_finite() {\n            anyhow::bail!(\"Grok CLI model provider received a non-finite temperature value\");\n        }\n        if !Self::supports_temperature(temperature) {\n            anyhow::bail!(\n                \"temperature unsupported by Grok CLI model provider: {temperature}. \\\n                 Supported values: 0.7 or 1.0 (not forwarded; CLI has no sampling flag)\"\n            );\n        }\n        Ok(())\n    }\n\n    /// Build the documented ACP invocation. Permission and tool overrides are\n    /// accepted only through explicit per-alias `extra_args`.\n    fn build_cli_args(model: &str, extra_args: &[String]) -> Vec<String> {\n        let mut args = Vec::with_capacity(16 + extra_args.len());\n        args.push(\"--no-auto-update\".to_string());\n        args.push(\"--no-plan\".to_string());\n\n        if !Self::extra_args_set_any(extra_args, &[\"--sandbox\"]) {","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-providers/src/grok_cli.rs#L634-L670","documentation":"validate_temperature rejects NaN and infinite temperatures before the Grok CLI process is started. The CLI has no sampling flag, so temperature is never forwarded; the check exists to catch garbage input early. Non-finite values typically enter through config deserialization (TOML/JSON accept `nan`/`inf` literals) or upstream arithmetic such as 0/0 or overflow in code that computes the value.","triggerScenarios":"A chat call on a grok_cli provider with temperature = NaN or +/-inf: `temperature = nan` in a config file, a computed `Some(x / count)` where count == 0, or lenient f64 parsing of the string \"NaN\".","commonSituations":"Agent profiles with hand-edited temperature fields; normalization or decay math upstream that divides by zero without guarding; JSON payloads where a missing value was coerced to NaN.","solutions":["Guard the producer: check `is_finite()` on any computed temperature before passing it to chat","Fix or delete the `temperature` entry in the agent/config file (deleting the key uses the provider default)","Pass Some(0.7) or Some(1.0) explicitly — the only supported values for grok_cli"],"exampleFix":"// before\nlet temp = normalize(score) / count; // NaN when count == 0\nprovider.chat(req, model, Some(temp)).await?;\n\n// after\nlet temp = if temp.is_finite() { temp } else { 0.7 };\nprovider.chat(req, model, Some(temp)).await?;","handlingStrategy":"validation","validationCode":"fn temperature_safe(t: Option<f64>) -> bool {\n    t.map(f64::is_finite).unwrap_or(true)\n}","typeGuard":"fn is_finite_temperature(t: f64) -> bool { t.is_finite() }","tryCatchPattern":"let temp = computed.filter(|t| t.is_finite());\nif let Err(e) = provider.chat(req, model, temp).await {\n    if e.to_string().contains(\"non-finite temperature\") {\n        // producer bug: audit upstream math instead of retrying\n    }\n}","preventionTips":["Guard every division/normalization that feeds temperature with is_finite()","Reject `nan`/`inf` literals at config load time","Treat non-finite temperature as a producer bug, never a retryable error"],"tags":["grok-cli","temperature","nan","infinity","validation"],"backgroundTag":"nan-parameter-value","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}