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 distant half of the limit partition at the provider boundary (#731)

Alfredo Lopezf9cf4f8d02f2
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index c768862a2..f6200ec47 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.375",
+ "version": "0.1.376",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.375",
+ "version": "0.1.376",
"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 9021b03f0..4d3f5cb58 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.375",
+ "version": "0.1.376",
"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 2d9bf1cff..5ed6e8131 100644
--- a/mcp-host/src/llm/__tests__/codexSubscription.test.ts
+++ b/mcp-host/src/llm/__tests__/codexSubscription.test.ts
@@ -344,6 +344,40 @@ describe('CodexSubscriptionProvider', () => {
expect(wired.stream).toHaveBeenCalledTimes(1)
})
+ it('T-C5 keeps an out-of-range maxOutputTokens out of the context-length taxonomy (#731)', async () => {
+ const wired = deps()
+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)
+ // T-C4 and this test pin the same half of the partition from opposite
+ // distances, which is why both exist. `request exceeds maximum nesting
+ // depth 64` shares the prefix `request exceeds max` with the byte regex and
+ // diverges one character later, so T-C4 is the near miss: it fails the
+ // moment that regex is loosened at all. This message shares nothing with
+ // any of the three patterns, so it only fails under a broadening wide
+ // enough to swallow an unrelated field - the case T-C4 cannot see.
+ // `maxOutputTokens` reaches the contract from the caller unclamped
+ // (`codexSubscription.ts:259-261` -> `:444`), so this is a refusal a caller
+ // can actually provoke, not a synthetic one.
+ const history = [{ role: 'user' as const, content: 'summarize' }]
+
+ const rejected = provider.completeSingleTurn(history, { max_tokens: 16_385 })
+ await expect(rejected).rejects.toBeInstanceOf(CodexAuthorizeError)
+ await expect(rejected).rejects.toMatchObject({
+ code: 'invalid_request',
+ message: 'generation.maxOutputTokens is out of range',
+ })
+ expect(wired.authorize).not.toHaveBeenCalled()
+ expect(wired.stream).not.toHaveBeenCalled()
+
+ const err = await rejected.catch((e: unknown) => e)
+ expect(provider.classifyError(err).code).not.toBe(LlmErrorCode.ContextLengthExceeded)
+
+ // Liveness witness: the bound itself authorizes and streams, so the refusal
+ // is the range check and not the presence of `max_tokens` in the request.
+ await provider.completeSingleTurn(history, { max_tokens: 16_384 })
+ expect(wired.authorize).toHaveBeenCalledTimes(1)
+ expect(wired.stream).toHaveBeenCalledTimes(1)
+ })
+
it('requires an explicit model plus authorizer and proxy dependencies', () => {
process.env.MCP_HOST_CODEX_SUBSCRIPTION_ENABLED = 'true'
expect(() => makeProvider('codex-subscription', {})).toThrow(/explicit model and runtime/)