Skip to main content
Glama

interact

Control AI agents in cmuxlayer by sending messages, interrupting tasks, switching models, resuming sessions, running skills, or checking usage. Manage agent interactions through direct commands.

Instructions

Send a message to an agent, or perform an agent action (interrupt, model switch, resume, skill, usage). If the agent is alive, sends directly. If not found, returns an error — use spawn_agent first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agentYesAgent ID (from spawn_agent or list_agents)
actionYesAction to perform
textNoText to send (required for action=send)
modelNoModel to switch to (required for action=model)
session_idNoSession ID to resume (optional for action=resume)
commandNoSlash command to run (required for action=skill)

Implementation Reference

  • The `interact` tool definition and its handler logic, which dispatches various agent actions based on the provided input.
    server.tool(
      "interact",
      "Send a message to an agent, or perform an agent action (interrupt, model switch, resume, skill, usage). If the agent is alive, sends directly. If not found, returns an error — use spawn_agent first.",
      {
        agent: z
          .string()
          .describe("Agent ID (from spawn_agent or list_agents)"),
        action: z
          .enum([
            "send",
            "interrupt",
            "model",
            "resume",
            "skill",
            "usage",
            "mcp",
          ])
          .describe("Action to perform"),
        text: z
          .string()
          .optional()
          .describe("Text to send (required for action=send)"),
        model: z
          .string()
          .optional()
          .describe("Model to switch to (required for action=model)"),
        session_id: z
          .string()
          .optional()
          .describe("Session ID to resume (optional for action=resume)"),
        command: z
          .string()
          .optional()
          .describe("Slash command to run (required for action=skill)"),
      },
      async (args) => {
        try {
          // Runtime validation per action (Decision 2)
          switch (args.action) {
            case "send":
              if (!args.text) {
                return err(
                  new Error(
                    "text is required for action=send. Provide the message to send to the agent.",
                  ),
                );
              }
              break;
            case "model":
              if (!args.model) {
                return err(
                  new Error(
                    "model is required for action=model. Provide the model name to switch to (e.g. 'sonnet', 'opus').",
                  ),
                );
              }
              break;
            case "skill":
              if (!args.command) {
                return err(
                  new Error(
                    "command is required for action=skill. Provide the slash command (e.g. '/commit', '/review').",
                  ),
                );
              }
              break;
            // interrupt, resume, usage, mcp — no extra fields required
          }
    
          // Resolve agent
          const agent = engine.getAgentState(args.agent);
          if (!agent) {
            return err(
              new Error(
                `Agent not found: "${args.agent}". Use list_agents to see available agents, or spawn_agent to create one.`,
              ),
            );
          }
    
          // Dispatch action
          switch (args.action) {
            case "send": {
              await engine.sendToAgent(args.agent, args.text!, true);
              return ok({
                agent_id: args.agent,
                action: "send",
                applied: true,
              });
            }
            case "interrupt": {
              await client.sendKey(agent.surface_id, "c-c", {});
              return ok({
                agent_id: args.agent,
                action: "interrupt",
                applied: true,
              });
            }
            case "model": {
              const modelCmd = `/model ${args.model}`;
              await engine.sendToAgent(args.agent, modelCmd, true);
              return ok({
                agent_id: args.agent,
                action: "model",
                model: args.model,
                applied: true,
              });
            }
            case "resume": {
              const resumeCmd = args.session_id
                ? `/resume ${args.session_id}`
                : "/resume";
              await engine.sendToAgent(args.agent, resumeCmd, true);
              return ok({
                agent_id: args.agent,
                action: "resume",
                session_id: args.session_id,
                applied: true,
              });
            }
            case "skill": {
              await engine.sendToAgent(args.agent, args.command!, true);
              return ok({
                agent_id: args.agent,
                action: "skill",
                command: args.command,
                applied: true,
              });
            }
            case "usage": {
              // Read screen to extract usage info
              const screen = await client.readScreen(agent.surface_id, {
                lines: 5,
              });
              return ok({
                agent_id: args.agent,
                action: "usage",
                surface_id: agent.surface_id,
                screen_tail: screen.text,
              });
            }
            case "mcp": {
              // Read screen for MCP server status
              const mcpScreen = await client.readScreen(agent.surface_id, {
                lines: 10,
              });
              return ok({
                agent_id: args.agent,
                action: "mcp",
                surface_id: agent.surface_id,
                screen_tail: mcpScreen.text,
              });
            }
          }
        } catch (e) {
          return err(e);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the tool can fail with an error if the agent isn't found, and it requires the agent to be 'alive' for direct sending. However, it doesn't cover other important aspects like authentication needs, rate limits, side effects of different actions, or what 'alive' means operationally.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded: two sentences that efficiently cover purpose, conditions, and error handling. Every word earns its place with zero waste or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (6 parameters, multiple action types) and no annotations or output schema, the description is adequate but incomplete. It covers the basic workflow and error case, but lacks details on action-specific behaviors, return values, or interaction patterns with sibling tools like 'send_to_agent'. For a multi-action tool with no structured output documentation, more context would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds minimal value beyond the schema—it mentions 'text' for 'send' and 'model' for 'model' actions implicitly, but doesn't provide additional semantic context or usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Send a message to an agent, or perform an agent action (interrupt, model switch, resume, skill, usage).' It specifies the verb ('send' or 'perform') and resource ('agent'), but doesn't explicitly differentiate from sibling tools like 'send_to_agent' or 'stop_agent' beyond mentioning 'spawn_agent' for error cases.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use the tool: 'If the agent is alive, sends directly. If not found, returns an error — use spawn_agent first.' This gives explicit guidance on prerequisites and error conditions, though it doesn't compare alternatives like 'send_to_agent' or explain when to choose specific actions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/EtanHey/cmuxlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server