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(cos): add periodic zombie agent cleanup to health check loop

Adam Eivy015ca4adc271
diff --git a/.changelog/v0.10.x.md b/.changelog/v0.10.x.md
index 422c633459..2b6ba7dfd0 100644
--- a/.changelog/v0.10.x.md
+++ b/.changelog/v0.10.x.md
@@ -517,6 +517,9 @@ This release introduces a structured changelog documentation system for creating
- **YOLO mode for autonomous agents**: Gemini CLI agents now spawn with `--yolo` flag for auto-approval (equivalent to Claude's `--dangerously-skip-permissions`), preventing agents from hanging on permission prompts
- **Model passthrough**: Gemini CLI now passes `--model` flag when a model is configured, enabling provider-level model selection
+### Periodic Zombie Agent Cleanup
+- **Runtime orphan detection**: `cleanupOrphanedAgents()` now runs every health check cycle (15 min) instead of only at daemon startup, catching agents whose process died mid-run without proper state cleanup
+
## 📦 Installation
```bash
diff --git a/server/services/cos.js b/server/services/cos.js
index 25a454e2ef..768711d3b4 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -93,7 +93,7 @@ const DEFAULT_CONFIG = {
autoStart: false, // Legacy: use alwaysOn instead
selfImprovementEnabled: true, // Allow CoS to improve itself (PortOS codebase)
appImprovementEnabled: true, // Allow CoS to improve managed apps
- avatarStyle: 'svg', // UI preference: 'svg' or 'ascii'
+ avatarStyle: 'svg', // UI preference: 'svg' | 'ascii' | 'cyber' | 'sigil'
// Always-on mode settings
alwaysOn: true, // CoS starts automatically and stays active
appReviewCooldownMs: 1800000, // 30 min between working on same app (was 1 hour)
@@ -290,8 +290,13 @@ export async function start() {
intervalMs: state.config.healthCheckIntervalMs,
handler: async () => {
await runHealthCheck();
+ // Periodic zombie detection — catches agents whose process died mid-run
+ const cleaned = await cleanupOrphanedAgents();
+ if (cleaned > 0) {
+ emitLog('info', `🧹 Periodic cleanup: ${cleaned} orphaned agent(s)`);
+ }
},
- metadata: { description: 'CoS health check loop' }
+ metadata: { description: 'CoS health check + orphan cleanup loop' }
});
// Run initial evaluation and health check