kill
Stop one or more AI agents managed by the cmuxlayer terminal multiplexer. Specify agent IDs or use 'all' to terminate agents, with optional force kill capability.
Instructions
Stop one or more agents. Target can be a single agent ID, an array of IDs, or 'all'.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Agent ID, array of agent IDs, or 'all' to stop all agents | |
| force | No | Force kill (SIGKILL) instead of graceful (Ctrl+C) |
Implementation Reference
- src/server.ts:1116-1174 (handler)Implementation of the 'kill' MCP tool, which stops agents either gracefully or forcibly.
server.tool( "kill", "Stop one or more agents. Target can be a single agent ID, an array of IDs, or 'all'.", { target: z .union([z.string(), z.array(z.string())]) .describe( "Agent ID, array of agent IDs, or 'all' to stop all agents", ), force: z .boolean() .optional() .default(false) .describe("Force kill (SIGKILL) instead of graceful (Ctrl+C)"), }, async (args) => { try { const killed: string[] = []; const errors: string[] = []; // Resolve target list let targetIds: string[]; if (args.target === "all") { const agents = engine.listAgents(); targetIds = agents .filter((a) => a.state !== "done" && a.state !== "error") .map((a) => a.agent_id); } else if (Array.isArray(args.target)) { targetIds = args.target; } else { targetIds = [args.target]; } if (targetIds.length === 0) { return ok({ killed: [], message: "No agents to kill" }); } // Kill each agent, collecting results for (const agentId of targetIds) { try { await engine.stopAgent(agentId, args.force); killed.push(agentId); } catch (e) { errors.push( `${agentId}: ${e instanceof Error ? e.message : String(e)}`, ); } } if (killed.length === 0 && errors.length > 0) { return err( new Error(`Failed to kill any agents: ${errors.join("; ")}`), ); } return ok({ killed, errors: errors.length > 0 ? errors : undefined, force: args.force,