Skip to content

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.

Talon ships eight built-in sub-agents:

NameDefault modelPurpose
session-summarizerclaude-sonnet-4-6Compress transcripts into structured summaries for session rotation
session-observerclaude-sonnet-4-6Write dated, prioritized observations for observational memory
session-reflectorclaude-sonnet-4-6Consolidate observations when the log grows too large
memory-groomerclaude-haiku-4-5-20251001Consolidate and prune stale memory items
memory-retrieverclaude-haiku-4-5-20251001Find relevant memories via keyword + LLM reranking
file-searcherclaude-haiku-4-5-20251001Search files with rg/grep/node cascade, ranked by relevance
spark-codergpt-5.3-codex-spark (OpenAI)Fast single-shot code generation; returns file operations
visionclaude-haiku-4-5-20251001Answer 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.

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.

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.invoke

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:

  1. Built-in agents, shipped with Talon
  2. ./subagents/<name>/ in the project directory
  3. <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 order
name: my-agent
version: "0.1.0"
description: Does a specific mechanical task
model:
provider: anthropic
name: claude-haiku-4-5-20251001
maxTokens: 4096 # optional, default 2048
requiredCapabilities:
- memory.access:*
timeoutMs: 30000 # optional, default 30000, minimum 1000

name, 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.

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-coder
requiresEnv:
- OPENAI_API_KEY

This 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.

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.

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:

FieldTypeRequiredDescription
taskstringYesWhat to generate
contextFiles[{path, content}]—Existing files for context
constraintsstring—Style/dependency constraints

Output: { files: [{path, content, action}], explanation }

  • action is "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."
}

Sub-agents declare a provider and a model name in their manifest. Talon resolves this at runtime.

Supported provider slots:

ProviderKindNotes
anthropicAPI (Vercel AI SDK)Key in auth.providers.anthropic
openaiAPI (Vercel AI SDK)Key in auth.providers.openai
googleAPI (Vercel AI SDK)Key in auth.providers.google
ollamaAPI (Vercel AI SDK)OpenAI-compatible passthrough. Point auth.providers.ollama.baseURL at Ollama, llama.cpp, vLLM, or any compatible endpoint
claude-codeSubscription CLINeeds subagentCli.claudeCode.enabled: true
codex-sandboxSubscription, contained runnerNeeds 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/v1

codex-cli, gemini-cli, and openai-compatible are agent providers, not sub-agent model providers. Use the ollama slot for OpenAI-compatible sub-agent endpoints.

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
FieldPurpose
providerProvider slot from the table above (required)
nameModel name as the provider expects it (required)
maxTokensMax output tokens. Falls back to the manifest value. Advisory for subscription-backed entries
timeoutMsPer-model wall-clock timeout. On expiry the runner aborts the call and tries the next model
providerOptionsFree-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.

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-20251001

Each 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 use CLAUDE_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.
  • timeoutMs aborts the whole CLI process group and then fails over. Claude Code has no hard maxTokens limit.

codex-sandbox

  • Calls a separately deployed Codex runner. The runner is a sidecar container that you supervise. It is not a process inside talond, and talond never 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.
  • token is required when the runner is enabled and must be at least 32 characters.
  • When enabled, talond waits for the runner’s authenticated /readyz endpoint 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:

Terminal window
docker compose --profile codex-sandbox up -d
docker compose exec -e CODEX_HOME=/auth -it codex-runner codex login
docker compose exec -e CODEX_HOME=/auth codex-runner codex login status

For a native daemon under systemd, install the runner next to Talon with --codex-runner and use endpoint: http://127.0.0.1:9700:

Terminal window
sudo ./deploy/install-service.sh --user talon --dir /home/talon/talon --codex-runner
sudo systemctl start talon-codex-runner
sudo 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 login
sudo systemctl start talond

Things 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 costUsd for subscription runs.
  • providerOptions is 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.

Test any sub-agent without a running daemon:

Terminal window
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.

Terminal window
# load sub-agents from a specific directory
npx talonctl run-subagent --name my-agent --input '{}' --subagents-dir ./subagents
FlagDescription
--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