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(cos): check for task commits before classifying agent as failed
Adam Eivy31eaafd950db
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex ea299bccd2..1a16c61e6e 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -52,6 +52,8 @@- Chart date range comparison uses local date strings instead of UTC Date objects — fixes today/yesterday missing from 7-day chart- Empty entry objects no longer accumulate in daily-log.json after moving the last item from a date- README screenshot labels corrected to match actual screenshot content (all 6 were mislabeled)+- Agent commit detection disconnected from task status: `handleAgentCompletion` now checks for task commits before treating killed/crashed agents as failures, preventing false `startup-failure` classifications when work was actually committed+- Orphaned agent handler now checks for task commits before retrying, completing the task instead of endlessly re-spawning when work is already done- Zod `.default(false)` on `archived`, `defaultUseWorktree`, and `defaultOpenPR` in `appSchema` caused `appUpdateSchema.partial()` to inject `false` for omitted fields, silently overwriting stored `true` values during partial updates## Removeddiff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.jsindex e3b27023bb..9b33e01fda 100644--- a/server/services/subAgentSpawner.js+++ b/server/services/subAgentSpawner.js@@ -1834,11 +1834,23 @@ async function handleAgentCompletion(agentId, exitCode, success, duration) {outputBuffer = await readFile(outputFile, 'utf-8').catch(() => '');}+ // Post-execution validation: check for task commit even if exit code is non-zero+ // This catches cases where the agent was killed/crashed after committing work+ let effectiveSuccess = success;+ if (!effectiveSuccess && task?.id) {+ const workspacePath = agent.workspacePath || ROOT_DIR;+ const commitFound = checkForTaskCommit(task.id, workspacePath);+ if (commitFound) {+ emitLog('warn', `Agent ${agentId} reported failure (exit ${exitCode}) but work completed - commit found for task ${task.id}`, { agentId, taskId: task.id, exitCode });+ effectiveSuccess = true;+ }+ }+// Analyze failure if applicable- const errorAnalysis = success ? null : analyzeAgentFailure(outputBuffer, task, model);+ const errorAnalysis = effectiveSuccess ? null : analyzeAgentFailure(outputBuffer, task, model);await completeAgent(agentId, {- success,+ success: effectiveSuccess,exitCode,duration,outputLength: outputBuffer.length,@@ -1851,7 +1863,7 @@ async function handleAgentCompletion(agentId, exitCode, success, duration) {}// Update task status with retry tracking- if (success) {+ if (effectiveSuccess) {await updateTask(task.id, { status: 'completed' }, task.taskType || 'user');} else {const failedUpdate = await resolveFailedTaskUpdate(task, errorAnalysis, agentId);@@ -1879,7 +1891,7 @@ async function handleAgentCompletion(agentId, exitCode, success, duration) {}// Process memory extraction and app cooldown- await processAgentCompletion(agentId, task, success, outputBuffer);+ await processAgentCompletion(agentId, task, effectiveSuccess, outputBuffer);// Fetch agent state once for JIRA and plan-question blocksconst { getAgent: getAgentState } = await import('./cos.js');@@ -3378,6 +3390,14 @@ export async function handleOrphanedTask(taskId, agentId, getTaskById) {return;}+ // Check if the agent actually committed work before treating as orphaned+ const commitFound = checkForTaskCommit(taskId);+ if (commitFound) {+ emitLog('info', `✅ Orphaned agent ${agentId} actually completed work - commit found for task ${taskId}`, { taskId, agentId });+ await updateTask(taskId, { status: 'completed' }, task.taskType || 'user');+ return;+ }+// Get current retry count from task metadataconst retryCount = (task.metadata?.orphanRetryCount || 0) + 1;const totalSpawns = task.metadata?.totalSpawnCount || 0;