Skip to content
Open
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
46 changes: 42 additions & 4 deletions packages/provider-bridge-acp/src/bridge/bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1210,11 +1210,49 @@ describe("acp bridge", () => {
});
});

it("falls back to the synthetic model when the list command prints no models", async () => {
const emptyId = sendModelList({ modelLines: "no model lines here" });
expect((await waitForResponse(emptyId)).result).toMatchObject({
models: [{ id: "acp-default", isDefault: true }],
it.each([
["exits unsuccessfully", "process.exit(2)"],
["prints no models", "process.stdout.write('no model lines here')"],
["times out", "setInterval(() => {}, 1000)"],
])(
"fails model/list when the configured command %s without a cached catalog",
async (_failure, script) => {
const failingId = sendModelList({
agent: { command: process.execPath, args: ["-e", script] },
modelListArgs: ["--"],
});
const response = await waitFor(
() => findResponse(failingId),
`response ${failingId}`,
40_000,
);
expect(response.error?.message).toBe(
"ACP model list command failed to provide a model catalog.",
);
expect(response.result).toBeUndefined();
},
45_000,
);

it("keeps the last good CLI catalog when the same command later fails", async () => {
const scriptPath = join(workspaceDir, "model-list.cjs");
writeFileSync(
scriptPath,
"process.stdout.write('cached-model - Cached Model\\n')",
);
const launch = {
agent: { command: process.execPath, args: [scriptPath] },
modelListArgs: ["--"],
};
const first = await waitForResponse(sendModelList(launch));
expect(first.result).toMatchObject({
models: [{ id: "cached-model", displayName: "Cached Model" }],
});

writeFileSync(scriptPath, "process.exit(2)");
const second = await waitForResponse(sendModelList(launch));
expect(second.error).toBeUndefined();
expect(second.result).toEqual(first.result);
});

it("keeps CLI reasoning on the resolved model variant instead of ACP config", async () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/provider-bridge-acp/src/bridge/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2642,6 +2642,11 @@ async function handleModelList(
);
return;
}
if (params.listCommand) {
throw new Error(
"ACP model list command failed to provide a model catalog.",
);
}
const sessionDiscoveredModels =
params.listCommand === undefined && params.agent
? await loadSessionDiscoveredModels(
Expand Down
Loading