Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): classify Codex tool-call and history limits as non-retryable
Alfredo Lopez7d2bc2cfb964
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 98cae4676..39932e385 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.347",+ "version": "0.1.348","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.347",+ "version": "0.1.348","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 8aa4e44c6..a1811749e 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.347",+ "version": "0.1.348","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/agent/__tests__/taskExecutor.test.ts b/mcp-host/src/agent/__tests__/taskExecutor.test.tsindex b7a617a22..c35796759 100644--- a/mcp-host/src/agent/__tests__/taskExecutor.test.ts+++ b/mcp-host/src/agent/__tests__/taskExecutor.test.ts@@ -1282,6 +1282,51 @@ describe('TaskExecutor error handling', () => {})})+ it.each([+ [LlmErrorCode.ToolCallLimitExceeded, 'LLM_TOOL_CALL_LIMIT_EXCEEDED', false],+ // Witness: the same path keeps an existing provider code unchanged.+ [LlmErrorCode.ModelOverloaded, 'LLM_MODEL_OVERLOADED', true],+ ] as const)(+ 'keeps %s from a loop error result as the task error code',+ async (code, expected, retryable) => {+ const llmError = new LlmError(+ 'provider failure',+ 'codex-subscription',+ code,+ retryable,+ undefined,+ undefined,+ 'provider-code'+ )+ ;(runToolUseLoop as ReturnType<typeof vi.fn>).mockResolvedValueOnce({+ type: 'error',+ error: llmError,+ })++ const captured: TaskError[] = []+ const deps = createDeps({+ onFail: (_task: Task, err: TaskError) => {+ captured.push(err)+ },+ })+ const executor = new TaskExecutor(createTask('Hello'), deps)++ await executor.run()++ expect(runToolUseLoop).toHaveBeenCalledTimes(1)+ expect(captured).toEqual([+ {+ code: expected,+ message: 'provider failure',+ retryable,+ provider: 'codex-subscription',+ httpStatus: undefined,+ providerCode: 'provider-code',+ },+ ])+ }+ )+it('does NOT invoke responseCallback from the catch block', async () => {const llmError = new LlmError('err', 'openai', LlmErrorCode.ApiCallFailed, false);(runToolUseLoop as ReturnType<typeof vi.fn>).mockRejectedValueOnce(llmError)diff --git a/mcp-host/src/core/errors.ts b/mcp-host/src/core/errors.tsindex 7e7f61e94..2452ddba4 100644--- a/mcp-host/src/core/errors.ts+++ b/mcp-host/src/core/errors.ts@@ -30,6 +30,8 @@ export enum LlmErrorCode {RateLimited = 'LLM_RATE_LIMITED',AuthenticationFailed = 'LLM_AUTHENTICATION_FAILED',ModelOverloaded = 'LLM_MODEL_OVERLOADED',+ /** One model response asked for more tool calls than the provider contract allows. */+ ToolCallLimitExceeded = 'LLM_TOOL_CALL_LIMIT_EXCEEDED',}export class LlmError extends AgentError {diff --git a/mcp-host/src/core/orchestration/__tests__/toolUseLoop.toolCallLimit.test.ts b/mcp-host/src/core/orchestration/__tests__/toolUseLoop.toolCallLimit.test.tsnew file mode 100644index 000000000..da5ad4013--- /dev/null+++ b/mcp-host/src/core/orchestration/__tests__/toolUseLoop.toolCallLimit.test.ts@@ -0,0 +1,77 @@+import { describe, expect, it } from 'vitest'+import { LlmError, LlmErrorCode } from '../../errors'+import { runToolUseLoop } from '../toolUseLoop'+import {+ buildTestConfig,+ createMockReasoning,+ createMockTool,+} from './toolUseLoopRetryableTestUtils'++// A workflow tool result is the one case where a retryable LLM failure is+// turned into a synthesized reply, so it is the setup that could hide the+// tool-call limit behind a fallback response.+function workflowResultTool() {+ return createMockTool('workflow_result', {+ sanitize: false,+ output: JSON.stringify({+ workflowName: 'treasury-risk-review',+ result: { artifactProof: 'artifact-output-treasury-risk-review-680' },+ }),+ })+}++function reasoningFailingAfterToolResults(error: LlmError) {+ return createMockReasoning([+ {+ type: 'tool_calls',+ calls: [{ id: 'tc_1', name: 'workflow_result', arguments: { name: 'treasury-risk-review' } }],+ },+ { type: 'error', error },+ { type: 'text', content: 'a second LLM call must not happen' },+ ])+}++describe('runToolUseLoop tool-call limit', () => {+ it('ends the loop with LLM_TOOL_CALL_LIMIT_EXCEEDED and no workflow fallback', async () => {+ const limit = new LlmError(+ 'tool calls exceed 64',+ 'codex-subscription',+ LlmErrorCode.ToolCallLimitExceeded,+ false+ )+ const reasoning = reasoningFailingAfterToolResults(limit)+ const tool = workflowResultTool()++ const result = await runToolUseLoop(buildTestConfig(reasoning, [tool]), [+ { role: 'user', content: 'Show me the workflow result artifact for treasury-risk-review.' },+ ])++ // Liveness witness: the tool ran and exactly one LLM call followed its result.+ expect(tool.execute).toHaveBeenCalledTimes(1)+ expect(reasoning.respondWithTools).toHaveBeenCalledTimes(1)+ expect(reasoning.continueWithToolResults).toHaveBeenCalledTimes(1)+ expect(result.type).toBe('error')+ if (result.type !== 'error') throw new Error(`expected an error result, got ${result.type}`)+ expect(result.error).toBe(limit)+ expect((result.error as LlmError).code).toBe('LLM_TOOL_CALL_LIMIT_EXCEEDED')+ })++ it('still synthesizes the workflow fallback for a retryable overload (fallback path witness)', async () => {+ const overload = new LlmError(+ 'provider unavailable',+ 'codex-subscription',+ LlmErrorCode.ModelOverloaded,+ true+ )+ const reasoning = reasoningFailingAfterToolResults(overload)++ const result = await runToolUseLoop(buildTestConfig(reasoning, [workflowResultTool()]), [+ { role: 'user', content: 'Show me the workflow result artifact for treasury-risk-review.' },+ ])++ expect(reasoning.continueWithToolResults).toHaveBeenCalledTimes(1)+ expect(result.type).toBe('response')+ if (result.type !== 'response') throw new Error(`expected a response, got ${result.type}`)+ expect(result.content).toContain('artifact-output-treasury-risk-review-680')+ })+})diff --git a/mcp-host/src/llm/__tests__/codexSubscription.test.ts b/mcp-host/src/llm/__tests__/codexSubscription.test.tsindex 54374b05c..99e3cce7e 100644--- a/mcp-host/src/llm/__tests__/codexSubscription.test.ts+++ b/mcp-host/src/llm/__tests__/codexSubscription.test.ts@@ -6,7 +6,8 @@ import {createToolDescribeTool,createToolSearchTool,} from '../../capabilities/toolCatalogTools'-import { LlmErrorCode } from '../../core/errors'+import { LlmPortAdapter } from '../../core/adapters/llmPortAdapter'+import { LlmError, LlmErrorCode } from '../../core/errors'import { DeferrableToolController } from '../../core/orchestration/deferrableToolController'import { DefaultLoopController } from '../../core/orchestration/loopConfig'import { CodexProxyError } from '../codexLlmProxyClient'@@ -69,25 +70,92 @@ describe('CodexSubscriptionProvider', () => {).rejects.toThrow(/successful terminal outcome/)})- it('rejects an oversized successful proxy batch before returning any executable tools', async () => {- const wired = deps({+ function successfulBatch(count: number) {+ return deps({stream: vi.fn().mockResolvedValue({text: '',outcome: 'success',- toolCalls: Array.from({ length: 33 }, (_, index) => ({+ toolCalls: Array.from({ length: count }, (_, index) => ({id: `call-${index}`,name: 'echo',arguments: {},})),}),})+ }++ it('returns a successful proxy batch of exactly 64 tool calls', async () => {+ const wired = successfulBatch(64)+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)+ const result = await provider.completeSingleTurnWithTools(+ [{ role: 'user', content: 'hi' }],+ [{ name: 'echo', description: 'echo', parameters: {} }]+ )+ expect(result.tool_calls).toHaveLength(64)+ })++ it('rejects a 65-call proxy batch with tool_call_limit_exceeded before returning any executable tools', async () => {+ const wired = successfulBatch(65)const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)await expect(provider.completeSingleTurnWithTools([{ role: 'user', content: 'hi' }],[{ name: 'echo', description: 'echo', parameters: {} }])- ).rejects.toThrow(/tool calls exceed 32/)+ ).rejects.toMatchObject({+ name: 'CodexProxyError',+ code: 'tool_call_limit_exceeded',+ message: 'tool calls exceed 64',+ })+ // Liveness witness: the batch really came back from the proxy.+ expect(wired.stream).toHaveBeenCalledTimes(1)+ })++ it('surfaces a 65-call stream through the port adapter as a non-retryable LlmError', async () => {+ const wired = successfulBatch(65)+ const adapter = new LlmPortAdapter(+ new CodexSubscriptionProvider('gpt-5.3-codex', wired as never),+ 'gpt-5.3-codex',+ 'codex-subscription'+ )+ const failure = await adapter+ .completeWithTools({+ messages: [{ role: 'user', content: 'hi' }],+ tools: [{ name: 'echo', description: 'echo', parameters: {} }],+ })+ .catch((err: unknown) => err)++ expect(wired.stream).toHaveBeenCalledTimes(1)+ expect(failure).toBeInstanceOf(LlmError)+ expect(failure).toMatchObject({+ code: 'LLM_TOOL_CALL_LIMIT_EXCEEDED',+ retryable: false,+ providerCode: 'tool_call_limit_exceeded',+ })+ })++ it('rejects more than 256 messages before authorize or dispatch', async () => {+ const wired = deps()+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', wired as never)+ const history = (count: number) =>+ Array.from({ length: count }, (_, index) => ({+ role: 'user' as const,+ content: `message ${index}`,+ }))++ const rejected = provider.completeSingleTurn(history(257))+ await expect(rejected).rejects.toBeInstanceOf(CodexAuthorizeError)+ await expect(rejected).rejects.toMatchObject({+ code: 'request_limit_exceeded',+ message: 'messages exceed 256',+ })+ expect(wired.authorize).not.toHaveBeenCalled()+ expect(wired.stream).not.toHaveBeenCalled()++ // Liveness witness: at the limit the same provider authorizes and streams.+ await provider.completeSingleTurn(history(256))+ 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'@@ -414,6 +482,41 @@ describe('CodexSubscriptionProvider', () => {expect(classifyFailoverClass(limited.code, limited.retryable)).toBe('rate_limited')})+ it('classifies request limits as non-retryable, non-failover errors', () => {+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', deps() as never)++ const toolLimit = provider.classifyError(+ new CodexProxyError('tool_call_limit_exceeded', 'tool calls exceed 64')+ )+ expect(toolLimit).toEqual({+ code: LlmErrorCode.ToolCallLimitExceeded,+ retryable: false,+ message: 'tool calls exceed 64',+ providerCode: 'tool_call_limit_exceeded',+ providerDispatched: true,+ })+ expect(classifyFailoverClass(toolLimit.code, toolLimit.retryable)).toBeNull()++ const history = provider.classifyError(+ new CodexAuthorizeError('request_limit_exceeded', 'messages exceed 256')+ )+ expect(history).toEqual({+ code: LlmErrorCode.ContextLengthExceeded,+ retryable: false,+ message: 'messages exceed 256',+ providerCode: 'request_limit_exceeded',+ providerDispatched: false,+ })+ expect(classifyFailoverClass(history.code, history.retryable)).toBeNull()++ // Witness: the new branches leave the outage mapping untouched.+ const unavailable = provider.classifyError(+ new CodexProxyError('provider_unavailable', 'upstream 5xx')+ )+ expect(unavailable.code).toBe(LlmErrorCode.ModelOverloaded)+ expect(unavailable.retryable).toBe(true)+ })+it('records whether a classified Codex failure had already left the process', () => {const provider = new CodexSubscriptionProvider('gpt-5.3-codex', deps() as never)diff --git a/mcp-host/src/llm/codexSubscription.ts b/mcp-host/src/llm/codexSubscription.tsindex 20d85c5f1..2dc4e5508 100644--- a/mcp-host/src/llm/codexSubscription.ts+++ b/mcp-host/src/llm/codexSubscription.ts@@ -68,7 +68,11 @@ function assertTerminalCodexOutcome(result: {outcome: 'success' | 'canceled' | 'error' | 'unknown'}): void {if (result.toolCalls.length > LIMITS.maxToolCalls) {- throw new CodexProxyError('provider_unavailable', `tool calls exceed ${LIMITS.maxToolCalls}`)+ // Defence in depth: codex-llm-proxy enforces the same limit first.+ throw new CodexProxyError(+ 'tool_call_limit_exceeded',+ `tool calls exceed ${LIMITS.maxToolCalls}`+ )}if (result.toolCalls.length > 0 && result.outcome !== 'success') {throw new CodexProxyError(@@ -173,6 +177,26 @@ export class CodexSubscriptionProvider implements SingleTurnProvider {...(providerDispatched !== undefined ? { providerDispatched } : {}),}}+ if (code === 'tool_call_limit_exceeded') {+ // The same request would produce the same over-limit response, so it is+ // neither retryable nor a reason to fail over to another provider.+ 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,@@ -258,6 +282,14 @@ export class CodexSubscriptionProvider implements SingleTurnProvider {// shapes the parser normalizes away (an empty `generation` from a// tool-name tool_choice, empty tools/hints) fail authorize with a// requestHash mismatch. An invalid request never leaves the process.+ // 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}`+ )+ }const canonical = hashCanonicalCodexRequest(this.buildRequest(messages, tools, options))if (!canonical.ok) {throw new CodexAuthorizeError('invalid_request', canonical.message)diff --git a/mcp-host/src/llm/failover/__tests__/classify.test.ts b/mcp-host/src/llm/failover/__tests__/classify.test.tsindex d0062a6f2..fbcad64fa 100644--- a/mcp-host/src/llm/failover/__tests__/classify.test.ts+++ b/mcp-host/src/llm/failover/__tests__/classify.test.ts@@ -23,6 +23,13 @@ describe('classifyFailoverClass', () => {expect(classifyFailoverClass(LlmErrorCode.ModelNotAvailable, false)).toBeNull()})+ it('never fails over a tool-call limit, whatever its retryable flag', () => {+ expect(classifyFailoverClass(LlmErrorCode.ToolCallLimitExceeded, false)).toBeNull()+ expect(classifyFailoverClass(LlmErrorCode.ToolCallLimitExceeded, true)).toBeNull()+ // Witness: the same classifier still switches on an outage.+ expect(classifyFailoverClass(LlmErrorCode.ModelOverloaded, true)).toBe('provider_unavailable')+ })+it('exports all four classes as the default triggerOn set', () => {expect([...ALL_FAILOVER_CLASSES].sort()).toEqual(['auth', 'insufficient_quota', 'provider_unavailable', 'rate_limited'].sort()diff --git a/mcp-host/src/llm/failover/__tests__/engine.test.ts b/mcp-host/src/llm/failover/__tests__/engine.test.tsindex cb88b6d45..b5fd5f0bc 100644--- a/mcp-host/src/llm/failover/__tests__/engine.test.ts+++ b/mcp-host/src/llm/failover/__tests__/engine.test.ts@@ -1,5 +1,8 @@import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'+import { LlmPortAdapter } from '../../../core/adapters/llmPortAdapter'import { LlmError, LlmErrorCode } from '../../../core/errors'+import { CodexProxyError } from '../../codexLlmProxyClient'+import { CodexSubscriptionProvider } from '../../codexSubscription'import { type ClassifiedLike, FailoverEngine } from '../engine'import type { FailoverSwitchEvent, LlmPolicy, ModelPair } from '../types'@@ -175,6 +178,115 @@ describe('FailoverEngine', () => {})})+ describe('Codex request limits', () => {+ // The primary runs the real Codex provider behind the port adapter, so the+ // error the engine sees is produced by CodexSubscriptionProvider.classifyError.+ function codexPrimary(stream: ReturnType<typeof vi.fn>) {+ const adapter = new LlmPortAdapter(+ new CodexSubscriptionProvider('gpt-5.3-codex', {+ 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),+ 'gpt-5.3-codex',+ 'codex-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+ })+ )+ return { call, thrown }+ }++ it('propagates a 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 primary = codexPrimary(stream)+ const fallbackBuild = vi.fn(() => () => Promise.resolve('fallback-served'))+ const e = engine()++ const failure = await e+ .run(PRIMARY, t => (t.kind === 'primary' ? primary.call : fallbackBuild()), classify)+ .catch((err: unknown) => err)++ // Liveness witness: the primary ran once and really reached the proxy.+ expect(primary.call).toHaveBeenCalledTimes(1)+ expect(stream).toHaveBeenCalledTimes(1)+ expect(primary.thrown).toHaveLength(1)+ expect(failure).toBe(primary.thrown[0])+ expect(failure).toBeInstanceOf(LlmError)+ expect(failure).toMatchObject({+ code: LlmErrorCode.ToolCallLimitExceeded,+ retryable: false,+ })+ expect(fallbackBuild).not.toHaveBeenCalled()+ expect(metricInc).not.toHaveBeenCalled()++ // No cooldown was set: the next call starts at the primary again.+ const nextPrimary = vi.fn(() => Promise.resolve('primary-again'))+ const next = await e.run(+ PRIMARY,+ t => (t.kind === 'primary' ? nextPrimary : () => Promise.resolve('fallback')),+ classify+ )+ expect(next).toBe('primary-again')+ expect(nextPrimary).toHaveBeenCalledTimes(1)+ })++ it('still fails over a Codex provider outage to the fallback', async () => {+ const stream = vi+ .fn()+ .mockRejectedValue(new CodexProxyError('provider_unavailable', 'upstream 5xx'))+ const primary = codexPrimary(stream)+ const e = engine()++ const res = await e.run(+ PRIMARY,+ t => (t.kind === 'primary' ? primary.call : () => Promise.resolve('fallback-served')),+ classify+ )++ expect(primary.call).toHaveBeenCalledTimes(1)+ expect(primary.thrown[0]).toMatchObject({+ code: LlmErrorCode.ModelOverloaded,+ retryable: true,+ })+ expect(res).toBe('fallback-served')+ expect(metricInc).toHaveBeenCalledWith({+ from: 'claude/claude-sonnet-4-6',+ to: 'openai/gpt-5.4',+ reason: 'provider_unavailable',+ })+ })+ })+it('is sticky: while cooling, the next call starts at the fallback (no primary retry)', async () => {const e = engine()// Call 1: primary fails eligibly → cooldown set, fallback serves.diff --git a/mcp-host/src/llm/failover/classify.ts b/mcp-host/src/llm/failover/classify.tsindex 62e50e72f..ca0e59571 100644--- a/mcp-host/src/llm/failover/classify.ts+++ b/mcp-host/src/llm/failover/classify.ts@@ -32,7 +32,7 @@ export const ALL_FAILOVER_CLASSES: readonly FailoverClass[] = [* - `ApiCallFailed ∧ !retryable` → null (400 / validation / content-policy —* never trigger; masking these would hide bugs)* - everything else (InvalidResponse, ContextLengthExceeded, ContentFiltered,- * ModelNotAvailable) → null+ * ModelNotAvailable, ToolCallLimitExceeded) → null*/export function classifyFailoverClass(code: LlmErrorCode,diff --git a/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts b/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.tsindex 584cad91a..e03d859d3 100644--- a/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts+++ b/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts@@ -345,6 +345,48 @@ describe('LlmBridge authorized multi-provider fallback', () => {expect(providerCalls).toEqual([`${primary.provider}/${primary.model}`])})+ it('does not fail over a tool-call limit, while an overload still does', async () => {+ const limited = new FakeProvider(() => Promise.reject(new Error('too many calls')), {+ code: LlmErrorCode.ToolCallLimitExceeded,+ retryable: false,+ providerCode: 'tool_call_limit_exceeded',+ providerDispatched: true,+ })+ const unusedFallback = new FakeProvider(() => Promise.resolve(OK))+ const limitRun = makeBridge({+ [primary.model]: limited,+ [fallback.model]: unusedFallback,+ })++ await expect(limitRun.bridge.complete(request)).rejects.toMatchObject({+ code: 'provider_unavailable',+ retryable: false,+ })+ expect(limited.completeSingleTurn).toHaveBeenCalledTimes(1)+ expect(limitRun.providerCalls).toEqual([`${primary.provider}/${primary.model}`])+ expect(unusedFallback.completeSingleTurn).not.toHaveBeenCalled()++ // Witness: the same bridge setup fails over an overloaded primary.+ const overloaded = new FakeProvider(() => Promise.reject(new Error('overloaded')), {+ code: LlmErrorCode.ModelOverloaded,+ retryable: true,+ })+ const servingFallback = new FakeProvider(() => Promise.resolve(OK))+ const overloadRun = makeBridge({+ [primary.model]: overloaded,+ [fallback.model]: servingFallback,+ })++ await expect(overloadRun.bridge.complete(request)).resolves.toMatchObject({+ servedTarget: fallback,+ fallbackUsed: true,+ })+ expect(overloadRun.providerCalls).toEqual([+ `${primary.provider}/${primary.model}`,+ `${fallback.provider}/${fallback.model}`,+ ])+ })+it('does not use auth failures as an implicit fallback trigger', async () => {const first = new FakeProvider(() => Promise.reject(new Error('401')), {code: LlmErrorCode.AuthenticationFailed,