mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:10:43 +00:00
fix: report model run fallback metadata
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -711,7 +711,13 @@ async function runModelRun(params: {
|
||||
const response: {
|
||||
result?: {
|
||||
payloads?: Array<{ text?: string; mediaUrl?: string | null; mediaUrls?: string[] }>;
|
||||
meta?: { agentMeta?: { provider?: string; model?: string } };
|
||||
meta?: {
|
||||
agentMeta?: {
|
||||
provider?: string;
|
||||
model?: string;
|
||||
fallbackAttempts?: Array<Record<string, unknown>>;
|
||||
};
|
||||
};
|
||||
};
|
||||
} = await callGateway({
|
||||
method: "agent",
|
||||
@@ -746,7 +752,7 @@ async function runModelRun(params: {
|
||||
transport: "gateway" as const,
|
||||
provider: response?.result?.meta?.agentMeta?.provider,
|
||||
model: response?.result?.meta?.agentMeta?.model,
|
||||
attempts: [],
|
||||
attempts: response?.result?.meta?.agentMeta?.fallbackAttempts ?? [],
|
||||
outputs: (response?.result?.payloads ?? []).map((payload) => ({
|
||||
text: payload.text,
|
||||
mediaUrl: payload.mediaUrl,
|
||||
|
||||
Reference in New Issue
Block a user