Skip to content

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

TypeScript

fix(plugin-sdk): preserve provider unavailable status

Alfredo Lopez28db727d1ed2
diff --git a/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts b/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts
index ab3977eb0..cb9d126d9 100644
--- a/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts
+++ b/mcp-host/src/pluginWorkloadSdk/promptBridge/llmBridge.failover.test.ts
@@ -114,6 +114,27 @@ describe('LlmBridge authorized multi-provider fallback', () => {
})
})
+ it('stops after every authorized target has an eligible failure', async () => {
+ const first = new FakeProvider(() => Promise.reject(new Error('primary unavailable')))
+ const second = new FakeProvider(() => Promise.reject(new Error('fallback unavailable')))
+ const { bridge, providerCalls, credentialCalls } = makeBridge({
+ [primary.model]: first,
+ [fallback.model]: second,
+ })
+
+ await expect(bridge.complete(request)).rejects.toMatchObject({
+ code: 'provider_unavailable',
+ retryable: true,
+ reason: 'rate_limited',
+ })
+ expect(credentialCalls).toEqual([primary.targetRef, fallback.targetRef])
+ expect(providerCalls).toEqual([
+ `${primary.provider}/${primary.model}`,
+ `${fallback.provider}/${fallback.model}`,
+ ])
+ expect(JSON.stringify(providerCalls)).not.toContain('secret-')
+ })
+
it('treats credential resolution failure as terminal and never redeems a fallback', async () => {
const resolve = vi.fn(async () => {
throw new PluginWorkloadError(
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 1748c4b47..6a6efd48d 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.258",
+ "version": "0.1.259",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.258",
+ "version": "0.1.259",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
diff --git a/workflow-recipes/package.json b/workflow-recipes/package.json
index 1a2ff461c..ec26fe442 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.258",
+ "version": "0.1.259",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.test.ts b/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.test.ts
index 54ff86acc..f11edd318 100644
--- a/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.test.ts
+++ b/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'
import type { PluginWorkloadSdkSpec, WorkflowRecipeSpec } from '../types'
import {
PLUGIN_WORKLOAD_SDK_CONDITION_TYPE,
+ PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE,
buildPluginWorkloadSdkStatus,
validatePluginWorkloadSdkSpec,
} from './pluginWorkloadSdkValidator'
@@ -298,6 +299,13 @@ describe('buildPluginWorkloadSdkStatus', () => {
message: 'Capability validated, but the configured provider is unavailable',
lastTransitionTime: NOW,
},
+ {
+ type: PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE,
+ status: 'True',
+ reason: 'ProviderUnavailable',
+ message: 'Capability validated, but the configured provider is unavailable',
+ lastTransitionTime: NOW,
+ },
])
expect(projection.capability).toEqual({
state: 'degraded',
diff --git a/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.ts b/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.ts
index 2c724d781..79e69d3f0 100644
--- a/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.ts
+++ b/workflow-recipes/src/reconciler/pluginWorkloadSdkValidator.ts
@@ -223,6 +223,13 @@ export function buildPluginWorkloadSdkStatus(args: {
message,
lastTransitionTime: now,
},
+ {
+ type: PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE,
+ status: 'True',
+ reason: 'ProviderUnavailable',
+ message,
+ lastTransitionTime: now,
+ },
],
capability: {
state: 'degraded',
diff --git a/workflow-recipes/src/reconciler/reconciler.test.ts b/workflow-recipes/src/reconciler/reconciler.test.ts
index 1f3495515..a0d2fdaf5 100644
--- a/workflow-recipes/src/reconciler/reconciler.test.ts
+++ b/workflow-recipes/src/reconciler/reconciler.test.ts
@@ -9,6 +9,7 @@ import { INHERITED_PARENT_RESOURCES_ANNOTATION } from '../workflow/childRecipeFa
import { buildCoordinatorGfsNetworkPolicy } from '../workflow/networkPolicyFactory'
import { isRetryableInfraError } from './k8sErrors'
import * as brokerIssuer from './oauthBrokerTokenIssuerClient'
+import { PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE } from './pluginWorkloadSdkValidator'
import {
resolveResourceName,
resolveScopedStatefulSetResourceName,
@@ -1382,6 +1383,73 @@ describe('WorkflowRecipeReconciler', () => {
])
})
+ it('replaces and clears the SDK provider-unavailable condition on recovery', async () => {
+ ;(
+ reconciler as unknown as { config: { pluginWorkloadSdkEnabled: boolean } }
+ ).config.pluginWorkloadSdkEnabled = true
+ const recipe = makeRecipe({
+ spec: {
+ agent: { provider: 'zai', model: 'glm-4.7' },
+ workloads: [{ id: 'app', type: 'deployment', image: 'nginx:1.30.1-alpine', port: 8080 }],
+ pluginWorkloadSdk: { promptBridge: {}, allowedCallers: ['app'] },
+ },
+ status: {
+ phase: 'degraded',
+ conditions: [
+ {
+ type: PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE,
+ status: 'True',
+ reason: 'ProviderUnavailable',
+ lastTransitionTime: 'old',
+ },
+ ],
+ },
+ })
+
+ await reconciler.patchStatus(recipe, {
+ phase: 'degraded',
+ message: 'configured provider unavailable',
+ workloadStatuses: [],
+ pluginWorkloadSdkProviderUnavailable: true,
+ })
+ const degradedPatch = mockCustomApi.patchNamespacedCustomObjectStatus.mock.calls.at(-1)![0].body
+ expect(
+ degradedPatch.status.conditions.filter(
+ (condition: { type: string }) =>
+ condition.type === PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE
+ )
+ ).toHaveLength(1)
+
+ mockCustomApi.patchNamespacedCustomObjectStatus.mockClear()
+ const recoveredRecipe: WorkflowRecipeCRD = {
+ ...recipe,
+ status: { phase: 'degraded', conditions: degradedPatch.status.conditions },
+ }
+ await reconciler.patchStatus(recoveredRecipe, {
+ phase: 'active',
+ message: 'All workloads deployed',
+ workloadStatuses: [],
+ pluginWorkloadSdkProviderUnavailable: false,
+ })
+ const recoveredPatch =
+ mockCustomApi.patchNamespacedCustomObjectStatus.mock.calls.at(-1)![0].body
+ expect(
+ recoveredPatch.status.conditions.some(
+ (condition: { type: string }) =>
+ condition.type === PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE
+ )
+ ).toBe(false)
+ expect(recoveredPatch.status.conditions).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ type: 'PluginWorkloadSdkCapability',
+ status: 'True',
+ reason: 'Validated',
+ }),
+ ])
+ )
+ })
+
it('prunes only selected stale internal-dependency policies when none are desired', async () => {
mockNetworkingApi.listNamespacedNetworkPolicy.mockImplementation(
({ namespace }: { namespace: string }) =>
diff --git a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
index c524a7da7..17f2cab90 100644
--- a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
+++ b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
@@ -237,7 +237,10 @@ function mergeSecretOwnershipConditions(
return mergeOwnedConditions(existing, fresh, SECRET_OWNERSHIP_CONDITION_TYPES)
}
-const PLUGIN_WORKLOAD_SDK_CONDITION_TYPES = new Set([PLUGIN_WORKLOAD_SDK_CONDITION_TYPE])
+const PLUGIN_WORKLOAD_SDK_CONDITION_TYPES = new Set([
+ PLUGIN_WORKLOAD_SDK_CONDITION_TYPE,
+ PLUGIN_WORKLOAD_SDK_PROVIDER_UNAVAILABLE_CONDITION_TYPE,
+])
function mergePluginWorkloadSdkConditions(
existing: StatusCondition[] | undefined,