Skip to content

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

TypeScript

test(mcp-host,desktop): require control_plane_unavailable to read as its own retryable code

Alfredo Lopez55d7b128147d
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.tsx
index a0f2cb4af..2c2a2ad37 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
@@ -154,6 +154,15 @@ describe('ChatThread error code labels', () => {
expect(renderErrorLabel('LLM_MODEL_OVERLOADED').label).toBe('Model Overloaded')
})
+ // G1-8 (#720): the Host reports a control plane that did not answer with its
+ // own code, so the user does not read it as a model or network failure.
+ it('labels a control-plane outage as "Control Plane Unavailable"', () => {
+ const { label, text } = renderErrorLabel('LLM_CONTROL_PLANE_UNAVAILABLE', 'codex-subscription')
+ expect(label).toBe('Control Plane Unavailable · CODEX-SUBSCRIPTION')
+ expect(text).not.toContain('Model Overloaded')
+ expect(text).not.toContain('Connection Error')
+ })
+
it('keeps the generic "Error" label for an unknown code', () => {
expect(renderErrorLabel('LLM_SOMETHING_UNMAPPED').label).toBe('Error')
})
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index d36460e4b..126c0d67a 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.444",
+ "version": "0.1.445",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.444",
+ "version": "0.1.445",
"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 f850f608b..e189791ca 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.444",
+ "version": "0.1.445",
"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__/codexLlmProxyClient.test.ts b/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts
index 0c86a6d5e..471696e94 100644
--- a/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts
+++ b/mcp-host/src/llm/__tests__/codexLlmProxyClient.test.ts
@@ -12,6 +12,7 @@ import {
} from '../codexLlmProxyClient'
import { CodexSubscriptionProvider } from '../codexSubscription'
import { classifyFailoverClass } from '../failover/classify'
+import { CodexAuthorizeError } from '../providerAttemptAuthorizer'
import { closedPortUrl, fetchFailure, silentServer } from './connectFailureFixtures'
function sse(frames: unknown[]): ReadableStream<Uint8Array> {
@@ -799,3 +800,94 @@ describe('CodexLlmProxyClient control-plane reachability', () => {
expect(fetchFn).toHaveBeenCalledTimes(1)
})
})
+
+// G1-8 (#720): the classifier's answer for the two codes G1 adds on the wire.
+describe('CodexSubscriptionProvider G1 classification', () => {
+ const provider = new CodexSubscriptionProvider('gpt-5.3-codex', {} as never)
+
+ async function proxyReply(response: Response): Promise<unknown> {
+ const fetchFn = vi.fn<typeof fetch>(async () => response)
+ const err = await new CodexLlmProxyClient({
+ runtimeUrl: 'http://proxy/completions',
+ readPlatformJwt: () => 'platform-jwt',
+ fetchFn,
+ })
+ .stream({ executionTicket: 'ticket-123456', requestHash: 'a'.repeat(64), request: {} })
+ .catch((caught: unknown) => caught)
+ // Liveness witness: the proxy hop ran.
+ expect(fetchFn).toHaveBeenCalledTimes(1)
+ return err
+ }
+
+ it('G1-8a keeps an upstream 4xx terminal with no failover', async () => {
+ const err = await proxyReply(Response.json({ error: 'upstream_rejected' }, { status: 502 }))
+ const classified = provider.classifyError(err)
+ expect(classified).toMatchObject({
+ code: LlmErrorCode.ApiCallFailed,
+ retryable: false,
+ providerCode: 'upstream_rejected',
+ providerDispatched: true,
+ })
+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()
+ })
+
+ it('G1-8b labels a gateway control_plane_unavailable reply as a control-plane outage', async () => {
+ const err = await proxyReply(
+ Response.json({ error: 'control_plane_unavailable' }, { status: 503 })
+ )
+ const classified = provider.classifyError(err)
+ expect(LlmErrorCode.ControlPlaneUnavailable).toBe('LLM_CONTROL_PLANE_UNAVAILABLE')
+ expect(classified).toMatchObject({
+ code: LlmErrorCode.ControlPlaneUnavailable,
+ retryable: true,
+ providerCode: 'control_plane_unavailable',
+ providerDispatched: true,
+ })
+ // Same failover class as the outage label it replaces.
+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBe(
+ 'provider_unavailable'
+ )
+ })
+
+ it('G1-8b labels a refused proxy connection as a control-plane outage', async () => {
+ const url = await closedPortUrl()
+ const err = await new CodexLlmProxyClient({
+ runtimeUrl: resolveCodexProxyRuntimeUrl(url),
+ readPlatformJwt: () => 'platform-jwt',
+ })
+ .stream({ executionTicket: 'ticket-123456', requestHash: 'a'.repeat(64), request: {} })
+ .catch((caught: unknown) => caught)
+ expect(err).toMatchObject({ code: 'control_plane_unavailable' })
+ expect(provider.classifyError(err)).toMatchObject({
+ code: LlmErrorCode.ControlPlaneUnavailable,
+ retryable: true,
+ providerCode: 'control_plane_unavailable',
+ })
+ })
+
+ it('G1-8b labels an authorize that reached no gateway as a control-plane outage, not dispatched', () => {
+ const classified = provider.classifyError(
+ new CodexAuthorizeError(
+ 'control_plane_unavailable',
+ 'authorize could not reach the control plane (ECONNREFUSED)'
+ )
+ )
+ expect(classified).toMatchObject({
+ code: LlmErrorCode.ControlPlaneUnavailable,
+ retryable: true,
+ providerCode: 'control_plane_unavailable',
+ providerDispatched: false,
+ })
+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBe(
+ 'provider_unavailable'
+ )
+ })
+
+ it('G1-8c still labels provider_unavailable as an overload', async () => {
+ const err = await proxyReply(Response.json({ error: 'provider_unavailable' }, { status: 503 }))
+ expect(provider.classifyError(err)).toMatchObject({
+ code: LlmErrorCode.ModelOverloaded,
+ retryable: true,
+ })
+ })
+})
diff --git a/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts b/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts
index 4920c4d79..588f306fd 100644
--- a/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts
+++ b/mcp-host/src/llm/__tests__/grokLlmProxyClient.test.ts
@@ -8,6 +8,7 @@ import {
resolveGrokProxyRuntimeUrl,
} from '../grokLlmProxyClient'
import { GrokSubscriptionProvider } from '../grokSubscription'
+import { CodexAuthorizeError } from '../providerAttemptAuthorizer'
import { closedPortUrl, fetchFailure, silentServer } from './connectFailureFixtures'
const RUNTIME_BASE = 'http://grok-llm-proxy.control-plane.svc.cluster.local:8080'
@@ -699,3 +700,94 @@ describe('GrokLlmProxyClient control-plane reachability', () => {
expect(fetchFn).toHaveBeenCalledTimes(1)
})
})
+
+// G1-8 (#720): the classifier's answer for the two codes G1 adds on the wire.
+describe('GrokSubscriptionProvider G1 classification', () => {
+ const provider = new GrokSubscriptionProvider('grok-4.6', {} as never)
+
+ async function proxyReply(response: Response): Promise<unknown> {
+ const fetchFn = vi.fn<typeof fetch>(async () => response)
+ const err = await new GrokLlmProxyClient({
+ runtimeUrl: resolveGrokProxyRuntimeUrl(RUNTIME_BASE),
+ readPlatformJwt: () => 'platform-jwt',
+ fetchFn,
+ })
+ .stream({ executionTicket: 'ticket-123456', requestHash: 'a'.repeat(64), request: {} })
+ .catch((caught: unknown) => caught)
+ // Liveness witness: the proxy hop ran.
+ expect(fetchFn).toHaveBeenCalledTimes(1)
+ return err
+ }
+
+ it('G1-8a keeps an upstream 4xx terminal with no failover', async () => {
+ const err = await proxyReply(Response.json({ error: 'upstream_rejected' }, { status: 502 }))
+ const classified = provider.classifyError(err)
+ expect(classified).toMatchObject({
+ code: LlmErrorCode.ApiCallFailed,
+ retryable: false,
+ providerCode: 'upstream_rejected',
+ providerDispatched: true,
+ })
+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBeNull()
+ })
+
+ it('G1-8b labels a gateway control_plane_unavailable reply as a control-plane outage', async () => {
+ const err = await proxyReply(
+ Response.json({ error: 'control_plane_unavailable' }, { status: 503 })
+ )
+ const classified = provider.classifyError(err)
+ expect(LlmErrorCode.ControlPlaneUnavailable).toBe('LLM_CONTROL_PLANE_UNAVAILABLE')
+ expect(classified).toMatchObject({
+ code: LlmErrorCode.ControlPlaneUnavailable,
+ retryable: true,
+ providerCode: 'control_plane_unavailable',
+ providerDispatched: true,
+ })
+ // Same failover class as the outage label it replaces.
+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBe(
+ 'provider_unavailable'
+ )
+ })
+
+ it('G1-8b labels a refused proxy connection as a control-plane outage', async () => {
+ const url = await closedPortUrl()
+ const err = await new GrokLlmProxyClient({
+ runtimeUrl: resolveGrokProxyRuntimeUrl(url),
+ readPlatformJwt: () => 'platform-jwt',
+ })
+ .stream({ executionTicket: 'ticket-123456', requestHash: 'a'.repeat(64), request: {} })
+ .catch((caught: unknown) => caught)
+ expect(err).toMatchObject({ code: 'control_plane_unavailable' })
+ expect(provider.classifyError(err)).toMatchObject({
+ code: LlmErrorCode.ControlPlaneUnavailable,
+ retryable: true,
+ providerCode: 'control_plane_unavailable',
+ })
+ })
+
+ it('G1-8b labels an authorize that reached no gateway as a control-plane outage, not dispatched', () => {
+ const classified = provider.classifyError(
+ new CodexAuthorizeError(
+ 'control_plane_unavailable',
+ 'authorize could not reach the control plane (ECONNREFUSED)'
+ )
+ )
+ expect(classified).toMatchObject({
+ code: LlmErrorCode.ControlPlaneUnavailable,
+ retryable: true,
+ providerCode: 'control_plane_unavailable',
+ providerDispatched: false,
+ })
+ expect(classifyFailoverClass(classified.code, classified.retryable)).toBe(
+ 'provider_unavailable'
+ )
+ })
+
+ it('G1-8c still labels provider_unavailable as an overload', async () => {
+ const err = await proxyReply(Response.json({ error: 'provider_unavailable' }, { status: 503 }))
+ expect(provider.classifyError(err)).toMatchObject({
+ code: LlmErrorCode.ModelOverloaded,
+ retryable: true,
+ })
+ })
+})
diff --git a/mcp-host/src/llm/failover/__tests__/classify.test.ts b/mcp-host/src/llm/failover/__tests__/classify.test.ts
index 7f88f812c..52f248793 100644
--- a/mcp-host/src/llm/failover/__tests__/classify.test.ts
+++ b/mcp-host/src/llm/failover/__tests__/classify.test.ts
@@ -10,6 +10,16 @@ describe('classifyFailoverClass', () => {
expect(classifyFailoverClass(LlmErrorCode.ModelOverloaded, true)).toBe('provider_unavailable')
})
+ // G1-8 (#720): a control-plane outage keeps the failover class of the
+ // overload label it replaces; only the label changes.
+ it('G1-8d maps a control-plane outage to provider_unavailable', () => {
+ expect(classifyFailoverClass(LlmErrorCode.ControlPlaneUnavailable, true)).toBe(
+ 'provider_unavailable'
+ )
+ // Witness: the overload it replaces maps to the same class.
+ expect(classifyFailoverClass(LlmErrorCode.ModelOverloaded, true)).toBe('provider_unavailable')
+ })
+
it('ApiCallFailed is provider_unavailable ONLY when retryable', () => {
expect(classifyFailoverClass(LlmErrorCode.ApiCallFailed, true)).toBe('provider_unavailable')
// 400 / validation / content-policy — never eligible (would mask bugs).