Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(grok): classify the tool-call and message limits as contract refusals
Alfredo Lopez76e0cbc93c38
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex fb023890b..8ee570bfc 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.363",+ "version": "0.1.364","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.363",+ "version": "0.1.364","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 2fc9ce550..81e89ac35 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.363",+ "version": "0.1.364","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/grokSubscription.ts b/mcp-host/src/llm/grokSubscription.tsindex b3f75f40a..f28aa0cff 100644--- a/mcp-host/src/llm/grokSubscription.ts+++ b/mcp-host/src/llm/grokSubscription.ts@@ -68,7 +68,7 @@ function assertTerminalGrokOutcome(result: {outcome: 'success' | 'canceled' | 'error' | 'unknown'}): void {if (result.toolCalls.length > LIMITS.maxToolCalls) {- throw new GrokProxyError('provider_unavailable', `tool calls exceed ${LIMITS.maxToolCalls}`)+ throw new GrokProxyError('tool_call_limit_exceeded', `tool calls exceed ${LIMITS.maxToolCalls}`)}if (result.toolCalls.length > 0 && result.outcome !== 'success') {throw new GrokProxyError(@@ -184,6 +184,28 @@ export class GrokSubscriptionProvider implements SingleTurnProvider {...(providerDispatched !== undefined ? { providerDispatched } : {}),}}+ if (code === 'tool_call_limit_exceeded') {+ // Not retryable: `retryable: true` would make this error+ // failover-eligible and enable the workflow fallback after tool+ // results, re-running the turn on another provider. The limit is a+ // contract rejection of the model output, not a provider outage.+ return {+ code: LlmErrorCode.ToolCallLimitExceeded,+ retryable: false,+ message: err instanceof Error ? err.message : String(err),+ providerCode: code,+ ...(providerDispatched !== undefined ? { providerDispatched } : {}),+ }+ }+ if (code === 'request_limit_exceeded') {+ return {+ code: LlmErrorCode.ContextLengthExceeded,+ retryable: false,+ message: err instanceof Error ? err.message : String(err),+ providerCode: code,+ ...(providerDispatched !== undefined ? { providerDispatched } : {}),+ }+ }if (code === 'provider_unavailable' || code === 'connection_unavailable') {return {code: LlmErrorCode.ModelOverloaded,@@ -264,6 +286,14 @@ export class GrokSubscriptionProvider implements SingleTurnProvider {if (options?.signal?.aborted) {throw new GrokProxyError('canceled', 'aborted before authorize', false)}+ // An over-long history is reported as a context-length failure instead of+ // a generic invalid request; it is thrown before authorize and dispatch.+ if (messages.length > LIMITS.maxMessages) {+ throw new CodexAuthorizeError(+ 'request_limit_exceeded',+ `messages exceed ${LIMITS.maxMessages}`+ )+ }// Hash and send the validated wire projection — exactly what control-api// authorize and the proxy re-derive. Hashing the locally built object let// shapes the parser normalizes away (an empty `generation` from a