pub fn nearest_effort(
requested: ReasoningLevel,
supported: &[ReasoningLevel],
) -> Option<ReasoningLevel>Expand description
Map a requested reasoning level onto the closest level the model actually supports.
Algorithm (lifted from OpenAI Codex’s nearest_effort):
- If the model has no supported levels, return
None— caller decides whether to error or silently disable reasoning. - Prefer the highest supported level whose rank is ≤ requested. This is the “graceful downgrade” semantic Claude Code uses (“falls back to the highest supported level at or below the one you set”).
- If every supported level is above the requested rank, fall back to the lowest supported level. Better to honor the user’s intent to enable reasoning than to silently disable it.