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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: retain saved delivery outcomes when replay includes prose
[._.]/ Adam Eivyc49f8424f8fd
diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.jsindex 4f75272499..614a8a22a8 100644--- a/server/services/agentFinalization.js+++ b/server/services/agentFinalization.js@@ -2301,10 +2301,9 @@ async function persistCompletionSummary(agentId, { workspacePath, finalSummary =}if (summary) source = 'terminal-result';}- if (!summary && !taskOutcome) {+ if (!taskOutcome) {// Cleanup may already have removed the sentinel on a finalization replay.- // Only retain a completion whose source was recorded for this same agent;- // older heuristic transcript summaries are not evidence of a final reply.+ // A new prose summary cannot clear the same agent's saved delivery outcome.const existing = existingRecord || await getAgentRecord(agentId);if (existing?.id === agentId) {taskOutcome = normalizeTaskOutcome(existing.result?.taskOutcome)@@ -2312,7 +2311,8 @@ async function persistCompletionSummary(agentId, { workspacePath, finalSummary =? normalizeTaskOutcome(existing.metadata?.taskOutcome) : null);if (taskOutcome) taskOutcomeSource = existing.metadata?.taskOutcomeSource || 'saved-result';}- if (existing?.id === agentId+ // Only retain summaries with a recorded source, never heuristic transcripts.+ if (!summary && existing?.id === agentId&& ['sentinel', 'terminal-result'].includes(existing.metadata?.taskSummarySource)&& typeof existing.metadata?.taskSummary === 'string'&& existing.metadata.taskSummary.trim()) return taskOutcome;diff --git a/server/services/agentFinalization.outputHooks.test.js b/server/services/agentFinalization.outputHooks.test.jsindex 849a49ee5f..76ad9a91c3 100644--- a/server/services/agentFinalization.outputHooks.test.js+++ b/server/services/agentFinalization.outputHooks.test.js@@ -372,7 +372,7 @@ describe('recovery output-hook dispatch (#3182)', () => {}});- it('holds an unverified no-op but leaves legacy prose as unknown delivery', async () => {+ it('holds an unverified no-op', async () => {isProgrammaticIoTaskType.mockReturnValue(false);try {const task = { id: 'user-example', taskType: 'user', metadata: {} };@@ -380,6 +380,15 @@ describe('recovery output-hook dispatch (#3182)', () => {finalSummary: JSON.stringify({ summary: 'Invented no-op.', taskOutcome: { status: 'no-action-needed', reason: 'No changes made.' } }) });expect(completeAgent).toHaveBeenLastCalledWith('agent-example', expect.objectContaining({ executionSuccess: true, success: false,taskOutcome: { status: 'incomplete', reason: 'The reported no-action-needed result was not verified.' } }));+ } finally {+ isProgrammaticIoTaskType.mockReturnValue(true);+ }+ });++ it('leaves legacy prose as unknown delivery when the agent has no saved outcome', async () => {+ isProgrammaticIoTaskType.mockReturnValue(false);+ try {+ const task = { id: 'user-example', taskType: 'user', metadata: {} };await finalizeAgent({ agentId: 'agent-example', task, success: true, exitCode: 0, outputBuffer: '',finalSummary: 'Status: BLOCKED - invented contradictory instructions' });expect(completeAgent).toHaveBeenLastCalledWith('agent-example', expect.objectContaining({ executionSuccess: true, taskOutcome: null }));@@ -406,21 +415,22 @@ describe('recovery output-hook dispatch (#3182)', () => {} finally { await rm(workspacePath, { recursive: true, force: true }); }});- it('retains an outcome-only sentinel on repeat finalization after cleanup', async () => {+ it.each([null, 'Invented terminal report.'])('retains an outcome-only sentinel on repeat finalization after cleanup with finalSummary=%s', async finalSummary => {const { mkdtemp, writeFile, rm } = await import('node:fs/promises');const { tmpdir } = await import('node:os');const workspacePath = await mkdtemp(join(tmpdir(), 'outcome-replay-'));const sentinelPath = join(workspacePath, '.agent-done-agent-example');const taskOutcome = { status: 'blocked', reason: 'Invented prerequisite remains unmet.' };- const finish = () => finalizeAgent({ agentId: 'agent-example', task: TASK, success: true,- exitCode: 0, duration: 1000, workspacePath, outputBuffer: '' });+ const finish = (finalSummary = null) => finalizeAgent({ agentId: 'agent-example', task: TASK, success: true,+ exitCode: 0, duration: 1000, workspacePath, finalSummary, outputBuffer: '' });try {await writeFile(sentinelPath, JSON.stringify({ taskOutcome }));await finish();await rm(sentinelPath);- await finish();+ await finish(finalSummary);expect(completeAgent).toHaveBeenLastCalledWith('agent-example', expect.objectContaining({ success: false, executionSuccess: true, taskOutcome }));expect(updateTask).toHaveBeenLastCalledWith(TASK.id, expect.objectContaining({ status: 'blocked', metadata: expect.objectContaining({ taskOutcome }) }), TASK.taskType);+ expect(persistedAgent.metadata.taskSummary).toBe(finalSummary);} finally { await rm(workspacePath, { recursive: true, force: true }); }});