Hmbown/CodeWhale · error

context window must be greater than 0

Error message

context window must be greater than 0

What it means

save_provider_context_window_for_identity was given a context window of zero (or a value that failed the >0 check). A zero context window is meaningless and would break budget calculations, so the write is rejected.

Source

Thrown at crates/tui/src/config.rs:11648

    crate::config_persistence::mutate_config_document(&config_path, |doc| {
        crate::config_persistence::set_document_value(
            doc,
            &["providers", key_inside, "base_url"],
            base_url,
        )
    })
    .with_context(|| format!("Failed to write config to {}", config_path.display()))?;
    Ok(config_path)
}

/// Persist a guided-setup context-window choice without replacing the user's
/// surrounding TOML comments or formatting.
pub(crate) fn save_provider_context_window_for_identity(
    identity: &ProviderIdentity,
    _route_config: &Config,
    context_window: u32,
) -> Result<PathBuf> {
    anyhow::ensure!(context_window > 0, "context window must be greater than 0");
    let config_path = try_default_config_path()
        .context("Failed to resolve config path for provider context window.")?;
    ensure_parent_dir(&config_path)?;
    let key_inside = if identity.provider == ApiProvider::Custom {
        let key = identity.key.trim();
        anyhow::ensure!(!key.is_empty(), "custom provider id cannot be empty");
        key
    } else {
        provider_config_key(identity.provider).context("provider context window table")?
    };
    crate::config_persistence::mutate_config_document(&config_path, |doc| {
        crate::config_persistence::set_document_value(
            doc,
            &["providers", key_inside, "context_window"],
            i64::from(context_window),
        )
    })
    .with_context(|| format!("Failed to write config to {}", config_path.display()))?;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Enter a positive token count matching the model's real context window
  2. Fix the setup step that produced 0 (e.g. unparsed numeric input)
  3. Omit the setting to use the provider default instead
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/config.rs:11648 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/316c9b29d0230e29. Report an issue: GitHub.