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): block user-killed tasks instead of re-queuing + fix gemini-cli model args

Adam Eivyaa2d65668223
diff --git a/.changelog/v0.10.x.md b/.changelog/v0.10.x.md
index 43d5c47e73..d7f440ac83 100644
--- a/.changelog/v0.10.x.md
+++ b/.changelog/v0.10.x.md
@@ -489,6 +489,15 @@ This release introduces a structured changelog documentation system for creating
- **Consistent failure handling**: Both runner mode and direct spawn mode use the same `resolveFailedTaskUpdate()` function, ensuring identical retry/block behavior regardless of spawn mode
- **DRY refactor**: Consolidated duplicate task-status-update and investigation-task-creation logic from both completion paths into a single shared function
+### CoS User-Killed Tasks No Longer Re-Queued
+- **Block instead of re-queue**: When a user terminates or force-kills a running agent, the associated task is now marked as `blocked` (with reason "Terminated by user") instead of being set back to `pending` — prevents killed tasks from automatically restarting on the next evaluation cycle
+- **Both spawn modes fixed**: Applies to both runner mode and direct spawn mode agent termination paths
+- **Close handler awareness**: Direct mode agents track user-termination state so the process `close` event handler skips retry logic for intentionally killed agents
+
+### Gemini CLI Model Argument Fix
+- **No --model flag for Gemini CLI**: The `buildCliSpawnConfig` function now has a dedicated handler for `gemini-cli` that uses the provider's own command and args without appending Claude-specific flags (`--dangerously-skip-permissions`, `--print`, `--model`)
+- **CoS Runner allowlist**: Added `gemini` to the allowed commands list in the CoS Runner, enabling Gemini CLI agents to spawn via the runner
+
## 📦 Installation
```bash
diff --git a/server/cos-runner/index.js b/server/cos-runner/index.js
index b8de3da784..79c499cd84 100644
--- a/server/cos-runner/index.js
+++ b/server/cos-runner/index.js
@@ -33,7 +33,8 @@ const ALLOWED_COMMANDS = new Set([
'claude',
'aider',
'codex',
- 'copilot'
+ 'copilot',
+ 'gemini'
]);
/**
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index e22d203b64..1d3bed291f 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -384,6 +384,9 @@ const activeAgents = new Map();
// Track runner-spawned agents (CoS Runner mode)
const runnerAgents = new Map();
+// Track agents terminated by user (to prevent re-queuing)
+const userTerminatedAgents = new Set();
+
/**
* Get list of active agent IDs (for zombie detection)
* Includes both direct mode and runner mode agents
@@ -1305,7 +1308,19 @@ async function spawnDirectly(agentId, task, prompt, workspacePath, model, provid
await completeAgentRun(agentData?.runId || runId, outputBuffer, code, duration, errorAnalysis);
// Update task status with retry tracking
- if (success) {
+ // Skip if user-terminated — task already blocked by terminateAgent/killAgent
+ if (userTerminatedAgents.has(agentId)) {
+ userTerminatedAgents.delete(agentId);
+ await updateTask(task.id, {
+ status: 'blocked',
+ metadata: {
+ ...task.metadata,
+ blockedReason: 'Terminated by user',
+ blockedCategory: 'user-terminated',
+ blockedAt: new Date().toISOString()
+ }
+ }, task.taskType || 'user');
+ } else if (success) {
await updateTask(task.id, { status: 'completed' }, task.taskType || 'user');
} else {
const failedUpdate = await resolveFailedTaskUpdate(task, errorAnalysis, agentId);
@@ -1365,6 +1380,16 @@ function buildCliSpawnConfig(provider, model) {
};
}
+ // Gemini CLI — no --model flag, no Claude-specific flags
+ if (providerId === 'gemini-cli') {
+ const args = [...(provider?.args || [])];
+ return {
+ command: provider?.command || 'gemini',
+ args,
+ stdinMode: 'prompt'
+ };
+ }
+
// Default: Claude Code CLI
const args = [
'--dangerously-skip-permissions', // Unrestricted mode
@@ -1594,10 +1619,18 @@ export async function terminateAgent(agentId) {
if (result.success) {
// Mark agent as completed with termination status
await completeAgent(agentId, { success: false, error: 'Agent terminated by user' });
- // Update task status back to pending
+ // Block task instead of re-queuing — user intentionally stopped this
const task = agentInfo?.task;
if (task) {
- await updateTask(task.id, { status: 'pending' }, task.taskType || 'user');
+ await updateTask(task.id, {
+ status: 'blocked',
+ metadata: {
+ ...task.metadata,
+ blockedReason: 'Terminated by user',
+ blockedCategory: 'user-terminated',
+ blockedAt: new Date().toISOString()
+ }
+ }, task.taskType || 'user');
}
runnerAgents.delete(agentId);
}
@@ -1611,6 +1644,9 @@ export async function terminateAgent(agentId) {
return { success: false, error: 'Agent not found or not running' };
}
+ // Track as user-terminated so the close handler doesn't re-queue
+ userTerminatedAgents.add(agentId);
+
// Mark agent as completed immediately with termination status
await completeAgent(agentId, { success: false, error: 'Agent terminated by user' });
@@ -1677,10 +1713,18 @@ export async function killAgent(agentId) {
if (result.success) {
// Mark agent as completed with kill status
await completeAgent(agentId, { success: false, error: 'Agent force killed by user (SIGKILL)' });
- // Update task status back to pending
+ // Block task instead of re-queuing — user intentionally killed this
const task = agentInfo?.task;
if (task) {
- await updateTask(task.id, { status: 'pending' }, task.taskType || 'user');
+ await updateTask(task.id, {
+ status: 'blocked',
+ metadata: {
+ ...task.metadata,
+ blockedReason: 'Force killed by user',
+ blockedCategory: 'user-terminated',
+ blockedAt: new Date().toISOString()
+ }
+ }, task.taskType || 'user');
}
runnerAgents.delete(agentId);
}
@@ -1694,6 +1738,9 @@ export async function killAgent(agentId) {
return { success: false, error: 'Agent not found or not running' };
}
+ // Track as user-terminated so the close handler doesn't re-queue
+ userTerminatedAgents.add(agentId);
+
// Mark agent as completed immediately with kill status
await completeAgent(agentId, { success: false, error: 'Agent force killed by user (SIGKILL)' });