Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(grok): pin the failover decision and the Desktop label for the limit
Alfredo Lopezbc9f25e9419c
diff --git a/desktop-app/ui/src/components/agents/__tests__/ChatThread.renderSemantics.test.tsx b/desktop-app/ui/src/components/agents/__tests__/ChatThread.renderSemantics.test.tsxindex 737bda91e..b97c4f21b 100644--- a/desktop-app/ui/src/components/agents/__tests__/ChatThread.renderSemantics.test.tsx+++ b/desktop-app/ui/src/components/agents/__tests__/ChatThread.renderSemantics.test.tsx@@ -123,6 +123,15 @@ describe('ChatThread error code labels', () => {expect(label).toBe('Too Many Tool Calls · CODEX-SUBSCRIPTION')})+ // The label is keyed by error code and the provider is appended generically,+ // so a second provider reaching the same code needs no renderer change. This+ // asserts that claim instead of assuming it.+ it('labels the Grok tool-call limit with the same copy and its own provider', () => {+ const { label, text } = renderErrorLabel('LLM_TOOL_CALL_LIMIT_EXCEEDED', 'grok-subscription')+ expect(label).toBe('Too Many Tool Calls · GROK-SUBSCRIPTION')+ expect(text).not.toContain('Model Overloaded')+ })+it('labels a context length error as "Conversation Too Long"', () => {expect(renderErrorLabel('LLM_CONTEXT_LENGTH_EXCEEDED').label).toBe('Conversation Too Long')})diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 8ee570bfc..65074c658 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.364",+ "version": "0.1.365","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.364",+ "version": "0.1.365","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 81e89ac35..4c87a1cbb 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.364",+ "version": "0.1.365","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/failover/__tests__/engine.test.ts b/mcp-host/src/llm/failover/__tests__/engine.test.tsindex 05b9499e9..a37e8b8c1 100644--- a/mcp-host/src/llm/failover/__tests__/engine.test.ts+++ b/mcp-host/src/llm/failover/__tests__/engine.test.ts@@ -3,6 +3,7 @@ import { LlmPortAdapter } from '../../../core/adapters/llmPortAdapter'import { LlmError, LlmErrorCode } from '../../../core/errors'import { CodexProxyError } from '../../codexLlmProxyClient'import { CodexSubscriptionProvider } from '../../codexSubscription'+import { GrokSubscriptionProvider } from '../../grokSubscription'import { type ClassifiedLike, FailoverEngine } from '../engine'import type { FailoverSwitchEvent, LlmPolicy, ModelPair } from '../types'@@ -285,6 +286,73 @@ describe('FailoverEngine', () => {reason: 'provider_unavailable',})})++ // The same claim for Grok. This is issue #680 in its most direct form:+ // before the taxonomy, the limit classified as ModelOverloaded/retryable,+ // failover fired, and the fallback answered from partial tool results.+ it('propagates a Grok tool-call limit without switching or setting a cooldown', async () => {+ const stream = vi.fn().mockResolvedValue({+ text: '',+ outcome: 'success',+ toolCalls: Array.from({ length: 65 }, (_, index) => ({+ id: `call-${index}`,+ name: 'echo',+ arguments: {},+ })),+ })+ const adapter = new LlmPortAdapter(+ new GrokSubscriptionProvider('grok-4.6', {+ authorizer: {+ authorize: vi.fn().mockResolvedValue({+ providerAttemptId: 'attempt-1',+ requestHash: 'a'.repeat(64),+ executionTicket: 'ticket-123456',+ expiresAt: '2026-08-20T10:00:00.000Z',+ }),+ },+ proxy: { stream },+ attemptContext: () => ({+ policyRevision: 1,+ policyHash: 'b'.repeat(64),+ hostRef: 'chatllm',+ }),+ } as never),+ 'grok-4.6',+ 'grok-subscription'+ )+ const thrown: unknown[] = []+ const call = vi.fn(+ (): Promise<unknown> =>+ adapter+ .completeWithTools({+ messages: [{ role: 'user', content: 'hi' }],+ tools: [{ name: 'echo', description: 'echo', parameters: {} }],+ })+ .catch((err: unknown) => {+ thrown.push(err)+ throw err+ })+ )+ const fallbackBuild = vi.fn(() => () => Promise.resolve('fallback-served'))+ const e = engine()++ const failure = await e+ .run(PRIMARY, t => (t.kind === 'primary' ? call : fallbackBuild()), classify)+ .catch((err: unknown) => err)++ // Liveness witness: the primary ran once and really reached the proxy.+ expect(call).toHaveBeenCalledTimes(1)+ expect(stream).toHaveBeenCalledTimes(1)+ expect(thrown).toHaveLength(1)+ expect(failure).toBe(thrown[0])+ expect(failure).toBeInstanceOf(LlmError)+ expect(failure).toMatchObject({+ code: LlmErrorCode.ToolCallLimitExceeded,+ retryable: false,+ })+ expect(fallbackBuild).not.toHaveBeenCalled()+ expect(metricInc).not.toHaveBeenCalled()+ })})it('is sticky: while cooling, the next call starts at the fallback (no primary retry)', async () => {