Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex,claude): keep fallback-selected api providers retryable

[._.]/ Adam Eivyfe35e1321021
diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.js
index 30393d33a2..e313a5f088 100644
--- a/server/services/agentLifecycle.js
+++ b/server/services/agentLifecycle.js
@@ -298,16 +298,15 @@ export async function spawnAgentForTask(task) {
// to an agent task, which has no file-writing harness) fails identically on
// every re-dispatch. Leaving the task pending makes it silently re-fail
// forever AND wedge its app's single improvement slot. Block it with an
- // actionable reason so it stops re-dispatching and surfaces in the UI —
- // `...buildRelease()` keeps the federation claim cleared (cleanupOnError
- // released it in persistence; the in-memory metadata spread would otherwise
- // re-introduce it). Transient failures stay non-permanent and still retry.
+ // actionable reason so it stops re-dispatching and surfaces in the UI.
+ // updateTask strips the federation claim on any non-`in_progress` status
+ // change, so the block also frees the lease. Transient (non-permanent)
+ // failures fall through and stay pending to retry.
if (resolution.permanent) {
await updateTask(task.id, {
status: 'blocked',
metadata: {
...task.metadata,
- ...buildRelease(),
blockedReason: resolution.error,
blockedCategory: 'provider-config',
blockedAt: new Date().toISOString()
diff --git a/server/services/agentProviderResolution.js b/server/services/agentProviderResolution.js
index 104a919931..0bc3cfdd6e 100644
--- a/server/services/agentProviderResolution.js
+++ b/server/services/agentProviderResolution.js
@@ -56,6 +56,12 @@ export async function resolveAgentProviderAndModel(task) {
// Model" pin — it overrides the usual per-task model selection so the
// user's chosen fallback provider+model pair is honored on agent runs.
let fallbackModelPin = null;
+ // Whether `provider` below is a FALLBACK selection (the directly-resolved
+ // pinned/active provider was unavailable) rather than the provider the task
+ // actually asked for. It gates the "permanent" flag on the api-type rejection:
+ // a fallback-selected api provider is a TRANSIENT condition (the primary CLI
+ // provider may recover), so the task must stay retryable, not be blocked.
+ let usedFallback = false;
const providerAvailable = isProviderAvailable(provider.id);
if (!providerAvailable) {
const status = getProviderStatus(provider.id);
@@ -83,6 +89,7 @@ export async function resolveAgentProviderAndModel(task) {
});
provider = fallbackResult.provider;
fallbackModelPin = fallbackResult.model || null;
+ usedFallback = true;
} else {
const errorMsg = `Provider ${provider.id} unavailable (${status.message}) and no fallback available`;
return { ok: false, error: errorMsg, providerId: provider.id, providerStatus: status };
@@ -100,10 +107,14 @@ export async function resolveAgentProviderAndModel(task) {
if (provider.type === 'api') {
return {
ok: false,
- // PERMANENT config error: this resolves the same way on every re-dispatch
- // (an api provider is never gaining a harness), so the caller must retire
- // the task rather than leave it pending to silently re-fail forever.
- permanent: true,
+ // PERMANENT config error ONLY when this api provider was the directly-
+ // resolved (pinned or active) one — it resolves identically on every
+ // re-dispatch (an api provider never gains a harness), so the caller must
+ // retire the task rather than leave it silently re-failing forever. A
+ // fallback-selected api provider is instead TRANSIENT: the primary CLI
+ // provider that was momentarily unavailable may recover, so the task must
+ // stay retryable rather than be blocked (a blocked task is never retried).
+ permanent: !usedFallback,
error: `Provider "${provider.id}" is an HTTP API provider with no file-writing harness — CoS agent tasks need a CLI/TUI coding provider (claude, codex, or the "Claude Ollama" Claude-on-Ollama sample).`,
providerId: provider.id
};
diff --git a/server/services/agentProviderResolution.test.js b/server/services/agentProviderResolution.test.js
index d814ab4793..687ba54584 100644
--- a/server/services/agentProviderResolution.test.js
+++ b/server/services/agentProviderResolution.test.js
@@ -181,7 +181,9 @@ describe('resolveAgentProviderAndModel', () => {
expect(r.ok).toBe(false);
expect(r.providerId).toBe('lmstudio');
expect(r.error).toContain('no file-writing harness');
- expect(r.permanent).toBe(true);
+ // NOT permanent: the primary CLI provider was only momentarily unavailable
+ // and may recover, so the task must stay retryable rather than be blocked.
+ expect(r.permanent).toBe(false);
});
it('falls back to the provider tier default when the selected model is not in the provider model list', async () => {