Sub-agents
Sub-agents are specialized LLM workers that the main agent can delegate mechanical tasks to. They run synchronously via subagent_invoke and return structured results. The main agent doesn’t need to handle the implementation details — it just calls the sub-agent by name.
The idea is to offload cheap, focused tasks (summarize this, find these files, groom this memory) to fast small models rather than burning context and cost on the main agent.
Built-in sub-agents
Section titled “Built-in sub-agents”Talon ships eight built-in sub-agents:
| Name | Default model | Purpose |
|---|---|---|
session-summarizer | claude-sonnet-4-6 | Compress transcripts into structured summaries for session rotation |
session-observer | claude-sonnet-4-6 | Write dated, prioritized observations for observational memory |
session-reflector | claude-sonnet-4-6 | Consolidate observations when the log grows too large |
memory-groomer | claude-haiku-4-5-20251001 | Consolidate and prune stale memory items |
memory-retriever | claude-haiku-4-5-20251001 | Find relevant memories via keyword + LLM reranking |
file-searcher | claude-haiku-4-5-20251001 | Search files with rg/grep/node cascade, ranked by relevance |
spark-coder | gpt-5.3-codex-spark (OpenAI) | Fast single-shot code generation; returns file operations |
vision | claude-haiku-4-5-20251001 | Answer one question about images in the thread and save a textual Finding |
The context roller calls the session sub-agents automatically. The others are available for direct invocation.
vision
Section titled “vision”The vision sub-agent is the only place where image pixels reach a model. The main agent stays text-only and receives image metadata and textual Findings. Add vision to the persona’s subagents list to enable it. subagent.invoke:* alone does not assign it.
Its model chain may only contain anthropic, openai, google, or ollama entries. Config load rejects claude-code and codex-sandbox in the vision chain. See the Vision guide for setup, limits, and the input and output format.
Invoking a sub-agent
Section titled “Invoking a sub-agent”The main agent calls subagent_invoke with a name and optional input object:
subagent_invoke({ name: "memory-retriever", input: { query: "user's preferred response format" }})The daemon handles model resolution, capability validation, and execution. The result is returned synchronously.
Required capability: subagent.invoke
The persona’s subagents list is an explicit allow-list:
personas: - name: assistant subagents: - session-summarizer - memory-retriever - memory-groomer - file-searcher capabilities: allow: - subagent.invokeCustom sub-agents
Section titled “Custom sub-agents”You can write your own sub-agents. Talon loads sub-agents from three locations at startup. A later location overrides an earlier one when names match:
- Built-in agents, shipped with Talon
./subagents/<name>/in the project directory<dataDir>/subagents/<name>/in the data directory (highest precedence)
A sub-agent directory needs at minimum a manifest and an entry point:
subagents/my-agent/ subagent.yaml # manifest index.ts # entry point exporting a run() function (index.js in production) prompts/ # system prompt fragments, concatenated in orderManifest (subagent.yaml)
Section titled “Manifest (subagent.yaml)”name: my-agentversion: "0.1.0"description: Does a specific mechanical taskmodel: provider: anthropic name: claude-haiku-4-5-20251001 maxTokens: 4096 # optional, default 2048requiredCapabilities: - memory.access:*timeoutMs: 30000 # optional, default 30000, minimum 1000name, version, description, model.provider, and model.name are required.
The requiredCapabilities list is validated against the invoking persona’s grants. If any required capability is missing, the sub-agent is rejected at invocation time.
requiresEnv — environment-gated loading
Section titled “requiresEnv — environment-gated loading”Sub-agents can declare environment variables they require. If any are missing, the loader silently skips the sub-agent at startup (info log, not a warning).
name: spark-coderrequiresEnv: - OPENAI_API_KEYThis lets you ship sub-agents that depend on optional credentials. Users without the env var simply don’t get the sub-agent loaded — no errors, no noise.
Entry point (index.ts)
Section titled “Entry point (index.ts)”import { generateText } from 'ai';import { ok } from 'neverthrow';
export async function run(ctx, input) { const { text } = await generateText({ model: ctx.model, system: ctx.systemPrompt, prompt: '...', maxOutputTokens: ctx.maxOutputTokens, experimental_telemetry: ctx.telemetry, abortSignal: ctx.abortSignal, providerOptions: ctx.providerOptions, }); return ok({ summary: text });}run(ctx, input) receives a SubAgentContext from the runner and returns a Result<SubAgentResult, SubAgentError>. A result has a required summary string and optional data and usage fields.
Always forward ctx.abortSignal to your model calls. The runner aborts it when the per-model timeoutMs fires. Without it, a timed-out call keeps running in the background while failover already tries the next model.
spark-coder
Section titled “spark-coder”Fast code generation using OpenAI’s gpt-5.3-codex-spark model. Designed for single-shot file generation inside an agentic loop — the parent agent describes what to generate, spark-coder produces structured file operations, and the parent handles I/O.
Requires: OPENAI_API_KEY in the environment.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
task | string | Yes | What to generate |
contextFiles | [{path, content}] | — | Existing files for context |
constraints | string | — | Style/dependency constraints |
Output: { files: [{path, content, action}], explanation }
actionis"create"or"replace"- Paths are always relative — absolute paths and
..traversal are rejected by schema
Example:
subagent_invoke({ name: "spark-coder", input: { task: "Add a validateEmail utility function", contextFiles: [ { path: "src/utils/index.ts", content: "export function formatDate..." } ], constraints: "TypeScript strict mode, no external deps" }})Returns:
{ "files": [ { "path": "src/utils/validate.ts", "content": "export function validateEmail(email: string): boolean { ... }", "action": "create" } ], "explanation": "Created validateEmail in a dedicated utility file."}Multi-provider model resolution
Section titled “Multi-provider model resolution”Sub-agents declare a provider and a model name in their manifest. Talon resolves this at runtime.
Supported provider slots:
| Provider | Kind | Notes |
|---|---|---|
anthropic | API (Vercel AI SDK) | Key in auth.providers.anthropic |
openai | API (Vercel AI SDK) | Key in auth.providers.openai |
google | API (Vercel AI SDK) | Key in auth.providers.google |
ollama | API (Vercel AI SDK) | OpenAI-compatible passthrough. Point auth.providers.ollama.baseURL at Ollama, llama.cpp, vLLM, or any compatible endpoint |
claude-code | Subscription CLI | Needs subagentCli.claudeCode.enabled: true |
codex-sandbox | Subscription, contained runner | Needs subagentSandbox.codex.enabled: true |
auth: providers: anthropic: apiKey: ${SUBAGENT_ANTHROPIC_API_KEY} openai: apiKey: ${OPENAI_API_KEY} google: apiKey: ${GOOGLE_API_KEY} ollama: baseURL: http://localhost:11434/v1codex-cli, gemini-cli, and openai-compatible are agent providers, not sub-agent model providers. Use the ollama slot for OpenAI-compatible sub-agent endpoints.
Model overrides and failover
Section titled “Model overrides and failover”You can override a sub-agent’s model in talond.yaml without editing its manifest. The model list is an ordered failover chain:
subagents: memory-groomer: model: - provider: ollama name: qwen3-30b # maxTokens: 4096 # optional, falls back to the manifest value # timeoutMs: 120000 # optional per-model timeout (minimum 1000) - provider: anthropic name: claude-haiku-4-5-20251001| Field | Purpose |
|---|---|
provider | Provider slot from the table above (required) |
name | Model name as the provider expects it (required) |
maxTokens | Max output tokens. Falls back to the manifest value. Advisory for subscription-backed entries |
timeoutMs | Per-model wall-clock timeout. On expiry the runner aborts the call and tries the next model |
providerOptions | Free-form record forwarded to the AI SDK call. Only effective on the ollama slot |
The runner tries each model in order. A failed or timed-out model logs a warning and the next one runs. After the override list, the manifest’s model is the final fallback. If all models fail, the error lists each attempt. Sub-agents without an entry under subagents: use their manifest model unchanged.
Subscription-backed sub-agents
Section titled “Subscription-backed sub-agents”Sub-agents can run on a Claude Code or Codex/ChatGPT subscription instead of an API key. Neither path uses auth.providers.
subagentCli: claudeCode: enabled: true command: claude # optional path or command name
subagentSandbox: codex: enabled: true endpoint: http://codex-runner:9700 # use http://127.0.0.1:9700 for a native daemon token: ${TALON_CODEX_RUNNER_TOKEN} startupTimeoutMs: 30000
subagents: session-summarizer: model: - provider: claude-code name: claude-sonnet-4-6 timeoutMs: 60000 - provider: codex-sandbox name: gpt-5.6-terra timeoutMs: 60000 - provider: anthropic # ordinary API fallback, if configured name: claude-haiku-4-5-20251001Each attempt is a single isolated generation, not an agent run. It gets no Talon host tools, no MCP servers, no provider session, and no persona tool access.
claude-code
- Uses the Claude Code login of the OS user that runs
talond. Log in interactively as that user before you enable it. Headless setups can useCLAUDE_CODE_OAUTH_TOKEN. - Runs in safe mode with tools disabled and no session persistence.
- The child process gets an explicit environment allowlist. Talon removes API-key and alternate API-routing variables before it starts.
timeoutMsaborts the whole CLI process group and then fails over. Claude Code has no hardmaxTokenslimit.
codex-sandbox
- Calls a separately deployed Codex runner. The runner is a sidecar container that you supervise. It is not a process inside
talond, andtalondnever starts Docker or Podman itself. - Use a dedicated Codex/ChatGPT account. The runner starts only with ChatGPT authentication. API-key and gateway authentication fail closed.
- Each attempt uses a fresh App Server process, an ephemeral thread, and an empty temporary home and workspace. The runner has no Talon host-tools bridge, MCP configuration, persona data, host mounts, or Docker socket.
- If Codex starts any built-in tool, the runner interrupts it and returns a failed attempt, so the next model in the chain takes over.
tokenis required when the runner is enabled and must be at least 32 characters.- When enabled,
talondwaits for the runner’s authenticated/readyzendpoint before it starts channels, scheduling, or queue processing.
For the Docker setup, add a random TALON_CODEX_RUNNER_TOKEN to .env, start the optional profile, and log in inside the runner volume:
docker compose --profile codex-sandbox up -ddocker compose exec -e CODEX_HOME=/auth -it codex-runner codex logindocker compose exec -e CODEX_HOME=/auth codex-runner codex login statusFor a native daemon under systemd, install the runner next to Talon with --codex-runner and use endpoint: http://127.0.0.1:9700:
sudo ./deploy/install-service.sh --user talon --dir /home/talon/talon --codex-runnersudo systemctl start talon-codex-runnersudo docker compose -f deploy/docker-compose.yaml -f deploy/docker-compose.native-runner.yaml \ --profile codex-sandbox exec -e CODEX_HOME=/auth codex-runner codex loginsudo systemctl start talondThings to know:
- Restart the daemon after you change
subagentCli,subagentSandbox, or a sub-agent model chain. Hot reload does not rebuild the resolver. - Authentication, quota, runner, and CLI failures are normal failover failures. The runner tries the next entry in the chain.
- Results can include token counts when the CLI supplies them. Talon does not report a
costUsdfor subscription runs. providerOptionsis ignored for subscription-backed entries.- Direct Codex CLI is not available as a sub-agent provider. Its agentic execution mode cannot enforce Talon’s filesystem-read boundary, so Codex only runs through the contained runner.
CLI testing
Section titled “CLI testing”Test any sub-agent without a running daemon:
npx talonctl run-subagent --name session-summarizer \ --input '{"transcript": "User: Hi\nAssistant: Hello!"}'This loads the sub-agent, resolves its model, and runs it in isolation. Useful for developing and debugging custom sub-agents before wiring them into a live persona.
# load sub-agents from a specific directorynpx talonctl run-subagent --name my-agent --input '{}' --subagents-dir ./subagents| Flag | Description |
|---|---|
--name <name> | Sub-agent name (required) |
--input <json> | JSON input for the sub-agent (required) |
--config <path> | Path to talond.yaml (default talond.yaml) |
--subagents-dir <path> | Sub-agents directory. Overrides the default three-location loading |