feat: add provider availability detection and normalize legacy "default" model IDs
This commit is contained in:
@@ -19,4 +19,13 @@ describe("extractAgentModel", () => {
|
||||
|
||||
expect(extractAgentModel(agent)).toBe("gpt-5.1-codex");
|
||||
});
|
||||
|
||||
it("treats legacy 'default' model ids as unset", () => {
|
||||
const agent = {
|
||||
model: "default",
|
||||
runtimeInfo: { model: "default" },
|
||||
} as Partial<Agent> as Agent;
|
||||
|
||||
expect(extractAgentModel(agent)).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,11 +4,17 @@ export function extractAgentModel(agent?: Agent | null): string | null {
|
||||
if (!agent) return null;
|
||||
const runtimeModel = agent.runtimeInfo?.model;
|
||||
const fallbackModel = agent.model;
|
||||
if (typeof runtimeModel === "string" && runtimeModel.trim().length > 0) {
|
||||
return runtimeModel.trim();
|
||||
if (typeof runtimeModel === "string") {
|
||||
const normalized = runtimeModel.trim();
|
||||
if (normalized.length > 0 && normalized.toLowerCase() !== "default") {
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
if (typeof fallbackModel === "string" && fallbackModel.trim().length > 0) {
|
||||
return fallbackModel.trim();
|
||||
if (typeof fallbackModel === "string") {
|
||||
const normalized = fallbackModel.trim();
|
||||
if (normalized.length > 0 && normalized.toLowerCase() !== "default") {
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user