Skip to content
Merged
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
29 changes: 13 additions & 16 deletions apps/gateway/src/api-individual.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ describe("e2e individual tests", () => {
);

test(
"Auto-routing sets reasoning_effort to minimal for gpt-5 models",
"Auto-routing sets reasoning_effort appropriately",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
getTestOptions({ completions: false }),
async () => {
const envVarName = getProviderEnvVar("openai");
Expand Down Expand Up @@ -584,32 +584,29 @@ describe("e2e individual tests", () => {
const log = await validateLogByRequestId(requestId);
expect(log.requestedModel).toBe("auto");

// Should auto-select gpt-5-nano (cheapest eligible model for auto)
// The provider can be either 'openai' or 'routeway-discount' depending on routing logic
expect(log.usedModelMapping).toBe("gpt-5-nano");
expect(log.usedModel).toMatch(/^(openai|routeway-discount)\/gpt-5-nano$/);
expect(["openai", "routeway-discount"]).toContain(log.usedProvider);
// Verify a reasoning model was selected
const usedModel = log.usedModelMapping;
expect(usedModel).toBeDefined();

// Should auto-set reasoning_effort to minimal for gpt-5* models
// The key test is that gpt-5-nano was selected and the request completed successfully
// This validates that the auto-routing + reasoning_effort logic works without errors
// Verify reasoningEffort is set and has the correct value based on model
expect(log.reasoningEffort).toBeDefined();
if (usedModel?.startsWith("gpt-5")) {
expect(log.reasoningEffort).toEqual("minimal");
} else {
expect(log.reasoningEffort).toEqual("low");
}

// Verify the response has valid usage information
expect(json.usage).toBeDefined();
expect(json.usage.prompt_tokens).toBeGreaterThan(0);
expect(json.usage.completion_tokens).toBeGreaterThan(0);
expect(json.usage.total_tokens).toBeGreaterThan(0);

// Check if reasoning was actually used (reasoning_tokens may not be present for minimal effort)
// Check if reasoning was actually used
// reasoning_tokens may not be present for minimal/low effort
if (json.usage.reasoning_tokens !== undefined) {
expect(typeof json.usage.reasoning_tokens).toBe("number");
expect(json.usage.reasoning_tokens).toBeGreaterThanOrEqual(0);
} else {
// For minimal effort, reasoning_tokens might be 0 or not present
// The key test is that gpt-5-nano was selected and no errors occurred
console.log(
"Note: reasoning_tokens not present, which may be expected for minimal effort",
);
}
},
);
Expand Down
Loading