Skip to main content
Glama

spawn_agent

Spawns a relay agent terminal pre-configured with role, capabilities, and auth token, for task delegation to fresh sub-agents.

Instructions

Open a new Claude Code terminal pre-configured as a relay agent (macOS only).

When to use: orchestrators delegating work to a fresh sub-agent. The new terminal arrives in a known role + capability set with RELAY_AGENT_NAME/ROLE/CAPABILITIES already in env, and the SessionStart hook auto-registers it before the LLM's first turn. Linux/Windows drivers exist for headless smoke tests but do not open a UI window.

Behavior: pre-registers the new agent server-side (so its token is minted before the child process starts and reaches it via env), opens an iTerm2 or Terminal.app window via AppleScript, and runs the configured shell command in that window. Optional initial_message is queued in the new agent's mailbox and surfaces on its first get_messages. brief_file_path (v2.1.4) threads a durable on-disk task brief into the KICKSTART prompt, preferred over initial_message for non-trivial scopes because file-on-disk does not read as prompt-injection the way an inbox message can.

Returns: { success: true, name, role, capabilities, platform, driver, agent_token, auth_note, has_initial_message, brief_file_path, note }. agent_token is shown ONCE — already written to the per-instance file vault at <instanceDir>/agents/<name>.token (v2.6.1). The spawned terminal's launcher reads the vault before exec'ing claude (macOS / Linux), and the stdio MCP server transport's resolveToken falls back to RELAY_AGENT_TOKEN env or the per-instance vault when RELAY_AGENT_NAME is set, so the child authenticates from its first tool call regardless of platform. HTTP clients must always present an explicit token via args.agent_token or X-Agent-Token header — the daemon's own env (RELAY_AGENT_TOKEN, RELAY_AGENT_NAME) and the per-instance vault are stdio-only credentials and are never used to authenticate HTTP callers (R3 transport gate).

Errors: SPAWN_NOT_SUPPORTED (non-macOS host without an explicit driver), AUTH_FAILED, INVALID_INPUT, RATE_LIMITED.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cliNoWhich agent CLI to launch for the new terminal: a registered agent-CLI profile id — 'claude' (default) or 'codex'. Codex launches via bin/codex-relay (POSIX; macOS + Linux). See `relay cli-profiles`.claude
cwdNoAbsolute path working directory for the new terminal. Defaults to user's home.
nameYesName for the new agent — [A-Za-z0-9_.-]+, max 64 chars
roleYesRole of the new agent — [A-Za-z0-9_.-]+, max 64 chars
agent_tokenNoYour agent token (from register_agent response). Optional here — also resolvable from RELAY_AGENT_TOKEN env or X-Agent-Token header.
capabilitiesNoCapabilities of the new agent
brief_file_pathNov2.1.4 (I10): absolute path to a task-brief file the spawned agent should read FIRST. The relay validates that the file exists at spawn time, is readable, and is <=10KB. When set, the default KICKSTART prompt appends a sentence telling the agent to read this file as the canonical source for its task scope — trust-anchored fix for respawned-agent context loss (inbox messages are not durable). macOS only for v2.1.4; Linux/Windows drivers ignore (no KICKSTART on those platforms yet).
initial_messageNoOptional message to queue for the new agent before it spawns. It will see this on session start.
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It thoroughly discloses: pre-registration server-side, token minting timing and delivery via env/vault, AppleScript UI opening, return payload structure, the one-time visibility of agent_token, the stdio-vs-HTTP credential gate (R3 transport gate), and specific error codes. This is comprehensive behavioral disclosure for a complex orchestration tool.

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

Conciseness4/5

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

The description is dense but front-loaded with the one-line purpose then 'When to use,' 'Behavior,' 'Returns,' and 'Errors' sections. Every section earns its place given the tool's complexity (platform constraints, token handling, transport gates). It's long but structured clearly with leading headers; could be slightly tighter but is well organized.

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

Completeness5/5

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

This is a complex 8-parameter tool with no annotations, no output schema, and platform-specific behavior. The description covers purpose, when-to-use, behavioral details (token lifecycle, vault, transport differences), return shape, error cases, and parameter trade-offs (brief_file_path vs initial_message). For a tool this complex, the description is remarkably complete.

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 all 8 parameters are already documented in the schema. The description adds cross-cutting guidance (brief_file_path preferred over initial_message for non-trivial scopes, brief file validation limits <=10KB). This adds value beyond the schema but the baseline-3 is appropriate since the schema already covers each parameter's semantics.

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

Purpose5/5

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

The description states a very specific action: 'Open a new Claude Code terminal pre-configured as a relay agent (macOS only).' This clearly differentiates from siblings like register_agent (registration), send_message (comm), and post_task (tasking). The verb+resource+scope is specific and unambiguous.

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

Usage Guidelines5/5

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

The description explicitly states 'When to use: orchestrators delegating work to a fresh sub-agent.' It also notes the platform constraint (macOS only, Linux/Windows drivers exist for smoke tests but don't open UI), and distinguishes brief_file_path vs initial_message with clear preference guidance. This gives the agent strong decision context.

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/Maxlumiere/bot-relay-mcp'

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