{"record":{"id":"6d85b7148b6564de","repo":"zed-industries/zed","slug":"auto-compact-threshold-percentage-must-be-between","errorCode":null,"errorMessage":"auto_compact threshold percentage must be between 0% and 100%, got {raw:?}","messagePattern":"auto_compact threshold percentage must be between 0% and 100%, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent_settings/src/agent_settings.rs","lineNumber":188,"sourceCode":"            Self::TokensRemaining(tokens) => write!(formatter, \"-{tokens}\"),\n        }\n    }\n}\n\n#[derive(Clone, Copy, Debug, PartialEq)]\npub struct AutoCompactSettings {\n    pub enabled: bool,\n    pub threshold: AutoCompactThreshold,\n}\n\nfn parse_auto_compact_threshold(raw: &str) -> anyhow::Result<AutoCompactThreshold> {\n    let trimmed = raw.trim();\n    if let Some(percent) = trimmed.strip_suffix('%') {\n        let value: f64 = percent\n            .trim_end()\n            .parse()\n            .with_context(|| format!(\"invalid auto_compact threshold percentage {raw:?}\"))?;\n        anyhow::ensure!(\n            value > 0.0 && value <= 100.0,\n            \"auto_compact threshold percentage must be between 0% and 100%, got {raw:?}\"\n        );\n        Ok(AutoCompactThreshold::Percentage(value / 100.0))\n    } else {\n        let tokens: i64 = trimmed.parse().with_context(|| {\n            format!(\n                \"invalid auto_compact threshold {raw:?}; \\\n                 expected a percentage like \\\"90%\\\" or an integer number of tokens\"\n            )\n        })?;\n        match tokens.cmp(&0) {\n            Greater => Ok(AutoCompactThreshold::TokensUsed(tokens as u64)),\n            Less => Ok(AutoCompactThreshold::TokensRemaining(tokens.unsigned_abs())),\n            Equal => {\n                anyhow::bail!(\"auto_compact threshold of 0 is not valid\")\n            }\n        }","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/agent_settings/src/agent_settings.rs#L170-L206","documentation":"Raised by parse_auto_compact_threshold while parsing the user's auto_compact settings string: the value was given with a '%' suffix (percentage form) and parsed as a number successfully, but the resulting percentage falls outside the valid 0–100 range. The offending input is the raw threshold string from agent settings (e.g. \"150%\" or \"-5%\").","triggerScenarios":"Thrown at crates/agent_settings/src/agent_settings.rs:182 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the threshold to a percentage between 0% and 100%","Use the token-count form (a plain integer) to specify remaining tokens instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}