Skip to content

Commit 5c98864

Browse files
committed
Respect Goose provider overrides and keep model refresh headless
Signed-off-by: Salman Mohammed <[email protected]>
1 parent b433a97 commit 5c98864

7 files changed

Lines changed: 162 additions & 17 deletions

File tree

‎docs/agent-control.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ resources. Production has no disposable storage override or preview launch mode.
160160
previous model. For Goose with Databricks v2, an explicit Browse asks Goose ACP
161161
for its live supported-model list and searches it in the existing picker. The
162162
exact returned ID is saved; an unlisted ID remains possible but is flagged
163-
after discovery. Other Goose providers retain manual model entry. Existing Goose credentials
163+
after discovery. Saved write-only `GOOSE_PROVIDER` overrides keep Browse
164+
reachable; native checks the effective provider before asking Goose. Goose
165+
has no separate Refresh action because its catalog lookup can start OAuth.
166+
Other Goose providers retain manual model entry. Existing Goose credentials
164167
are reused; providers without local setup need `goose configure` before Start. Executable detection
165168
is not a sign-in or ACP readiness check. Custom command/provider values remain
166169
editable, including absolute paths. Buzz Agent retains on-demand Databricks

‎src-tauri/src/agent_models.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ pub(crate) async fn agent_models_run<R: tauri::Runtime>(
255255
== Some("goose")
256256
});
257257
if goose {
258+
// Goose's catalog handler may start OAuth on a cache miss. Only the
259+
// explicit Browse/Retry action may invoke it; Refresh stays headless.
260+
if request.action != Operation::Connect {
261+
return host
262+
.run(ticket, async {
263+
Err("Goose model lookup requires explicit Browse or Retry".into())
264+
})
265+
.await;
266+
}
258267
let prepared = request
259268
.edit
260269
.clone()

‎src-tauri/src/agent_models/tests.rs‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,42 @@ fn goose_databricks_models_load_through_native_ipc_for_an_unsaved_agent() {
9696
use std::os::unix::fs::PermissionsExt;
9797
let (dir, _, _app, view) = fixture();
9898
let goose = dir.path().join("goose");
99+
let invoked = dir.path().join("invoked");
99100
std::fs::write(
100101
&goose,
101-
"#!/bin/sh\nread request\nprintf '%s\\n' '{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"providerId\":\"databricks_v2\",\"models\":[\"catalog.schema.goose-glm-5-3\"]}}'\n",
102+
format!(
103+
"#!/bin/sh\n: > '{}'\nread request\nprintf '%s\\n' '{{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{{\"providerId\":\"databricks_v2\",\"models\":[\"catalog.schema.goose-glm-5-3\"]}}}}'\n",
104+
invoked.display()
105+
),
102106
)
103107
.unwrap();
104108
std::fs::set_permissions(&goose, std::fs::Permissions::from_mode(0o700)).unwrap();
109+
let edit = json!({"name":"Goose","systemPrompt":"","workspace":dir.path(),
110+
"harness":{"command":goose,"args":["acp"],"provider":"databricks_v2","model":""},
111+
"environment":{}});
112+
let refresh_ticket = invoke(&view, "agent_models_begin", json!({})).unwrap();
113+
assert!(invoke(
114+
&view,
115+
"agent_models_run",
116+
json!({"ticket":refresh_ticket,"request":{
117+
"host":"", "filter":"", "action":"refresh", "edit":edit
118+
}})
119+
)
120+
.unwrap_err()
121+
.to_string()
122+
.contains("explicit Browse or Retry"));
123+
assert!(!invoked.exists());
105124
let ticket = invoke(&view, "agent_models_begin", json!({})).unwrap();
106125
let result = invoke(
107126
&view,
108127
"agent_models_run",
109128
json!({"ticket":ticket,"request":{
110129
"host":"", "filter":"", "action":"connect",
111-
"edit":{"name":"Goose","systemPrompt":"","workspace":dir.path(),
112-
"harness":{"command":goose,"args":["acp"],"provider":"databricks_v2","model":""},
113-
"environment":{}}
130+
"edit":edit
114131
}}),
115132
)
116133
.unwrap();
134+
assert!(invoked.exists());
117135
assert_eq!(result["models"][0]["id"], "catalog.schema.goose-glm-5-3");
118136
assert_eq!(result["host"], "");
119137
}

‎src/bundled/agents/AgentModelPicker.test.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ it("Goose Databricks v2 browses live IDs and flags an unlisted short name", asyn
5959
action: "connect",
6060
}),
6161
);
62-
expect(screen.getByRole("combobox", { name: "Model" })).toHaveAttribute(
63-
"aria-expanded",
64-
"true",
62+
await waitFor(() =>
63+
expect(screen.getByRole("combobox", { name: "Model" })).toHaveAttribute(
64+
"aria-expanded",
65+
"true",
66+
),
6567
);
6668
await user.click(
6769
screen.getByRole("option", {

‎src/bundled/agents/AgentModelPicker.tsx‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,6 @@ export function AgentModelPicker({
320320
}
321321
/>
322322
</Field>
323-
{supported && goose && (
324-
<Button
325-
disabled={disabled || busy}
326-
onClick={() => void run("refresh")}
327-
>
328-
Refresh models
329-
</Button>
330-
)}
331323
{supported && !goose && (
332324
<>
333325
<Field label="Databricks workspace (HTTPS origin)">

‎src/bundled/agents/AgentSettingsFields.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ export function AgentSettingsFields({
3232
onChange(patch: Partial<AgentDraft>): void;
3333
}) {
3434
const goose = isGoose(draft.command);
35+
const providerOverride = draft.environment.GOOSE_PROVIDER;
36+
const provider = providerOverride ?? draft.provider;
37+
const gooseCanBrowse =
38+
provider === "databricks_v2" ||
39+
(providerOverride === undefined &&
40+
environmentKeys.includes("GOOSE_PROVIDER"));
3541
return (
3642
<div className="min-w-0">
3743
<div className="min-w-0 space-y-section-gap">
@@ -62,7 +68,7 @@ export function AgentSettingsFields({
6268
options={state.data?.harnessOptions ?? []}
6369
onChange={onChange}
6470
/>
65-
{goose && draft.provider !== "databricks_v2" ? (
71+
{goose && !gooseCanBrowse ? (
6672
<div className="space-y-2">
6773
<Field label="Model">
6874
<Input

‎src/bundled/agents/AgentsPage.test.tsx‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,121 @@ it("selects installed Goose with ACP arguments and saves its provider and model"
418418
);
419419
});
420420

421+
for (const source of ["saved", "draft"] as const) {
422+
for (const provider of ["", "openai"] as const) {
423+
it(`browses Goose models with a ${source} Databricks override and ${provider || "blank"} selector`, async () => {
424+
const run = vi.fn(async () => ({
425+
host: "",
426+
models: [{ id: "catalog.schema.model", name: "catalog.schema.model" }],
427+
modelOverridden: false,
428+
disconnected: false,
429+
}));
430+
setup("ready", (fixture) => {
431+
Object.assign(fixture.agent.harness, {
432+
command: "/fixture/bin/goose",
433+
args: ["acp"],
434+
provider,
435+
environmentKeys: source === "saved" ? ["GOOSE_PROVIDER"] : [],
436+
});
437+
fixture.data.harnessOptions?.push({
438+
command: "/fixture/bin/goose",
439+
label: "Goose",
440+
available: true,
441+
defaultArgs: ["acp"],
442+
providers: [{ value: "databricks_v2", label: "Databricks v2" }],
443+
});
444+
fixture.host.models = {
445+
begin: async () => 1,
446+
cancel: async () => {},
447+
run,
448+
};
449+
});
450+
const [card] = await screen.findAllByRole("article", {
451+
name: "Agent Fixture agent",
452+
});
453+
if (!card) throw Error("Missing managed card");
454+
fireEvent.click(
455+
within(card).getByRole("button", { name: "Actions for Fixture agent" }),
456+
);
457+
fireEvent.click(await screen.findByRole("menuitem", { name: "Edit" }));
458+
const dialog = screen.getByRole("dialog", { name: "Edit agent" });
459+
if (source === "draft") {
460+
expect(
461+
within(dialog).queryByRole("button", { name: "Browse models" }),
462+
).not.toBeInTheDocument();
463+
fireEvent.click(
464+
within(dialog).getByRole("button", { name: "Environment" }),
465+
);
466+
fireEvent.change(within(dialog).getByLabelText("Variable name"), {
467+
target: { value: "GOOSE_PROVIDER" },
468+
});
469+
fireEvent.click(
470+
within(dialog).getByRole("button", { name: "Add variable" }),
471+
);
472+
fireEvent.change(
473+
within(dialog).getByLabelText("Replacement for GOOSE_PROVIDER"),
474+
{ target: { value: "databricks_v2" } },
475+
);
476+
}
477+
expect(
478+
within(dialog).queryByRole("button", { name: "Refresh models" }),
479+
).not.toBeInTheDocument();
480+
fireEvent.click(
481+
within(dialog).getByRole("button", { name: "Browse models" }),
482+
);
483+
await waitFor(() =>
484+
expect(run).toHaveBeenCalledWith(
485+
1,
486+
expect.objectContaining({
487+
action: "connect",
488+
edit: expect.objectContaining({
489+
harness: expect.objectContaining({ provider }),
490+
environment:
491+
source === "saved" ? {} : { GOOSE_PROVIDER: "databricks_v2" },
492+
}),
493+
}),
494+
),
495+
);
496+
});
497+
}
498+
}
499+
500+
it("uses a draft Goose provider override before the Databricks selector", async () => {
501+
setup("ready", (fixture) => {
502+
Object.assign(fixture.agent.harness, {
503+
command: "/fixture/bin/goose",
504+
args: ["acp"],
505+
provider: "databricks_v2",
506+
environmentKeys: [],
507+
});
508+
});
509+
const [card] = await screen.findAllByRole("article", {
510+
name: "Agent Fixture agent",
511+
});
512+
if (!card) throw Error("Missing managed card");
513+
fireEvent.click(
514+
within(card).getByRole("button", { name: "Actions for Fixture agent" }),
515+
);
516+
fireEvent.click(await screen.findByRole("menuitem", { name: "Edit" }));
517+
const dialog = screen.getByRole("dialog", { name: "Edit agent" });
518+
expect(
519+
within(dialog).getByRole("button", { name: "Browse models" }),
520+
).toBeVisible();
521+
fireEvent.click(within(dialog).getByRole("button", { name: "Environment" }));
522+
fireEvent.change(within(dialog).getByLabelText("Variable name"), {
523+
target: { value: "GOOSE_PROVIDER" },
524+
});
525+
fireEvent.click(within(dialog).getByRole("button", { name: "Add variable" }));
526+
fireEvent.change(
527+
within(dialog).getByLabelText("Replacement for GOOSE_PROVIDER"),
528+
{ target: { value: "openai" } },
529+
);
530+
expect(
531+
within(dialog).queryByRole("button", { name: "Browse models" }),
532+
).not.toBeInTheDocument();
533+
expect(within(dialog).getByLabelText("Model")).toBeVisible();
534+
});
535+
421536
it("creates a stopped Goose agent with the selected provider", async () => {
422537
vi.spyOn(communityApi, "communityRequest").mockResolvedValue({ auth: [] });
423538
const commit = vi.fn();

0 commit comments

Comments
 (0)