Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(mcp-host): cover both proxy wire paths for the tool-call limit

Alfredo Lopez871e8d0c62e2
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 4862d18f2..d0c10f84c 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.356",
+ "version": "0.1.357",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.356",
+ "version": "0.1.357",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index 83805f035..d78711ce7 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.356",
+ "version": "0.1.357",
"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.ts
index 3ef536074..f292d3b8a 100644
--- a/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts
+++ b/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts
@@ -1,5 +1,12 @@
import { describe, expect, it, vi } from 'vitest'
-import { CodexLlmProxyClient, resolveCodexProxyRuntimeUrl } from '../codexLlmProxyClient'
+import { LlmErrorCode } from '../../core/errors'
+import {
+ CodexLlmProxyClient,
+ CodexProxyError,
+ resolveCodexProxyRuntimeUrl,
+} from '../codexLlmProxyClient'
+import { CodexSubscriptionProvider } from '../codexSubscription'
+import { classifyFailoverClass } from '../failover/classify'
function sse(frames: unknown[]): ReadableStream<Uint8Array> {
const encoder = new TextEncoder()
@@ -50,6 +57,57 @@ describe('CodexLlmProxyClient', () => {
])
})
+ // The proxy reports the tool-call limit on two wire paths: a 422 JSON body
+ // before any stream frame, or an SSE error frame after one. Both must reach
+ // the provider classifier with the proxy's code intact.
+ it.each([
+ {
+ path: '422 JSON body before streaming',
+ response: {
+ ok: false,
+ status: 422,
+ json: async () => ({ error: 'tool_call_limit_exceeded' }),
+ },
+ message: 'proxy stream failed with 422 (tool_call_limit_exceeded)',
+ },
+ {
+ path: 'SSE error frame after a text frame',
+ response: {
+ ok: true,
+ body: sse([
+ { type: 'text', text: 'partial' },
+ { type: 'error', code: 'tool_call_limit_exceeded' },
+ ]),
+ },
+ message: 'proxy stream failed with tool_call_limit_exceeded',
+ },
+ ])('surfaces tool_call_limit_exceeded from the $path', async ({ response, message }) => {
+ const fetchFn = vi.fn().mockResolvedValue(response)
+ 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: 'tool_call_limit_exceeded', message })
+
+ const classified = new CodexSubscriptionProvider('gpt-5.3-codex', {} as never).classifyError(
+ err
+ )
+ expect(classified.code).toBe(LlmErrorCode.ToolCallLimitExceeded)
+ expect(classified.retryable).toBe(false)
+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()
+ })
+
it('refuses a runtime URL that is not absolute', () => {
expect(
() =>