Skip to content

Commit bc828cc

Browse files
committed
fix(cli): preserve explicit sidecar backend clear
1 parent 6b9e204 commit bc828cc

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎src/cli/agent.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async function sidecar(argv: string[], deps: RuntimeApiDeps): Promise<void> {
203203
&& (requestedBackend === undefined || candidate.backend === requestedBackend));
204204
if (option) {
205205
settings.model = option.model;
206-
settings.backend = option.backend;
206+
if (backend !== "-") settings.backend = option.backend;
207207
}
208208
}
209209
const body = section === "web" ? { webSearch: settings } : { vision: settings };

‎tests/cli-headless-parity.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,40 @@ describe("ocx agent sidecar --list (#2188)", () => {
8989
}
9090
});
9191

92+
test("web --model preserves an explicit backend clear", async () => {
93+
const { requests, deps } = fakeRuntime((req, body) => {
94+
const url = new URL(req.url);
95+
if (url.pathname === "/api/sidecar-settings" && req.method === "GET") {
96+
return {
97+
webSearchModels: [
98+
{ value: "gpt-5.6-luna", label: "gpt-5.6-luna", model: "gpt-5.6-luna", backend: "openai" },
99+
],
100+
visionModels: [],
101+
};
102+
}
103+
if (url.pathname === "/api/sidecar-settings" && req.method === "PUT") {
104+
return { ok: true, saved: body };
105+
}
106+
return undefined;
107+
});
108+
const logSpy = spyOn(console, "log").mockImplementation(() => {});
109+
try {
110+
expect(await handleAgentCommand([
111+
"sidecar", "web", "--model", "gpt-5.6-luna", "--backend", "-",
112+
], deps)).toBe(0);
113+
expect(requests).toEqual([
114+
{ path: "/api/sidecar-settings", method: "GET", body: null },
115+
{
116+
path: "/api/sidecar-settings",
117+
method: "PUT",
118+
body: { webSearch: { model: "gpt-5.6-luna", backend: null } },
119+
},
120+
]);
121+
} finally {
122+
logSpy.mockRestore();
123+
}
124+
});
125+
92126
test("web --model surfaces the server's backend/model pair rejection", async () => {
93127
const { requests, deps } = fakeRuntime(req => {
94128
const url = new URL(req.url);

0 commit comments

Comments
 (0)