Preserve model defaults after discovery

Signed-off-by: Salman Mohammed <smohammed@squareup.com>
This commit is contained in:
Salman Mohammed
2026-09-23 22:07:51 -04:00
parent 4f77fd2dcd
commit 48c13b5ac9
2 changed files with 15 additions and 2 deletions

View File

@@ -425,7 +425,8 @@ export function AgentConfigFields({
autoSelectedModelScopeRef.current = null;
return;
}
if ((config.model ?? "").trim().length > 0) return;
// Discovery fills an unset model; it must not replace an inherited default.
if ((config.model ?? "").trim() || fallbackModel?.trim()) return;
if (modelDiscoveryLoading || discoveredModelOptions === null) return;
const selectionScope = `${selectedRuntimeId}:${trimmedProvider}`;
if (autoSelectedModelScopeRef.current === selectionScope) return;
@@ -441,6 +442,7 @@ export function AgentConfigFields({
}, [
config,
discoveredModelOptions,
fallbackModel,
isCustomProvider,
modelDiscoveryLoading,
onConfigChange,

View File

@@ -1234,7 +1234,7 @@ test("baked build config keeps Finish enabled without manual provider setup", as
await expect(page.getByTestId("onboarding-finish")).toBeEnabled();
});
test("bundled Goose displays its own provider and model defaults", async ({
test("bundled Goose preserves its defaults after model discovery", async ({
page,
}) => {
await installMockBridge(
@@ -1263,6 +1263,10 @@ test("bundled Goose displays its own provider and model defaults", async ({
bakedBuildEnv: [
{ key: "BUZZ_AGENT_PROVIDER", masked: false, value: "anthropic" },
],
discoverAgentModels: {
models: [{ id: "discovered-model", name: "Discovered Model" }],
supportsSwitching: true,
},
globalAgentConfig: {
env_vars: {},
provider: null,
@@ -1279,6 +1283,13 @@ test("bundled Goose displays its own provider and model defaults", async ({
await expect(page.getByTestId("global-agent-provider")).toContainText(
"Databricks",
);
// Wait for the competing catalog entry to render so this assertion cannot
// pass before the discovery effect has had a chance to replace the default.
await page.getByTestId("global-agent-model").click();
await expect(
page.getByTestId("global-agent-model-option-discovered-model"),
).toBeVisible();
await page.keyboard.press("Escape");
await expect(page.getByTestId("global-agent-model")).toContainText(
"bundled-pilot-model",
);