From c642eede4d954c38642fea8ca0a3bd82745996d5 Mon Sep 17 00:00:00 2001 From: Christiaan Arnoldus Date: Wed, 9 Sep 2026 12:11:45 +0200 Subject: [PATCH 1/3] fix: rephrase auto-routing selection error --- apps/web/src/app/api/openrouter/[...path]/route.ts | 5 ++--- apps/web/src/lib/ai-gateway/llm-proxy-helpers.ts | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/web/src/app/api/openrouter/[...path]/route.ts b/apps/web/src/app/api/openrouter/[...path]/route.ts index 6b5328a17d..6ed31fb28f 100644 --- a/apps/web/src/app/api/openrouter/[...path]/route.ts +++ b/apps/web/src/app/api/openrouter/[...path]/route.ts @@ -324,9 +324,8 @@ export async function POST(request: NextRequest): Promise Date: Wed, 9 Sep 2026 12:21:48 +0200 Subject: [PATCH 2/3] test: align auto-routing error expectations --- apps/web/src/app/api/openrouter/[...path]/route.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/web/src/app/api/openrouter/[...path]/route.test.ts b/apps/web/src/app/api/openrouter/[...path]/route.test.ts index e720384ed5..a900dd1360 100644 --- a/apps/web/src/app/api/openrouter/[...path]/route.test.ts +++ b/apps/web/src/app/api/openrouter/[...path]/route.test.ts @@ -1407,7 +1407,7 @@ describe('kilo-auto/efficient classifier billing', () => { expect(stats.cost_mUsd).toBe(1000); // toMicrodollars(0.001) }); - it('guides teams that block every pool model to configure a custom Efficient pool', async () => { + it('reports an auto-routing selection failure when a group blocks every pool model', async () => { mockedGetUserFromAuth.mockResolvedValue({ user: { id: 'user-123', @@ -1434,12 +1434,12 @@ describe('kilo-auto/efficient classifier billing', () => { expect(response.status).toBe(404); expect(await response.json()).toMatchObject({ error_type: 'model_not_allowed', - message: expect.stringContaining('custom Efficient model pool'), + message: expect.stringContaining('Auto-routing could not select an eligible model'), }); expect(mockedUpstreamRequest).not.toHaveBeenCalled(); }); - it('guides enterprise teams whose baseline blocks every pool model to configure a custom Efficient pool', async () => { + it('reports an auto-routing selection failure when an organization blocks every pool model', async () => { mockedGetUserFromAuth.mockResolvedValue({ user: { id: 'user-123', @@ -1467,7 +1467,7 @@ describe('kilo-auto/efficient classifier billing', () => { expect(response.status).toBe(404); expect(await response.json()).toMatchObject({ error_type: 'model_not_allowed', - message: expect.stringContaining('custom Efficient model pool'), + message: expect.stringContaining('Auto-routing could not select an eligible model'), }); expect(mockedUpstreamRequest).not.toHaveBeenCalled(); }); From 90ffa361034e52b43e0fa5ee9e073a5549f71870 Mon Sep 17 00:00:00 2001 From: Christiaan Arnoldus Date: Wed, 9 Sep 2026 12:30:09 +0200 Subject: [PATCH 3/3] fix: make auto-routing selection failures retryable --- apps/web/src/app/api/openrouter/[...path]/route.test.ts | 4 ++-- apps/web/src/lib/ai-gateway/llm-proxy-helpers.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app/api/openrouter/[...path]/route.test.ts b/apps/web/src/app/api/openrouter/[...path]/route.test.ts index a900dd1360..a9b1235740 100644 --- a/apps/web/src/app/api/openrouter/[...path]/route.test.ts +++ b/apps/web/src/app/api/openrouter/[...path]/route.test.ts @@ -1431,7 +1431,7 @@ describe('kilo-auto/efficient classifier billing', () => { const { POST } = await import('./route'); const response = await POST(makeRequest(makeBody('kilo-auto/efficient')) as never); - expect(response.status).toBe(404); + expect(response.status).toBe(503); expect(await response.json()).toMatchObject({ error_type: 'model_not_allowed', message: expect.stringContaining('Auto-routing could not select an eligible model'), @@ -1464,7 +1464,7 @@ describe('kilo-auto/efficient classifier billing', () => { const { POST } = await import('./route'); const response = await POST(makeRequest(makeBody('kilo-auto/efficient')) as never); - expect(response.status).toBe(404); + expect(response.status).toBe(503); expect(await response.json()).toMatchObject({ error_type: 'model_not_allowed', message: expect.stringContaining('Auto-routing could not select an eligible model'), diff --git a/apps/web/src/lib/ai-gateway/llm-proxy-helpers.ts b/apps/web/src/lib/ai-gateway/llm-proxy-helpers.ts index 2cd38f7792..45370e3395 100644 --- a/apps/web/src/lib/ai-gateway/llm-proxy-helpers.ts +++ b/apps/web/src/lib/ai-gateway/llm-proxy-helpers.ts @@ -338,7 +338,7 @@ export function efficientPoolBlockedResponse() { error_type: ProxyErrorType.model_not_allowed, message, }, - { status: 404 } + { status: 503 } ); }