zed-industries/zed · error

auto_compact threshold percentage must be between 0% and 100

Error message

auto_compact threshold percentage must be between 0% and 100%, got {raw:?}

What it means

Error "auto_compact threshold percentage must be between 0% and 100%, got {raw:?}" thrown in zed-industries/zed.

Source

Thrown at crates/agent_settings/src/agent_settings.rs:182

            Self::TokensRemaining(tokens) => write!(formatter, "-{tokens}"),
        }
    }
}

#[derive(Clone, Copy, Debug, PartialEq)]
pub struct AutoCompactSettings {
    pub enabled: bool,
    pub threshold: AutoCompactThreshold,
}

fn parse_auto_compact_threshold(raw: &str) -> anyhow::Result<AutoCompactThreshold> {
    let trimmed = raw.trim();
    if let Some(percent) = trimmed.strip_suffix('%') {
        let value: f64 = percent
            .trim_end()
            .parse()
            .with_context(|| format!("invalid auto_compact threshold percentage {raw:?}"))?;
        anyhow::ensure!(
            value > 0.0 && value <= 100.0,
            "auto_compact threshold percentage must be between 0% and 100%, got {raw:?}"
        );
        Ok(AutoCompactThreshold::Percentage(value / 100.0))
    } else {
        let tokens: i64 = trimmed.parse().with_context(|| {
            format!(
                "invalid auto_compact threshold {raw:?}; \
                 expected a percentage like \"90%\" or an integer number of tokens"
            )
        })?;
        match tokens.cmp(&0) {
            Greater => Ok(AutoCompactThreshold::TokensUsed(tokens as u64)),
            Less => Ok(AutoCompactThreshold::TokensRemaining(tokens.unsigned_abs())),
            Equal => {
                anyhow::bail!("auto_compact threshold of 0 is not valid")
            }
        }

View on GitHub (pinned to bc538def45)

When it happens

Trigger: Thrown at crates/agent_settings/src/agent_settings.rs:182 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/6d85b7148b6564de. Report an issue: GitHub.