mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 14:01:06 +00:00
fix: clean up Codex thinking level handling
- Remove per-thinking-level model variants (gpt-5.2-codex-high, etc.) - Remove thinkingLevels from Model type - Provider clamps reasoning effort internally - Omit reasoning field when thinking is off fixes #472
This commit is contained in:
parent
02b72b49d5
commit
0b9e3ada0c
11 changed files with 45 additions and 148 deletions
|
|
@ -1007,16 +1007,10 @@ export class AgentSession {
|
|||
|
||||
/**
|
||||
* Get available thinking levels for current model.
|
||||
* The provider will clamp to what the specific model supports internally.
|
||||
*/
|
||||
getAvailableThinkingLevels(): ThinkingLevel[] {
|
||||
if (!this.supportsThinking()) return ["off"];
|
||||
|
||||
const modelLevels = this.model?.thinkingLevels;
|
||||
if (modelLevels && modelLevels.length > 0) {
|
||||
const withOff: ThinkingLevel[] = ["off", ...modelLevels];
|
||||
return THINKING_LEVELS_WITH_XHIGH.filter((level) => withOff.includes(level));
|
||||
}
|
||||
|
||||
return this.supportsXhighThinking() ? THINKING_LEVELS_WITH_XHIGH : THINKING_LEVELS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,16 +18,6 @@ import type { AuthStorage } from "./auth-storage.js";
|
|||
|
||||
const Ajv = (AjvModule as any).default || AjvModule;
|
||||
|
||||
const ThinkingLevelsSchema = Type.Array(
|
||||
Type.Union([
|
||||
Type.Literal("minimal"),
|
||||
Type.Literal("low"),
|
||||
Type.Literal("medium"),
|
||||
Type.Literal("high"),
|
||||
Type.Literal("xhigh"),
|
||||
]),
|
||||
);
|
||||
|
||||
// Schema for OpenAI compatibility settings
|
||||
const OpenAICompatSchema = Type.Object({
|
||||
supportsStore: Type.Optional(Type.Boolean()),
|
||||
|
|
@ -50,7 +40,6 @@ const ModelDefinitionSchema = Type.Object({
|
|||
]),
|
||||
),
|
||||
reasoning: Type.Boolean(),
|
||||
thinkingLevels: Type.Optional(ThinkingLevelsSchema),
|
||||
input: Type.Array(Type.Union([Type.Literal("text"), Type.Literal("image")])),
|
||||
cost: Type.Object({
|
||||
input: Type.Number(),
|
||||
|
|
@ -118,14 +107,6 @@ function resolveApiKeyConfig(keyConfig: string): string | undefined {
|
|||
return keyConfig;
|
||||
}
|
||||
|
||||
function normalizeCodexModelId(modelId: string): string {
|
||||
const suffixes = ["-none", "-minimal", "-low", "-medium", "-high", "-xhigh"];
|
||||
const normalized = modelId.toLowerCase();
|
||||
const matchedSuffix = suffixes.find((suffix) => normalized.endsWith(suffix));
|
||||
if (!matchedSuffix) return modelId;
|
||||
return modelId.slice(0, modelId.length - matchedSuffix.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Model registry - loads and manages models, resolves API keys via AuthStorage.
|
||||
*/
|
||||
|
|
@ -349,7 +330,6 @@ export class ModelRegistry {
|
|||
provider: providerName,
|
||||
baseUrl: providerConfig.baseUrl!,
|
||||
reasoning: modelDef.reasoning,
|
||||
thinkingLevels: modelDef.thinkingLevels,
|
||||
input: modelDef.input as ("text" | "image")[],
|
||||
cost: modelDef.cost,
|
||||
contextWindow: modelDef.contextWindow,
|
||||
|
|
@ -383,15 +363,7 @@ export class ModelRegistry {
|
|||
* Find a model by provider and ID.
|
||||
*/
|
||||
find(provider: string, modelId: string): Model<Api> | undefined {
|
||||
const exact = this.models.find((m) => m.provider === provider && m.id === modelId);
|
||||
if (exact) return exact;
|
||||
if (provider === "openai-codex") {
|
||||
const normalized = normalizeCodexModelId(modelId);
|
||||
if (normalized !== modelId) {
|
||||
return this.models.find((m) => m.provider === provider && m.id === normalized) ?? undefined;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
return this.models.find((m) => m.provider === provider && m.id === modelId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -102,18 +102,6 @@ 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).
|
||||
|
|
@ -134,14 +122,6 @@ 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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue