zeroclaw-labs/zeroclaw · error · anyhow::Error

KiloCLI model_provider received non-finite temperature value

Error message

KiloCLI model_provider received non-finite temperature value

What it means

KiloCLI's validate_temperature rejects NaN and infinite temperatures before the `kilo` process is spawned. As with the other CLI wrappers, the CLI takes no sampling parameter, so the value is validated only to catch corrupt input early. Non-finite values come from config literals (`nan`/`inf`) or upstream arithmetic (0/0, overflow).

Source

Thrown at crates/zeroclaw-providers/src/kilocli.rs:89

            binary_path: None,
        }
    }

    /// Returns true if the model argument should be forwarded to the CLI.
    fn should_forward_model(model: &str) -> bool {
        let trimmed = model.trim();
        !trimmed.is_empty() && trimmed != DEFAULT_MODEL_MARKER
    }

    fn supports_temperature(temperature: f64) -> bool {
        KILO_CLI_SUPPORTED_TEMPERATURES
            .iter()
            .any(|v| (temperature - v).abs() < TEMP_EPSILON)
    }

    fn validate_temperature(temperature: f64) -> anyhow::Result<()> {
        if !temperature.is_finite() {
            anyhow::bail!("KiloCLI model_provider received non-finite temperature value");
        }
        if !Self::supports_temperature(temperature) {
            anyhow::bail!(
                "temperature unsupported by KiloCLI: {temperature}. \
                 Supported values: 0.7 or 1.0"
            );
        }
        Ok(())
    }

    fn redact_stderr(stderr: &[u8]) -> String {
        let text = String::from_utf8_lossy(stderr);
        let trimmed = text.trim();
        if trimmed.is_empty() {
            return String::new();
        }
        if trimmed.chars().count() <= MAX_KILO_CLI_STDERR_CHARS {
            return trimmed.to_string();

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Guard the producer: verify `is_finite()` before passing temperature to chat
  2. Fix or delete the `temperature` key in the agent/config file
  3. Pass Some(0.7) or Some(1.0) — the only supported values for kilocli

Example fix

// before
let temp: f64 = input.parse().unwrap_or(f64::NAN);
provider.chat(req, model, Some(temp)).await?;

// after
let temp: f64 = input.parse().ok().filter(|v| v.is_finite()).unwrap_or(0.7);
provider.chat(req, model, Some(temp)).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn temperature_safe(t: Option<f64>) -> bool {
    t.map(f64::is_finite).unwrap_or(true)
}

Type guard

fn is_finite_temperature(t: f64) -> bool { t.is_finite() }

Try / catch

if let Err(e) = kilo.chat(req, model, temp).await {
    if e.to_string().contains("non-finite temperature") {
        // fix the value producer; retrying the same input cannot succeed
    }
}

Prevention

When it happens

Trigger: A chat call on a KiloCliModelProvider with temperature = NaN or +/-inf: hand-edited config, computed division without a zero guard, or parsed "NaN"/"Infinity" strings from user input.

Common situations: Agent profiles shared across providers where one producer can emit NaN; normalization code that divides by a count that can be zero; lenient numeric parsing of external input.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/7c915d786071dcf4. Report an issue: GitHub.