mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-20 05:42:19 +03:00
Validado numa worktree combinada com a onda de dashboard/monitoring desta leva sobre `release/v3.8.51`: typecheck:core limpo, check-api-typecheck OK (289), check-file-size OK após rebaseline, 130/131 nos testes focados — a falha restante é asserção de tempo de parede sob carga, verde 6/6 isolada. Envenenar a conexão inteira por um 402 de **um** modelo é o erro clássico de granularidade em provider openai-compatible com múltiplos upstreams — derruba modelos que estavam saudáveis. Restringir ao modelo afetado é o comportamento correto, e é a mesma distinção que o guia de resiliência faz entre cooldown de conexão e lockout de modelo.
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { routingFinishReason } from "../../open-sse/handlers/chatCore/routingFinishReason.ts";
|
|
|
|
test("routing finish reasons preserve chat and Responses shapes", () => {
|
|
assert.equal(routingFinishReason({ choices: [{ finish_reason: "stop" }] }), "stop");
|
|
assert.equal(routingFinishReason({ output: [null, {}, { finish_reason: "length" }] }), "length");
|
|
assert.equal(
|
|
routingFinishReason({
|
|
choices: [{ finish_reason: "tool_calls" }],
|
|
output: [{ finish_reason: "stop" }],
|
|
}),
|
|
"tool_calls"
|
|
);
|
|
});
|
|
|
|
test("unknown routing response shapes remain null", () => {
|
|
for (const body of [
|
|
null,
|
|
undefined,
|
|
false,
|
|
"stop",
|
|
12,
|
|
{},
|
|
{ choices: [] },
|
|
{ choices: [null] },
|
|
{ choices: [{ finish_reason: 42 }] },
|
|
{ output: [null, 3, { finish_reason: false }] },
|
|
]) {
|
|
assert.equal(routingFinishReason(body), null);
|
|
}
|
|
});
|
|
|
|
test("missing chat finish reason falls back to Responses output", () => {
|
|
assert.equal(routingFinishReason({ choices: [{}], output: [{ finish_reason: "stop" }] }), "stop");
|
|
});
|