Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(mcp-host): pin the proxy 408 request_timeout as non-retryable (#739)
Alfredo Lopez75bd6cfd866b
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex f4c6f849e..1a72211cb 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.418",+ "version": "0.1.419","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.418",+ "version": "0.1.419","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 9d1730067..9a2138e22 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.418",+ "version": "0.1.419","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts b/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.tsindex b7e8a435d..bf35b72d0 100644--- a/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts+++ b/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts@@ -280,6 +280,42 @@ describe('CodexLlmProxyClient', () => {})+ // T-MB-5 — the proxy answers `408 { error: 'request_timeout' }` when the+ // body upload overruns its read deadline. The body never reached the+ // upstream, so this is not an outage: it must not enter failover cooldown.+ it('T-MB-5a classifies the proxy 408 request_timeout as a non-retryable ApiCallFailed', async () => {+ const fetchFn = vi.fn(async () => Response.json({ error: 'request_timeout' }, { status: 408 }))+ const client = new CodexLlmProxyClient({+ runtimeUrl: resolveCodexProxyRuntimeUrl(+ 'http://codex-llm-proxy.control-plane.svc.cluster.local:8080'+ ),+ readPlatformJwt: () => 'platform-jwt',+ fetchFn: fetchFn as unknown as typeof fetch,+ })+ const err = await client+ .stream({ executionTicket: 'ticket-123456', requestHash: 'a'.repeat(64), request: {} })+ .then(+ () => undefined,+ (e: unknown) => e+ )+ expect(fetchFn).toHaveBeenCalledTimes(1)+ expect(err).toBeInstanceOf(CodexProxyError)+ expect(err).toMatchObject({+ code: 'request_timeout',+ message: 'proxy stream failed with 408 (request_timeout)',+ })++ const classified = new CodexSubscriptionProvider('gpt-5.3-codex', {} as never).classifyError(+ err+ )+ expect(classified).toMatchObject({+ code: LlmErrorCode.ApiCallFailed,+ retryable: false,+ providerCode: 'request_timeout',+ })+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()+ })+it('refuses a runtime URL that is not absolute', () => {expect(() =>diff --git a/mcp-host/src/llm/__tests__/codexSubscription.test.ts b/mcp-host/src/llm/__tests__/codexSubscription.test.tsindex fe43cf967..7eb10745e 100644--- a/mcp-host/src/llm/__tests__/codexSubscription.test.ts+++ b/mcp-host/src/llm/__tests__/codexSubscription.test.ts@@ -710,6 +710,23 @@ describe('CodexSubscriptionProvider', () => {})+ // T-MB-5 — the proxy's 408 for a body upload over its read deadline. The+ // upstream never saw the body; a retryable class would cost the provider a+ // failover cooldown for what is the Host's own slow upload.+ it('T-MB-5c classifies request_timeout as a non-retryable ApiCallFailed', () => {+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', deps() as never)+ const message = 'proxy stream failed with 408 (request_timeout)'+ const classified = provider.classifyError(new CodexProxyError('request_timeout', message))+ expect(classified).toEqual({+ code: LlmErrorCode.ApiCallFailed,+ retryable: false,+ message,+ providerCode: 'request_timeout',+ providerDispatched: true,+ })+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()+ })+it('keeps insufficient_scope distinguishable', () => {const provider = new CodexSubscriptionProvider('gpt-5.3-codex', deps() as never)const classified = provider.classifyError(diff --git a/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts b/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.tsindex ec332f851..a4a189f16 100644--- a/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts+++ b/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts@@ -255,6 +255,33 @@ describe('GrokLlmProxyClient', () => {expect(fetchFn).toHaveBeenCalledTimes(1)})+ // T-MB-5 — the proxy answers `408 { error: 'request_timeout' }` when the+ // body upload overruns its read deadline. The body never reached the+ // upstream, so this is not an outage: it must not enter failover cooldown.+ it('T-MB-5b classifies the proxy 408 request_timeout as a non-retryable ApiCallFailed', async () => {+ const fetchFn = vi.fn(async () => Response.json({ error: 'request_timeout' }, { status: 408 }))+ const err = await client(fetchFn)+ .stream(STREAM_INPUT)+ .then(+ () => undefined,+ (e: unknown) => e+ )+ expect(fetchFn).toHaveBeenCalledTimes(1)+ expect(err).toBeInstanceOf(GrokProxyError)+ expect(err).toMatchObject({+ code: 'request_timeout',+ message: 'proxy stream failed with 408 (request_timeout)',+ })++ const classified = new GrokSubscriptionProvider('grok-4.6', {} as never).classifyError(err)+ expect(classified).toMatchObject({+ code: LlmErrorCode.ApiCallFailed,+ retryable: false,+ providerCode: 'request_timeout',+ })+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()+ })+it('fails closed when the proxy emits an SSE error frame after headers', async () => {const fetchFn = vi.fn().mockResolvedValue({ok: true,diff --git a/mcp-host/src/llm/__tests__/grokSubscription.test.ts b/mcp-host/src/llm/__tests__/grokSubscription.test.tsindex 0795d07f9..553dc2682 100644--- a/mcp-host/src/llm/__tests__/grokSubscription.test.ts+++ b/mcp-host/src/llm/__tests__/grokSubscription.test.ts@@ -122,6 +122,23 @@ describe('GrokSubscriptionProvider', () => {})+ // T-MB-5 — the proxy's 408 for a body upload over its read deadline. The+ // upstream never saw the body; a retryable class would cost the provider a+ // failover cooldown for what is the Host's own slow upload.+ it('T-MB-5d classifies request_timeout as a non-retryable ApiCallFailed', () => {+ const provider = new GrokSubscriptionProvider('grok-4.6', deps() as never)+ const message = 'proxy stream failed with 408 (request_timeout)'+ const classified = provider.classifyError(new GrokProxyError('request_timeout', message))+ expect(classified).toEqual({+ code: LlmErrorCode.ApiCallFailed,+ retryable: false,+ message,+ providerCode: 'request_timeout',+ providerDispatched: true,+ })+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()+ })+it('still completes a successful terminal outcome', async () => {const provider = new GrokSubscriptionProvider('grok-4.6', deps() as never)await expect(