fix: report model run fallback metadata

This commit is contained in:
Peter Steinberger
2026-05-02 07:59:47 +01:00
parent 11560f8d3a
commit ea1a0277d5
8 changed files with 109 additions and 3 deletions

View File

@@ -585,6 +585,47 @@ describe("capability cli", () => {
);
});
it("surfaces gateway model fallback attempts in model probe JSON", async () => {
mocks.callGateway.mockResolvedValueOnce({
result: {
payloads: [{ text: "gateway fallback reply" }],
meta: {
agentMeta: {
provider: "openai",
model: "gpt-4.1-mini",
fallbackAttempts: [
{
provider: "openrouter",
model: "openrouter/auto",
error: "model unavailable",
reason: "model_not_found",
},
],
},
},
},
} as never);
await runRegisteredCli({
register: registerCapabilityCli as (program: Command) => void,
argv: ["capability", "model", "run", "--prompt", "hello", "--gateway", "--json"],
});
expect(mocks.runtime.writeJson).toHaveBeenCalledWith(
expect.objectContaining({
provider: "openai",
model: "gpt-4.1-mini",
attempts: [
expect.objectContaining({
provider: "openrouter",
model: "openrouter/auto",
reason: "model_not_found",
}),
],
}),
);
});
it("requests admin scope for gateway model probes with provider/model overrides", async () => {
await runRegisteredCli({
register: registerCapabilityCli as (program: Command) => void,