Skip to content

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

TypeScript

test(grok): move the limit boundaries to 256 calls and 1024 messages

Alfredo Lopezd3a0513485e0
diff --git a/grok-llm-proxy/test/contractFreeze.test.ts b/grok-llm-proxy/test/contractFreeze.test.ts
index ea509da72..9cf44fbed 100644
--- a/grok-llm-proxy/test/contractFreeze.test.ts
+++ b/grok-llm-proxy/test/contractFreeze.test.ts
@@ -49,7 +49,9 @@ describe('grok-subscription contract freeze', () => {
expect(fixture.supportedOperations).not.toContain('oauth_browser')
expect(fixture.supportedOperations).toContain('oauth_device')
expect(fixture.limits.maxToolCalls).toBe(LIMITS.maxToolCalls)
- expect(fixture.limits.maxToolCalls).toBe(64)
+ expect(fixture.limits.maxToolCalls).toBe(256)
+ expect(fixture.limits.maxMessages).toBe(LIMITS.maxMessages)
+ expect(fixture.limits.maxMessages).toBe(1024)
expect(fixture.limits.maxRetriesPerAttempt).toBe(1)
// Live xAI gates subscription inference on a client version (426 probe,
// 2026-09-18), so we send one — but the identity stays Evenfire's and never
diff --git a/grok-llm-proxy/test/grokTransport.conformance.test.ts b/grok-llm-proxy/test/grokTransport.conformance.test.ts
index e9b814c21..745f0cd98 100644
--- a/grok-llm-proxy/test/grokTransport.conformance.test.ts
+++ b/grok-llm-proxy/test/grokTransport.conformance.test.ts
@@ -249,7 +249,7 @@ describe('streamGrokCompletion', () => {
expect(emitted).toEqual([])
}
)
- it.each([64, 65])(
+ it.each([256, 257])(
'validates the complete %s-call response before emitting executable calls',
async count => {
const emitted: Array<{ type: string }> = []
@@ -286,16 +286,16 @@ describe('streamGrokCompletion', () => {
emitted.push(frame)
},
})
- if (count === 64) {
+ if (count === 256) {
expect((await pending).outcome).toBe('success')
- expect(emitted.filter(frame => frame.type === 'tool_call')).toHaveLength(64)
+ expect(emitted.filter(frame => frame.type === 'tool_call')).toHaveLength(256)
} else {
- await expect(pending).rejects.toThrow(/tool calls exceed 64/)
+ await expect(pending).rejects.toThrow(/tool calls exceed 256/)
// The code, not only the message: the message is unchanged by the
// taxonomy work, so a message-only assertion passes either way.
await expect(pending).rejects.toMatchObject({
code: 'tool_call_limit_exceeded',
- details: { limit: 64, observed: 65 },
+ details: { limit: 256, observed: 257 },
})
expect(emitted.filter(frame => frame.type === 'tool_call')).toHaveLength(0)
expect(finalize).toHaveBeenCalledWith(
@@ -316,7 +316,7 @@ describe('streamGrokCompletion', () => {
duplicate: false,
}))
const frames = Array.from(
- { length: 65 },
+ { length: 257 },
() =>
`data: ${JSON.stringify({
type: 'response.output_item.added',
@@ -345,7 +345,7 @@ describe('streamGrokCompletion', () => {
})
await expect(pending).rejects.toMatchObject({
code: 'tool_call_limit_exceeded',
- details: { limit: 64, observed: 65 },
+ details: { limit: 256, observed: 257 },
})
expect(emitted.filter(frame => frame.type === 'tool_call')).toHaveLength(0)
expect(finalize).toHaveBeenCalledWith(
@@ -367,7 +367,7 @@ describe('streamGrokCompletion', () => {
const frames = [
`data: ${JSON.stringify({ type: 'response.output_text.delta', delta: 'before' })}\n\n`,
...Array.from(
- { length: 65 },
+ { length: 257 },
(_, index) =>
`data: ${JSON.stringify({
type: 'response.output_item.added',
@@ -397,7 +397,7 @@ describe('streamGrokCompletion', () => {
})
await expect(pending).rejects.toMatchObject({
code: 'tool_call_limit_exceeded',
- details: { limit: 64, observed: 65 },
+ details: { limit: 256, observed: 257 },
})
expect(emitted.filter(frame => frame.type === 'tool_call')).toHaveLength(0)
// Liveness witness and mutation detector in one: the leading text proves
diff --git a/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.ts b/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.ts
index 03d1cc1c9..9de6db4af 100644
--- a/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.ts
+++ b/grok-llm-proxy/test/runtimePath.hermetic.e2e.test.ts
@@ -512,12 +512,12 @@ describe('hermetic per-response tool-call limit', () => {
}
}
- it('rejects 65 calls before any text with 422 tool_call_limit_exceeded', async () => {
- const { res, redeems, finalizes, streams } = await runWithToolCallCount(65, 'att-limit-65', {
+ it('rejects 257 calls before any text with 422 tool_call_limit_exceeded', async () => {
+ const { res, redeems, finalizes, streams } = await runWithToolCallCount(257, 'att-limit-257', {
omitText: true,
})
- // Liveness witness: the fixture really served the 65-call stream.
+ // Liveness witness: the fixture really served the 257-call stream.
expect(streams).toBe(1)
// One assertion so a regression reports the status and the code together.
expect({
@@ -534,15 +534,15 @@ describe('hermetic per-response tool-call limit', () => {
expect(redeems).toHaveLength(1)
expect(finalizes).toHaveLength(1)
expect(finalizes[0]?.receipt).toMatchObject({
- providerAttemptId: 'att-limit-65',
+ providerAttemptId: 'att-limit-257',
outcome: 'error',
})
})
- it('rejects 65 calls after streamed text with an SSE tool_call_limit_exceeded frame', async () => {
+ it('rejects 257 calls after streamed text with an SSE tool_call_limit_exceeded frame', async () => {
const { res, redeems, finalizes, streams } = await runWithToolCallCount(
- 65,
- 'att-limit-65-text',
+ 257,
+ 'att-limit-257-text',
{ omitText: false }
)
@@ -561,13 +561,13 @@ describe('hermetic per-response tool-call limit', () => {
expect(redeems).toHaveLength(1)
expect(finalizes).toHaveLength(1)
expect(finalizes[0]?.receipt).toMatchObject({
- providerAttemptId: 'att-limit-65-text',
+ providerAttemptId: 'att-limit-257-text',
outcome: 'error',
})
})
- it('delivers exactly 64 calls in one response', async () => {
- const { res, redeems, finalizes, streams } = await runWithToolCallCount(64, 'att-limit-64', {
+ it('delivers exactly 256 calls in one response', async () => {
+ const { res, redeems, finalizes, streams } = await runWithToolCallCount(256, 'att-limit-256', {
omitText: true,
})
@@ -575,15 +575,15 @@ describe('hermetic per-response tool-call limit', () => {
expect(res.status).toBe(200)
const frames = sseFrames(res.text)
const toolCalls = frames.filter(frame => frame.type === 'tool_call')
- expect(toolCalls).toHaveLength(64)
+ expect(toolCalls).toHaveLength(256)
expect(toolCalls.map(frame => frame.id)).toEqual(
- Array.from({ length: 64 }, (_, index) => `call-hermetic-${index}`)
+ Array.from({ length: 256 }, (_, index) => `call-hermetic-${index}`)
)
expect(frames.find(frame => frame.type === 'done')?.outcome).toBe('success')
expect(redeems).toHaveLength(1)
expect(finalizes).toHaveLength(1)
expect(finalizes[0]?.receipt).toMatchObject({
- providerAttemptId: 'att-limit-64',
+ providerAttemptId: 'att-limit-256',
outcome: 'success',
})
})
diff --git a/grok-llm-proxy/test/server.security.test.ts b/grok-llm-proxy/test/server.security.test.ts
index 3771605df..f9c0ec632 100644
--- a/grok-llm-proxy/test/server.security.test.ts
+++ b/grok-llm-proxy/test/server.security.test.ts
@@ -606,10 +606,10 @@ describe('grok-llm-proxy attempt telemetry', () => {
for (const key of FORBIDDEN_LOG_KEYS) expect(key in line).toBe(false)
}
- it('(a) answers 422 and logs one attempt line when 65 calls arrive before any text', async () => {
+ it('(a) answers 422 and logs one attempt line when 257 calls arrive before any text', async () => {
const { res, receipts, lines, metricsText } = await run({
providerAttemptId: 'att-limit-http',
- calls: 65,
+ calls: 257,
})
expect(res.status).toBe(422)
// The staged SSE headers are replaced by a JSON response.
@@ -622,8 +622,8 @@ describe('grok-llm-proxy attempt telemetry', () => {
providerAttemptId: 'att-limit-http',
outcome: 'failed',
code: 'tool_call_limit_exceeded',
- reason: 'tool calls exceed 64',
- details: { limit: 64, observed: 65 },
+ reason: 'tool calls exceed 256',
+ details: { limit: 256, observed: 257 },
deliveredAs: 'http_status',
httpStatus: 422,
toolCalls: 0,
@@ -637,7 +637,7 @@ describe('grok-llm-proxy attempt telemetry', () => {
const { res, lines } = await run({
providerAttemptId: 'att-limit-sse',
textDeltas: 1,
- calls: 65,
+ calls: 257,
})
expect(res.status).toBe(200)
expect(res.text).toContain('data: {"type":"text","text":"t0"}')
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 65074c658..d9d139b9d 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.365",
+ "version": "0.1.366",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.365",
+ "version": "0.1.366",
"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 4c87a1cbb..7b940acdd 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.365",
+ "version": "0.1.366",
"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__/grokSubscription.test.ts b/mcp-host/src/llm/__tests__/grokSubscription.test.ts
index 0dae697b2..25d48a377 100644
--- a/mcp-host/src/llm/__tests__/grokSubscription.test.ts
+++ b/mcp-host/src/llm/__tests__/grokSubscription.test.ts
@@ -58,7 +58,7 @@ describe('GrokSubscriptionProvider', () => {
stream: vi.fn().mockResolvedValue({
text: '',
outcome: 'success',
- toolCalls: Array.from({ length: 65 }, (_, index) => ({
+ toolCalls: Array.from({ length: 257 }, (_, index) => ({
id: `call-${index}`,
name: 'echo',
arguments: {},
@@ -76,11 +76,11 @@ describe('GrokSubscriptionProvider', () => {
await expect(oversized).rejects.toMatchObject({
name: 'GrokProxyError',
code: 'tool_call_limit_exceeded',
- message: 'tool calls exceed 64',
+ message: 'tool calls exceed 256',
})
const classified = provider.classifyError(
- new GrokProxyError('tool_call_limit_exceeded', 'tool calls exceed 64')
+ new GrokProxyError('tool_call_limit_exceeded', 'tool calls exceed 256')
)
expect(classified.code).toBe(LlmErrorCode.ToolCallLimitExceeded)
expect(classified.retryable).toBe(false)
@@ -278,8 +278,8 @@ describe('GrokSubscriptionProvider', () => {
}
)
- it('accepts exactly 64 tool calls from a successful batch', async () => {
- const toolCalls = Array.from({ length: 64 }, (_, index) => ({
+ it('accepts exactly 256 tool calls from a successful batch', async () => {
+ const toolCalls = Array.from({ length: 256 }, (_, index) => ({
id: `call-${index}`,
name: 'echo',
arguments: {},
@@ -294,14 +294,14 @@ describe('GrokSubscriptionProvider', () => {
[{ role: 'user', content: 'hi' }],
[{ name: 'echo', description: 'echo', parameters: {} }]
)
- expect(result.tool_calls).toHaveLength(64)
+ expect(result.tool_calls).toHaveLength(256)
const over = new GrokSubscriptionProvider(
'grok-4.6',
deps({
stream: vi.fn().mockResolvedValue({
text: '',
outcome: 'success',
- toolCalls: [...toolCalls, { id: 'call-64', name: 'echo', arguments: {} }],
+ toolCalls: [...toolCalls, { id: 'call-256', name: 'echo', arguments: {} }],
}),
}) as never
)
@@ -309,11 +309,11 @@ describe('GrokSubscriptionProvider', () => {
[{ role: 'user', content: 'hi' }],
[{ name: 'echo', description: 'echo', parameters: {} }]
)
- await expect(rejected).rejects.toThrow(/tool calls exceed 64/)
+ await expect(rejected).rejects.toThrow(/tool calls exceed 256/)
await expect(rejected).rejects.toMatchObject({ code: 'tool_call_limit_exceeded' })
})
- it('refuses 129 messages before authorize and classifies the refusal as a context limit', async () => {
+ it('refuses 1025 messages before authorize and classifies the refusal as a context limit', async () => {
const wired = deps()
const provider = new GrokSubscriptionProvider('grok-4.6', wired as never)
const message = { role: 'user' as const, content: 'hi' }
@@ -321,14 +321,14 @@ describe('GrokSubscriptionProvider', () => {
// Liveness witness for the negative assertion below: the identical call
// one message shorter does reach authorize, so "authorize was not called"
// reports the guard rather than a provider that never ran.
- await provider.completeSingleTurn(Array.from({ length: 128 }, () => message))
+ await provider.completeSingleTurn(Array.from({ length: 1024 }, () => message))
expect(wired.authorizer.authorize).toHaveBeenCalledTimes(1)
- const refused = provider.completeSingleTurn(Array.from({ length: 129 }, () => message))
+ const refused = provider.completeSingleTurn(Array.from({ length: 1025 }, () => message))
await expect(refused).rejects.toBeInstanceOf(CodexAuthorizeError)
await expect(refused).rejects.toMatchObject({
code: 'request_limit_exceeded',
- message: 'messages exceed 128',
+ message: 'messages exceed 1024',
})
expect(wired.authorizer.authorize).toHaveBeenCalledTimes(1)
@@ -336,7 +336,7 @@ describe('GrokSubscriptionProvider', () => {
// `providerDispatched: false` is what proves nothing was billed for it,
// and it comes from the authorize arm of the same expression.
const classified = provider.classifyError(
- new CodexAuthorizeError('request_limit_exceeded', 'messages exceed 128')
+ new CodexAuthorizeError('request_limit_exceeded', 'messages exceed 1024')
)
expect(classified.code).toBe(LlmErrorCode.ContextLengthExceeded)
expect(classified.retryable).toBe(false)
diff --git a/mcp-host/src/llm/failover/__tests__/engine.test.ts b/mcp-host/src/llm/failover/__tests__/engine.test.ts
index a37e8b8c1..2594e091e 100644
--- a/mcp-host/src/llm/failover/__tests__/engine.test.ts
+++ b/mcp-host/src/llm/failover/__tests__/engine.test.ts
@@ -294,7 +294,7 @@ describe('FailoverEngine', () => {
const stream = vi.fn().mockResolvedValue({
text: '',
outcome: 'success',
- toolCalls: Array.from({ length: 65 }, (_, index) => ({
+ toolCalls: Array.from({ length: 257 }, (_, index) => ({
id: `call-${index}`,
name: 'echo',
arguments: {},
diff --git a/packages/grok-provider-attempt-contract/index.test.cjs b/packages/grok-provider-attempt-contract/index.test.cjs
index 46fa306a3..3704a9ac8 100644
--- a/packages/grok-provider-attempt-contract/index.test.cjs
+++ b/packages/grok-provider-attempt-contract/index.test.cjs
@@ -29,7 +29,7 @@ test('does not import Codex LIMITS or Codex provider id', () => {
assert.equal(src.includes("require('../llm-provider-attempt-contract"), false)
assert.equal(contract.PROVIDER_ID, 'grok-subscription')
assert.equal(contract.TICKET_TYP, 'grok-execution-ticket')
- assert.equal(contract.LIMITS.maxToolCalls, 64)
+ assert.equal(contract.LIMITS.maxToolCalls, 256)
assert.equal(contract.COMPLETIONS_ORIGIN, 'https://cli-chat-proxy.grok.com/v1/responses')
const chatgptHost = ['chatgpt', 'com'].join('.')
assert.equal(src.includes(chatgptHost), false)