Skip to content
Merged
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
4 changes: 1 addition & 3 deletions open-sse/services/combo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
recordProviderFailure,
selectLockoutCooldownMs,
} from "./accountFallback.ts";
import { RateLimitReason } from "../config/constants.ts";
import { errorResponse, unavailableResponse } from "../utils/error.ts";
import {
recordComboIntent,
Expand Down Expand Up @@ -2345,8 +2344,7 @@ export async function handleComboChat({
fallbackResult.shouldFallback &&
!isContextOverflow400(errorText) &&
!isParamValidation400(errorText) &&
(fallbackResult.reason === RateLimitReason.MODEL_CAPACITY ||
errorText.toLowerCase().includes("context") ||
(errorText.toLowerCase().includes("context") ||
errorText.toLowerCase().includes("prompt") ||
errorText.toLowerCase().includes("token") ||
errorText.toLowerCase().includes("malformed") ||
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/combo-strategies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,39 @@ test("reset-aware strategy scores provider-specific weekly windows when availabl

assert.equal(await selectedConnectionFor(combo), soon);
});

test("priority combo advances to next model when first returns 400 'model not supported'", async () => {
const name = `model-not-supported-${randomUUID()}`;
const combo = await combosDb.createCombo({
name,
strategy: "priority",
models: ["openai/gpt-4", "openai/gpt-3.5-turbo"],
});

const calls: string[] = [];
const response = await handleComboChat({
body: reqBodyTextArray,
combo,
allCombos: [combo],
isModelAvailable: undefined,
relayOptions: undefined,
signal: undefined,
settings: {},
log: makeLog(),
handleSingleModel: async (_body: unknown, modelStr: string) => {
calls.push(modelStr);
if (modelStr === "openai/gpt-4") {
return Response.json(
{ error: { message: "requested model is not supported" } },
{ status: 400 }
);
}
Comment on lines +732 to +737

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure the fallback logic is robust against providers returning "invalid" in their unsupported model errors (e.g., "requested model is invalid"), we should update the test case to use an error message containing "invalid".

This will verify that the guard condition in handleComboChat correctly ignores "invalid" when it is associated with the model, allowing the fallback to proceed.

      if (modelStr === "openai/gpt-4") {
        return Response.json(
          { error: { message: "requested model is invalid" } },
          { status: 400 }
        );
      }

return okResponse(modelStr);
},
});

assert.equal(response.status, 200, "combo should advance to second model and return 200");
assert.equal(calls.length, 2, "combo should have tried both models");
assert.equal(calls[0], "openai/gpt-4", "first model should be tried first");
assert.equal(calls[1], "openai/gpt-3.5-turbo", "second model should be tried after 400");
});
Loading