Skip to content

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

TypeScript

test(mcp-host): pin the container refusal as a non-retryable context-length failure

Alfredo Lopeze134c8c54348
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 0d5c41119..55768918c 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.451",
+ "version": "0.1.452",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.451",
+ "version": "0.1.452",
"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 1a73f94db..6e0a406d8 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.451",
+ "version": "0.1.452",
"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.ts
index d98849f2c..7329837b4 100644
--- a/mcp-host/src/llm/__tests__/codexSubscription.test.ts
+++ b/mcp-host/src/llm/__tests__/codexSubscription.test.ts
@@ -338,6 +338,46 @@ describe('CodexSubscriptionProvider', () => {
expect(wired.stream).toHaveBeenCalledTimes(1)
})
+ it('T-C3b reports the container bound as a non-retryable context-length failure (A8)', async () => {
+ const wired = deps()
+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)
+ // `maxRequestContainers` bounds the heap JSON.parse allocates for a body.
+ // Its refusal carries `kind: 'size'` and matches no
+ // `CONTEXT_LENGTH_REFUSALS` row, so it reaches the user through
+ // `payload_too_large`, which classifies as `ContextLengthExceeded`. The
+ // array holds maxRequestContainers + 1 objects in well under 8 MiB, so the
+ // byte bound and the element bound cannot be what refuses it.
+ const rows = (count: number) => Array.from({ length: count }, () => ({}))
+ const history = (count: number) => [
+ { role: 'user' as const, content: 'summarize the export' },
+ {
+ role: 'assistant' as const,
+ content: '',
+ tool_calls: [{ id: 'call_1', name: 'export_rows', arguments: { rows: rows(count) } }],
+ },
+ ]
+
+ const rejected = provider.completeSingleTurn(history(LIMITS.maxRequestContainers + 1))
+ await expect(rejected).rejects.toBeInstanceOf(CodexAuthorizeError)
+ await expect(rejected).rejects.toMatchObject({
+ code: 'payload_too_large',
+ message: 'codex completion request rejected: request exceeds maxRequestContainers',
+ })
+ expect(wired.authorize).not.toHaveBeenCalled()
+ expect(wired.stream).not.toHaveBeenCalled()
+
+ const err = await rejected.catch((e: unknown) => e)
+ expect(provider.classifyError(err)).toMatchObject({
+ code: LlmErrorCode.ContextLengthExceeded,
+ retryable: false,
+ })
+
+ // Liveness witness: the same shape with a few objects goes through.
+ await provider.completeSingleTurn(history(3))
+ 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.ts
index 1c989c703..2d1d1fc3f 100644
--- a/mcp-host/src/llm/__tests__/grokSubscription.test.ts
+++ b/mcp-host/src/llm/__tests__/grokSubscription.test.ts
@@ -591,6 +591,44 @@ describe('GrokSubscriptionProvider', () => {
expect(wired.proxy.stream).toHaveBeenCalledTimes(1)
})
+ it('T-C3b-grok reports the container bound as a non-retryable context-length failure (A8)', async () => {
+ const wired = deps()
+ const provider = new GrokSubscriptionProvider('grok-4.6', wired as never)
+ // The Grok twin of T-C3b. The refusal carries `kind: 'size'` and matches
+ // no `CONTEXT_LENGTH_REFUSALS` row or attachment row, so it reaches the
+ // user through `payload_too_large` as `ContextLengthExceeded`. The array
+ // holds maxRequestContainers + 1 objects in well under 8 MiB.
+ const rows = (count: number) => Array.from({ length: count }, () => ({}))
+ const history = (count: number) => [
+ { role: 'user' as const, content: 'summarize the export' },
+ {
+ role: 'assistant' as const,
+ content: '',
+ tool_calls: [{ id: 'call_1', name: 'export_rows', arguments: { rows: rows(count) } }],
+ },
+ ]
+
+ const rejected = provider.completeSingleTurn(history(LIMITS.maxRequestContainers + 1))
+ await expect(rejected).rejects.toBeInstanceOf(CodexAuthorizeError)
+ await expect(rejected).rejects.toMatchObject({
+ code: 'payload_too_large',
+ message: 'request exceeds maxRequestContainers',
+ })
+ expect(wired.authorizer.authorize).not.toHaveBeenCalled()
+ expect(wired.proxy.stream).not.toHaveBeenCalled()
+
+ const err = await rejected.catch((e: unknown) => e)
+ expect(provider.classifyError(err)).toMatchObject({
+ code: LlmErrorCode.ContextLengthExceeded,
+ retryable: false,
+ })
+
+ // Liveness witness: the same shape with a few objects goes through.
+ await provider.completeSingleTurn(history(3))
+ 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)