Show an agent's own model in the composer when the catalog lacks it (#5796)

The composer fell back to the catalog's default model whenever the agent's
model was missing from the loaded model list, so a Codex subagent started
on a model the catalog did not list yet was labeled as the default model,
with that model's thinking options.

Fixes #5791

Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
This commit is contained in:
paseo-bot[bot]
2026-10-01 00:00:16 +02:00
committed by GitHub
parent a7c9c05bef
commit 20a887f4cc
2 changed files with 29 additions and 3 deletions
@@ -186,4 +186,30 @@ describe("resolveAgentModelSelection", () => {
expect(selection.selectedThinkingId).toBe("low");
expect(selection.displayThinking).toBe("Low");
});
it("shows the agent's own model when the catalog does not list it", () => {
const selection = resolveAgentModelSelection({
models: [
{
id: "gpt-6-sol",
provider: "codex",
label: "GPT-6-Sol",
isDefault: true,
thinkingOptions: [
{ id: "medium", label: "medium" },
{ id: "max", label: "max" },
],
defaultThinkingOptionId: "medium",
},
],
runtimeModelId: "gpt-6.1-sol",
configuredModelId: "gpt-6.1-sol",
explicitThinkingOptionId: "max",
});
expect(selection.selectedModel).toBeNull();
expect(selection.activeModelId).toBe("gpt-6.1-sol");
expect(selection.displayModel).toBe("gpt-6.1-sol");
expect(selection.displayThinking).toBe("Max");
});
});
@@ -79,10 +79,10 @@ function pickSelectedModel(
preferredModelId: string | null,
fallbackModel: AgentModelDefinition | null,
): AgentModelDefinition | null {
if (!models || !preferredModelId) {
if (!preferredModelId) {
return fallbackModel;
}
return findModelById(models, preferredModelId) ?? fallbackModel;
return findModelById(models, preferredModelId);
}
function resolveThinkingId(
@@ -164,7 +164,7 @@ export function resolveAgentModelSelection(input: {
const thinkingOptions = selectedModel?.thinkingOptions ?? null;
const resolvedThinkingId = resolveThinkingId(explicitThinkingOptionId, selectedModel);
const effectiveThinking = resolveEffectiveThinking(thinkingOptions, resolvedThinkingId);
const selectedThinkingId = effectiveThinking?.id ?? null;
const selectedThinkingId = effectiveThinking?.id ?? resolvedThinkingId;
const displayThinking = resolveThinkingDisplay(
effectiveThinking,
selectedThinkingId,