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

fix: clear escalation dedupe marker when task creation fails (#2342)

Adam Eivy7832b7114392
diff --git a/server/services/autoFixer.js b/server/services/autoFixer.js
index e36e57ec18..050ccece3e 100644
--- a/server/services/autoFixer.js
+++ b/server/services/autoFixer.js
@@ -353,7 +353,14 @@ export async function escalateProviderFailure(error) {
console.log(`🔌 Auto-fix circuit OPEN for ${ctx.provider} (${ctx.model}) — suppressing escalated investigation task`);
return null;
}
- return createAIProviderInvestigationTask(error);
+ // Clear the dedupe marker if task creation fails so an identical escalation
+ // isn't suppressed for the window (mirrors the deferred path's catch arm) —
+ // otherwise an addTask rejection would silently swallow every retry for 60s.
+ return createAIProviderInvestigationTask(error).catch((err) => {
+ escalatedKeys.delete(errorKey);
+ console.error(`❌ Escalated AI provider task creation failed: ${err.message}`);
+ return null;
+ });
}
/**
diff --git a/server/services/autoFixer.test.js b/server/services/autoFixer.test.js
index c5e76bce1f..fd50d0898d 100644
--- a/server/services/autoFixer.test.js
+++ b/server/services/autoFixer.test.js
@@ -677,3 +677,36 @@ describe('autoFixer — escalateProviderFailure (explicit Tier-4, issue #2342)',
}
});
});
+
+describe('autoFixer — escalateProviderFailure dedupe clears on task-creation failure (#2342)', () => {
+ beforeEach(() => {
+ cos.addTask.mockReset();
+ cos.isRunning.mockReturnValue(true);
+ _resetAutoFixerForTests();
+ });
+ afterEach(() => {
+ cos.addTask.mockReset();
+ cos.addTask.mockResolvedValue({ id: 'task-1' });
+ _resetAutoFixerForTests();
+ });
+
+ it('does not suppress a retry when the escalated task creation fails', async () => {
+ const err = {
+ code: 'AI_PROVIDER_EXECUTION_FAILED',
+ message: 'AI provider Ollama execution failed: model gone',
+ timestamp: Date.now(),
+ context: { provider: 'Ollama', providerId: 'ollama', model: 'command-r', errorDetails: 'model gone', errorAnalysis: { category: 'model-not-found' } },
+ };
+ // First escalation: addTask rejects → dedupe marker must be cleared.
+ cos.addTask.mockRejectedValueOnce(new Error('plan write failed'));
+ const first = await (await import('./autoFixer.js')).escalateProviderFailure(err);
+ expect(first).toBeNull();
+
+ // Second identical escalation within the window must NOT be deduped — it
+ // creates the task the failed first attempt never did.
+ cos.addTask.mockResolvedValueOnce({ id: 'task-ok' });
+ const second = await (await import('./autoFixer.js')).escalateProviderFailure(err);
+ expect(second).toBeTruthy();
+ expect(cos.addTask).toHaveBeenCalledTimes(2);
+ });
+});