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: preserve retry handling for failed recovered delivery

[._.]/ Adam Eivy24c4c0ddfa8c
diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.js
index eea165080c..4f75272499 100644
--- a/server/services/agentFinalization.js
+++ b/server/services/agentFinalization.js
@@ -1209,9 +1209,11 @@ export async function retireDeadAgent({ agent, task, success, exitCode, duration
const refused = ['content-refusal', 'content-filtered'].includes(interruption?.category);
const reportedOutcome = !isPrivateSecurity && !refused
? await persistCompletionSummary(agent.id, { workspacePath: agent.metadata?.workspacePath, existingRecord: agent }) : null;
- const reportedHold = ['blocked', 'incomplete'].includes(reportedOutcome?.status);
+ // Only an explicit hold suppresses orphan recovery; a failed delivery check
+ // must retain the caller's normal failure/retry handling.
+ const deliveryHeld = ['blocked', 'incomplete'].includes(reportedOutcome?.status);
const executionSuccess = success && exitCode === 0;
- let effectiveSuccess = isPrivateSecurity || refused || reportedHold ? false : success;
+ let effectiveSuccess = isPrivateSecurity || refused || deliveryHeld ? false : success;
const errorAnalysis = refused ? {
category: interruption.category, origin: interruption.source || 'provider',
message: 'Provider safety refusal; automatic continuation, retries and provider fallback are disabled.',
@@ -1231,8 +1233,7 @@ export async function retireDeadAgent({ agent, task, success, exitCode, duration
: agent.result?.validationPassed ?? null;
const taskOutcome = reportedOutcome ? resolveTaskOutcome({ reported: reportedOutcome,
success: effectiveSuccess, validationPassed }) : null;
- const deliveryHeld = ['blocked', 'incomplete'].includes(taskOutcome?.status);
- if (deliveryHeld) effectiveSuccess = false;
+ if (['blocked', 'incomplete'].includes(taskOutcome?.status)) effectiveSuccess = false;
if (agent.metadata?.runId) {
const bufferedOutput = Array.isArray(agent.output)
diff --git a/server/services/agentFinalization.retireDeadAgent.test.js b/server/services/agentFinalization.retireDeadAgent.test.js
index ec8ee4af5c..d624057ae2 100644
--- a/server/services/agentFinalization.retireDeadAgent.test.js
+++ b/server/services/agentFinalization.retireDeadAgent.test.js
@@ -139,6 +139,20 @@ describe('retireDeadAgent (#8440)', () => {
expect(updateTask).not.toHaveBeenCalled();
});
+ it.each([
+ { success: false, status: 'completed', exitCode: 1 },
+ { success: true, status: 'no-action-needed', exitCode: 0 },
+ ])('keeps failure recovery enabled for a synthesized incomplete outcome ($status, success=$success)', async ({ success, status, exitCode }) => {
+ const reportedOutcome = { status, reason: 'Invented delivery report.' };
+ const result = await retireDeadAgent({ agent: { ...AGENT, result: { taskOutcome: reportedOutcome } },
+ task: TASK, success, exitCode, duration: 100 });
+ expect(result).toEqual({ success: false, deliveryHeld: false,
+ taskOutcome: expect.objectContaining({ status: 'incomplete' }) });
+ expect(completeAgent).toHaveBeenCalledWith(AGENT.id, expect.objectContaining({ success: false,
+ taskOutcome: result.taskOutcome }));
+ expect(updateTask).not.toHaveBeenCalled();
+ });
+
it('leaves recovery retryable when parking the held task cannot be persisted', async () => {
const taskOutcome = { status: 'blocked', reason: 'Invented prerequisite.' };
updateTask.mockResolvedValueOnce({ error: 'storage-unavailable' });