Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/server/management/agent-settings-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,10 @@ export async function handleAgentSettingsRoutes(ctx: ManagementContext): Promise
const models = await (deps.fetchAllModels ?? fetchAllModels)(config);
// Evaluate visibility AFTER discovery: a concurrent visibility write may have completed.
const visible = new Set(filterCatalogVisibleModels(models, config).map(catalogModelSlug).filter(slug => slug.includes("/")));
// A bare native id orders the complete picker (docs: guides/model-ordering.md).
for (const row of nativeModelRows(config)) if (!row.disabled) visible.add(row.slug);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate native IDs on native passthrough availability

When the configuration has an enabled non-OpenAI provider, or providers.openai uses key auth/noncanonical URL, shouldIncludeNativeOpenAi() returns false and catalog convergence omits every bare native row, but nativeModelRows(config) still returns its enabled static rows. This therefore accepts and persists an unavailable bare ID such as gpt-5.5; because any bare ID activates complete-picker ordering, it can also reorder the remaining routed catalog even though the requested target never appears. Apply the same native-inclusion predicate used by catalog convergence before adding these rows to visible, and cover a key-auth or non-OpenAI-only configuration.

Useful? React with 👍 / 👎.

if (pickerOrder.some(model => !visible.has(model))) {
return jsonResponse({ error: "pickerOrder must contain each visible routed model at most once" }, 400);
return jsonResponse({ error: "pickerOrder must contain visible routed or native model ids, each at most once" }, 400);
}
}
}
Expand Down
13 changes: 12 additions & 1 deletion tests/routing/subagent-roster-retention.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe("picker updates preserve roster and persistence intent", () => {
test.each([null, [], 1, "bad", {}, { pickerOrderMode: "provider" }, { models: null },
{ models: [1] }, { pickerOrder: [" "] }, { pickerOrder: ["alpha/one", " alpha/one "] },
{ pickerOrder: ["absent/model"], models: ["replacement"] },
{ pickerOrder: null, pickerOrderMode: "custom" }, { pickerOrder: ["gpt-5.5"] },
{ pickerOrder: null, pickerOrderMode: "custom" }, { pickerOrder: ["gpt-9.9-imaginary"] },
])("invalid body %j is rejected before any mutation", async body => {
const config = makeConfig({ subagentModels: ["keep"], modelPickerOrder: ["alpha/one"], modelPickerOrderMode: "most-used" });
const before = structuredClone(config);
Expand All @@ -161,6 +161,17 @@ describe("picker updates preserve roster and persistence intent", () => {
expect((await handleAgentSettingsRoutes(context(config, { pickerOrder: [id] })))?.status).toBe(400);
}
});
test("a visible bare native id orders the complete picker; a disabled one is rejected (#6338)", async () => {
const config = makeConfig({ subagentModels: ["keep"] });
const ok = context(config, { pickerOrder: ["gpt-5.5", "beta/two"] });
expect((await handleAgentSettingsRoutes(ok))?.status).toBe(200);
expect(config.modelPickerOrder).toEqual(["gpt-5.5", "beta/two"]);
const disabled = makeConfig({ disabledModels: ["gpt-5.5"] });
const before = structuredClone(disabled);
const rejected = context(disabled, { pickerOrder: ["gpt-5.5"] });
expect((await handleAgentSettingsRoutes(rejected))?.status).toBe(400);
expect(disabled).toEqual(before);
});
test.each([{ pickerOrder: null }, { pickerOrder: ["beta/two"] }])("failed picker save %j restores fields AND deletion provenance", async ({ pickerOrder }) => {
const config = makeConfig({ subagentModels: ["keep"], modelPickerOrder: ["alpha/one"], modelPickerOrderMode: "most-used" });
deleteConfigTopLevelKey(config, "streamMode");
Expand Down
Loading