fix: codex thinking handling

This commit is contained in:
Ben Vargas 2026-01-05 11:40:44 -07:00 committed by Mario Zechner
parent 22870ae0c2
commit 02b72b49d5
23 changed files with 205 additions and 754 deletions

View file

@ -102,6 +102,18 @@ export interface ParsedModelResult {
warning: string | undefined;
}
const THINKING_SUFFIXES = ["-none", "-minimal", "-low", "-medium", "-high", "-xhigh"];
function stripThinkingSuffix(pattern: string): string {
const normalized = pattern.toLowerCase();
for (const suffix of THINKING_SUFFIXES) {
if (normalized.endsWith(suffix)) {
return pattern.slice(0, pattern.length - suffix.length);
}
}
return pattern;
}
/**
* Parse a pattern to extract model and thinking level.
* Handles models with colons in their IDs (e.g., OpenRouter's :exacto suffix).
@ -122,6 +134,14 @@ export function parseModelPattern(pattern: string, availableModels: Model<Api>[]
return { model: exactMatch, thinkingLevel: "off", warning: undefined };
}
const normalizedPattern = stripThinkingSuffix(pattern);
if (normalizedPattern !== pattern) {
const normalizedMatch = tryMatchModel(normalizedPattern, availableModels);
if (normalizedMatch) {
return { model: normalizedMatch, thinkingLevel: "off", warning: undefined };
}
}
// No match - try splitting on last colon if present
const lastColonIndex = pattern.lastIndexOf(":");
if (lastColonIndex === -1) {