diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs index 4b44ea8fa3..69e92a8557 100644 --- a/codex-rs/core/src/config/mod.rs +++ b/codex-rs/core/src/config/mod.rs @@ -513,48 +513,14 @@ fn sanitize_reasoning_effort_table( table.remove("model_reasoning_effort"); - let suggestion = closest_value(&normalized, allowed); - let suggestion_text = suggestion - .as_deref() - .map(|value| format!(" Did you mean \"{value}\"?")) - .unwrap_or_default(); let allowed_text = allowed.join(", "); warnings.push(ConfigWarning { message: format!( - "Invalid config value for {path}: \"{raw}\". Allowed values: {allowed_text}.{suggestion_text} Falling back to default." + "Invalid config value for {path}: \"{raw}\". Allowed values: {allowed_text}. Falling back to default." ), }); } -fn closest_value(input: &str, options: &[String]) -> Option { - let mut best: Option<(&String, usize)> = None; - for option in options { - let distance = edit_distance(input, option); - match best { - Some((_, best_distance)) if distance >= best_distance => {} - _ => best = Some((option, distance)), - } - } - best.map(|(option, _)| option.clone()) -} - -fn edit_distance(a: &str, b: &str) -> usize { - let mut costs = (0..=b.len()).collect::>(); - for (i, ca) in a.chars().enumerate() { - let mut last = i; - costs[0] = i + 1; - for (j, cb) in b.chars().enumerate() { - let next = costs[j + 1]; - let replace_cost = if ca == cb { last } else { last + 1 }; - let insert_cost = costs[j] + 1; - let delete_cost = costs[j + 1] + 1; - costs[j + 1] = replace_cost.min(insert_cost).min(delete_cost); - last = next; - } - } - costs[b.len()] -} - impl Config { /// This is the preferred way to create an instance of [Config]. pub async fn load_with_cli_overrides(