Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(mcp-host): pin local member-bound refusal as context length (R2-H1)
claude[bot]a4076a2d6281
diff --git a/mcp-host/src/llm/__tests__/codexSubscription.test.ts b/mcp-host/src/llm/__tests__/codexSubscription.test.tsindex 21daed6f3..3e8f3cb1b 100644--- a/mcp-host/src/llm/__tests__/codexSubscription.test.ts+++ b/mcp-host/src/llm/__tests__/codexSubscription.test.ts@@ -414,6 +414,52 @@ describe('CodexSubscriptionProvider', () => {expect(wired.stream).toHaveBeenCalledTimes(1)})+ it('T-C3d reports the local member bound as a non-retryable context-length failure (R2-H1)', async () => {+ const wired = deps()+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)+ // The local member-bound twin of T-C3b. `checkStructure` refuses a request+ // over `maxRequestMembers` with `kind: 'size'` and the message+ // `request exceeds maxRequestMembers`, which matches no+ // `CONTEXT_LENGTH_REFUSALS` row, so — exactly like the container bound — it+ // reaches the user through `payload_too_large`, which classifies as+ // `ContextLengthExceeded`. A single flat object of scalar keys trips the+ // member bound (262144) before the element bound (1048576) and adds only one+ // container, so neither of those can be what refuses it.+ const fields = (count: number) => {+ const object: Record<string, number> = {}+ for (let i = 0; i < count; i++) object['f' + i] = 1+ return object+ }+ 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: { fields: fields(count) } }],+ },+ ]++ const rejected = provider.completeSingleTurn(history(LIMITS.maxRequestMembers + 1))+ await expect(rejected).rejects.toBeInstanceOf(CodexAuthorizeError)+ await expect(rejected).rejects.toMatchObject({+ code: 'payload_too_large',+ message: 'codex completion request rejected: request exceeds maxRequestMembers',+ })+ 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 members 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.tsindex 005587b16..5f2505e08 100644--- a/mcp-host/src/llm/__tests__/grokSubscription.test.ts+++ b/mcp-host/src/llm/__tests__/grokSubscription.test.ts@@ -669,6 +669,52 @@ describe('GrokSubscriptionProvider', () => {expect(wired.proxy.stream).toHaveBeenCalledTimes(1)})+ it('T-C3d-grok reports the local member bound as a non-retryable context-length failure (R2-H1)', async () => {+ const wired = deps()+ const provider = new GrokSubscriptionProvider('grok-4.6', wired as never)+ // The local member-bound twin of T-C3b-grok. `checkStructure` refuses a+ // request over `maxRequestMembers` with `kind: 'size'` and the message+ // `request exceeds maxRequestMembers`, which matches no+ // `CONTEXT_LENGTH_REFUSALS` row or attachment row, so — exactly like the+ // container bound — it reaches the user through `payload_too_large`, which+ // classifies as `ContextLengthExceeded`. A single flat object of scalar+ // keys trips the member bound (262144) before the element bound (1048576)+ // and adds only one container, so neither of those can be what refuses it.+ const fields = (count: number) => {+ const object: Record<string, number> = {}+ for (let i = 0; i < count; i++) object['f' + i] = 1+ return object+ }+ 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: { fields: fields(count) } }],+ },+ ]++ const rejected = provider.completeSingleTurn(history(LIMITS.maxRequestMembers + 1))+ await expect(rejected).rejects.toBeInstanceOf(CodexAuthorizeError)+ await expect(rejected).rejects.toMatchObject({+ code: 'payload_too_large',+ message: 'request exceeds maxRequestMembers',+ })+ 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 members 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)diff --git a/mcp-host/src/llm/codexSubscription.ts b/mcp-host/src/llm/codexSubscription.tsindex cdeda771d..6c8fc31e6 100644--- a/mcp-host/src/llm/codexSubscription.ts+++ b/mcp-host/src/llm/codexSubscription.ts@@ -70,10 +70,12 @@ export type CodexAttemptContext = {* `subscriptionRequestHash.test.ts` pins for the over-deep schema.* The image budgets belong to the attachments, not the conversation: a `size`* one is `attachment_too_large` (see `ATTACHMENT_BUDGET_REFUSALS`), the- * `maxImages` `count` one stays `invalid_request`. The container bound- * (`maxRequestContainers`, `checkStructure`) is volume too, but it is not- * listed: it carries `kind: 'size'`, so it reaches the user as- * `payload_too_large`, which classifies the same way (T-C3b).+ * `maxImages` `count` one stays `invalid_request`. The structural volume bounds+ * (`maxRequestContainers` and `maxRequestMembers`, both from `checkStructure`)+ * are volume too, but they are not listed: each carries `kind: 'size'`, so it+ * reaches the user as `payload_too_large`, which classifies the same way+ * (T-C3b for containers, T-C3d for members; the proxy's raw-body member 413 is+ * T-C3c).** `hashCanonicalCodexRequest` also returns a `kind`, but it cannot replace the* message here: `size` covers the conversation bytes and the image byte anddiff --git a/mcp-host/src/llm/grokSubscription.ts b/mcp-host/src/llm/grokSubscription.tsindex df4f5fa91..5b981370a 100644--- a/mcp-host/src/llm/grokSubscription.ts+++ b/mcp-host/src/llm/grokSubscription.ts@@ -80,10 +80,12 @@ export type GrokAttemptContext = {* providers. The image budgets belong to the attachments, not the* conversation: a `size` one is `attachment_too_large` (see* `ATTACHMENT_BUDGET_REFUSALS`), the `maxImages` `count` one stays- * `invalid_request`. The container bound (`maxRequestContainers`,- * `checkStructure`) is volume too, but it is not listed: it carries- * `kind: 'size'`, so it reaches the user as `payload_too_large`, which- * classifies the same way (T-C3b-grok).+ * `invalid_request`. The structural volume bounds (`maxRequestContainers` and+ * `maxRequestMembers`, both from `checkStructure`) are volume too, but they are+ * not listed: each carries `kind: 'size'`, so it reaches the user as+ * `payload_too_large`, which classifies the same way (T-C3b-grok for+ * containers, T-C3d-grok for members; the proxy's raw-body member 413 is+ * T-C3c-grok).** `hashCanonicalGrokRequest` also returns a `kind` (#784), but it cannot* replace the message here: `size` covers the conversation bytes and the image