stop_agent
Stop AI agents in the cmuxlayer terminal multiplexer by sending Ctrl+C for graceful termination or force killing processes when needed.
Instructions
Stop an agent gracefully (Ctrl+C) or forcefully (kill process).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | Agent ID to stop | |
| force | No | Force kill instead of graceful Ctrl+C |
Implementation Reference
- src/agent-engine.ts:545-560 (handler)The core implementation of the stopAgent logic which handles checking if the agent exists, if it's already in a terminal state, and killing the process if force is true.
async stopAgent(agentId: string, force?: boolean): Promise<void> { const agent = this.registry.get(agentId); if (!agent) { throw new Error(`Agent not found: ${agentId}`); } if (TERMINAL_STATES.has(agent.state)) { return; // Already stopped } if (force && agent.pid) { try { process.kill(agent.pid, "SIGKILL"); } catch { // Process may already be dead — that's fine } - src/server.ts:835-855 (registration)Registration of the stop_agent MCP tool, including input schema validation and calling the engine's stopAgent method.
server.tool( "stop_agent", "Stop an agent gracefully (Ctrl+C) or forcefully (kill process).", { agent_id: z.string().describe("Agent ID to stop"), force: z .boolean() .optional() .default(false) .describe("Force kill instead of graceful Ctrl+C"), }, async (args) => { try { await engine.stopAgent(args.agent_id, args.force); const state = engine.getAgentState(args.agent_id); return ok({ agent_id: args.agent_id, state: state?.state ?? "done", applied: "stop_agent", }); } catch (e) {