Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(mcp-host): a retryable control_plane_unavailable takes the loop transport retry (#720)
Alfredo Lopez147ad3cde2d7
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 9df8f174f..4b5e9b166 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.457",+ "version": "0.1.458","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.457",+ "version": "0.1.458","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex 73cacef6e..49e037a8e 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.457",+ "version": "0.1.458","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/core/orchestration/__tests__/toolUseLoop.llmTransportRetry.test.ts b/mcp-host/src/core/orchestration/__tests__/toolUseLoop.llmTransportRetry.test.tsindex 605ae0db6..c6d5ee489 100644--- a/mcp-host/src/core/orchestration/__tests__/toolUseLoop.llmTransportRetry.test.ts+++ b/mcp-host/src/core/orchestration/__tests__/toolUseLoop.llmTransportRetry.test.ts@@ -15,6 +15,20 @@ function retryableRateLimitError(): LlmError {return new LlmError('rate limited', 'zai', LlmErrorCode.RateLimited, true)}+// What codexSubscription's classifier builds for a proxy connect-phase failure+// (hop H4) or a gateway's control_plane_unavailable reply (hops H2/H3).+function controlPlaneUnavailableError(retryable: boolean): LlmError {+ return new LlmError(+ 'proxy could not be reached (ECONNREFUSED)',+ 'codex-subscription',+ LlmErrorCode.ControlPlaneUnavailable,+ retryable,+ undefined,+ undefined,+ 'control_plane_unavailable'+ )+}+describe('runToolUseLoop LLM transport retry', () => {it('retries a retryable transport failure once before surfacing a response', async () => {const reasoning = createMockReasoning([@@ -31,6 +45,37 @@ describe('runToolUseLoop LLM transport retry', () => {expect(reasoning.continueWithToolResults).not.toHaveBeenCalled()})+ // Review round 2 M4 (#720): on dev a refused proxy connect was a retryable+ // ApiCallFailed and took this retry; relabelling it must not drop it.+ it('G1-12a retries a retryable control_plane_unavailable once like a transport failure', async () => {+ const reasoning = createMockReasoning([+ { type: 'error', error: controlPlaneUnavailableError(true) },+ { type: 'text', content: 'Here are the workflow recipes you can run.' },+ ])+ const result = await runToolUseLoop(buildTestConfig(reasoning, []), [+ { role: 'user', content: 'What workflow recipes can I run?' },+ ])++ expect(result.type).toBe('response')+ if (result.type === 'response') expect(result.content).toContain('workflow recipes')+ expect(reasoning.respondWithTools).toHaveBeenCalledTimes(2)+ })++ it('G1-12b does not retry a control_plane_unavailable that is not retryable', async () => {+ const reasoning = createMockReasoning([+ { type: 'error', error: controlPlaneUnavailableError(false) },+ { type: 'text', content: 'never reached' },+ ])+ const result = await runToolUseLoop(buildTestConfig(reasoning, []), [+ { role: 'user', content: 'hello' },+ ])++ expect(result.type).toBe('error')+ if (result.type === 'error') expect(result.error.message).toContain('could not be reached')+ // Witness: the loop did call the model and surfaced this error.+ expect(reasoning.respondWithTools).toHaveBeenCalledTimes(1)+ })+it('does not retry retryable non-transport LLM failures', async () => {const reasoning = createMockReasoning([{ type: 'error', error: retryableRateLimitError() }])const result = await runToolUseLoop(buildTestConfig(reasoning, []), [