Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(mcp-host): classify the proxy member bound as context length
Alfredo Lopezae0ddfb18d4b
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex c37c5eea7..30e327790 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.455",+ "version": "0.1.456","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.455",+ "version": "0.1.456","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex dd7061a6e..5730a96ea 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.455",+ "version": "0.1.456","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__/codexSubscription.test.ts b/mcp-host/src/llm/__tests__/codexSubscription.test.tsindex 7329837b4..ccb6f5bfa 100644--- a/mcp-host/src/llm/__tests__/codexSubscription.test.ts+++ b/mcp-host/src/llm/__tests__/codexSubscription.test.ts@@ -378,6 +378,43 @@ describe('CodexSubscriptionProvider', () => {expect(wired.stream).toHaveBeenCalledTimes(1)})+ it('T-C3c surfaces the proxy member-bound 413 as a non-retryable context-length failure', async () => {+ const wired = deps({+ stream: vi+ .fn()+ .mockRejectedValue(new CodexProxyError('payload_too_large', 'proxy refused the envelope')),+ })+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)+ // The member-bound twin of T-C3b. The proxy's raw-body scan refuses a+ // body over `BODY_STRUCTURE_LIMITS.maxMembers` with HTTP 413+ // `body.structure.too.many.members`, which reaches mcp-host as+ // `payload_too_large`. A small turn passes every local guard, so the+ // refusal can only come from the proxy's member scan: the classify call+ // sees the same `payload_too_large` code the real 413 carries.+ const rejected = provider.completeSingleTurn([{ role: 'user', content: 'hi' }])+ await expect(rejected).rejects.toBeInstanceOf(CodexProxyError)+ await expect(rejected).rejects.toMatchObject({+ code: 'payload_too_large',+ dispatched: true,+ })++ const err = await rejected.catch((e: unknown) => e)+ const classified = provider.classifyError(err)+ expect(classified).toMatchObject({+ code: LlmErrorCode.ContextLengthExceeded,+ retryable: false,+ providerCode: 'payload_too_large',+ providerDispatched: true,+ })+ // Retrying or failing over cannot shrink a body the proxy already counted:+ // this is a context-length refusal, not a provider outage.+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()++ // Liveness witness: the request actually reached the proxy path.+ expect(wired.authorize).toHaveBeenCalledTimes(1)+ expect(wired.stream).toHaveBeenCalledTimes(1)+ })+it('T-C4 keeps a non-size limit refusal out of the context-length taxonomy (#731)', async () => {const wired = deps()const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)diff --git a/mcp-host/src/llm/__tests__/grokSubscription.test.ts b/mcp-host/src/llm/__tests__/grokSubscription.test.tsindex 2d1d1fc3f..3a1599095 100644--- a/mcp-host/src/llm/__tests__/grokSubscription.test.ts+++ b/mcp-host/src/llm/__tests__/grokSubscription.test.ts@@ -629,6 +629,43 @@ describe('GrokSubscriptionProvider', () => {expect(wired.proxy.stream).toHaveBeenCalledTimes(1)})+ it('T-C3c-grok surfaces the proxy member-bound 413 as a non-retryable context-length failure', async () => {+ const wired = deps({+ stream: vi+ .fn()+ .mockRejectedValue(new GrokProxyError('payload_too_large', 'proxy refused the envelope')),+ })+ const provider = new GrokSubscriptionProvider('grok-4.6', wired as never)+ // The Grok twin of T-C3c. The proxy's raw-body scan refuses a body over+ // `BODY_STRUCTURE_LIMITS.maxMembers` with HTTP 413+ // `body.structure.too.many.members`, which reaches mcp-host as+ // `payload_too_large`. A small turn passes every local guard, so the+ // refusal can only come from the proxy's member scan: the classify call+ // sees the same `payload_too_large` code the real 413 carries.+ const rejected = provider.completeSingleTurn([{ role: 'user', content: 'hi' }])+ await expect(rejected).rejects.toBeInstanceOf(GrokProxyError)+ await expect(rejected).rejects.toMatchObject({+ code: 'payload_too_large',+ dispatched: true,+ })++ const err = await rejected.catch((e: unknown) => e)+ const classified = provider.classifyError(err)+ expect(classified).toMatchObject({+ code: LlmErrorCode.ContextLengthExceeded,+ retryable: false,+ providerCode: 'payload_too_large',+ providerDispatched: true,+ })+ // Retrying or failing over cannot shrink a body the proxy already counted:+ // this is a context-length refusal, not a provider outage.+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()++ // Liveness witness: the request actually reached the proxy path.+ expect(wired.authorizer.authorize).toHaveBeenCalledTimes(1)+ expect(wired.proxy.stream).toHaveBeenCalledTimes(1)+ })+it('T-C4-grok keeps a nesting-depth refusal out of the context-length taxonomy (#731)', async () => {const wired = deps()const provider = new GrokSubscriptionProvider('grok-4.6', wired as never)