Skip to content

Background agents

Background agents are long-running workers that run out-of-band — they don’t block the foreground conversation. Claude Code is still the default, but background tasks can also run through Codex CLI, Gemini CLI, or the openai-compatible provider when that better fits the workload.

Good use cases:

  • Repo-wide refactoring or code analysis
  • Large document processing or research
  • Tasks that take 5+ minutes and don’t need turn-by-turn interaction

Not appropriate for:

  • Quick lookups or calculations (use sub-agents instead)
  • Tasks that need access to the conversation history in real time
  • Anything that needs to send multiple incremental messages back

The foreground agent calls background_agent with a task description. Talon spawns the configured provider process, tracks it in SQLite, and returns a task ID immediately. The foreground conversation continues normally.

When the background worker finishes (or times out, or fails), Talon delivers a completion message to the originating thread via the normal queue and channel-send path.

Background workers:

  • Inherit the persona’s system prompt and MCP servers from assigned skills
  • Get a filtered version of Talon’s host-tools MCP server, based on the persona’s capabilities. The background_agent tool is always excluded, so a worker cannot spawn more workers
  • Are subject to maxConcurrent and defaultTimeoutMinutes limits
  • Have their state persisted — completion/failure/timeout/cancellation are all recorded
backgroundAgent:
enabled: true
maxConcurrent: 3
defaultTimeoutMinutes: 30
defaultProvider: claude-code
providers:
claude-code:
enabled: true
command: claude
contextWindowTokens: 200000
FieldDefaultDescription
enabledtrueGlobally enable background workers
maxConcurrent3Maximum simultaneous workers (1–10)
defaultTimeoutMinutes30Default wall-clock timeout (15–480 min)
defaultProviderclaude-codeProvider used for workers
claudePath—Legacy shortcut for the Claude Code binary path
providers.<name>.options{}Provider-specific options (for example defaultModel: gpt-5.4 for codex-cli, or baseUrl / providerId for openai-compatible)

Available providers: claude-code (default), gemini-cli, codex-cli, and openai-compatible. See the Providers guide for configuration details.

A persona can run its background agents on a different provider and model than its foreground runs. Set backgroundProvider and, optionally, backgroundModel:

personas:
- name: assistant
model: qwen3-coder:30b
provider: openai-compatible # foreground stays on Ollama
backgroundProvider: claude-code # background runs on Claude Code
backgroundModel: claude-sonnet-4-6

backgroundProvider must be enabled under backgroundAgent.providers. The daemon refuses to start otherwise. backgroundModel without backgroundProvider is rejected at config load.

Talon picks the provider for a spawn in this order:

  1. The provider argument of the background_agent tool call
  2. The persona’s backgroundProvider
  3. The persona’s foreground provider, only if it is also enabled under backgroundAgent.providers
  4. backgroundAgent.defaultProvider

When a background run takes its provider and model from the persona configuration, Talon also forwards that persona’s reasoningEffort. A run with explicit provider arguments in the tool call does not inherit it.

openai-compatible works as a background provider. Configure it like this:

backgroundAgent:
enabled: true
maxConcurrent: 2
defaultTimeoutMinutes: 30
defaultProvider: claude-code
providers:
claude-code:
enabled: true
command: claude
contextWindowTokens: 200000
openai-compatible:
enabled: true
command: node
contextWindowTokens: 256000
options:
baseUrl: ${OLLAMA_BASE_URL}
defaultModel: glm-5.1
providerId: ollama

Notes:

  • background openai-compatible runs use the same tool bridge and capability filtering as the foreground path
  • they do not live-stream intermediate output back into the channel
  • credentials are resolved from auth.providers.<providerId> first, then auth.providers.openai-compatible

Grant subagent.background in the persona’s capabilities:

personas:
- name: assistant
capabilities:
allow:
- subagent.background
- channel.send:my-telegram

A profile is a loaded persona. When the agent passes profile on spawn, the worker uses that persona’s system prompt, skills, model, and provider instead of those of the persona that owns the thread. The agent can call background_agent action="profiles" to discover available profiles before spawning. The list shows each persona name plus the optional description from its system.md frontmatter.

Without a profile, the worker gets the full prompt of the persona that owns the thread. A lean persona used as profile keeps background agents small.

To check what profiles are available, instruct the agent to do so in the system prompt:

## Background Agents
You can delegate work to specialized background agents. Use
`background_agent action="profiles"` to discover what profiles are available.
When asked about your capabilities or what agents you can use, always check
profiles first rather than guessing.
ParameterDescription
actionspawn, status, cancel, result, or profiles
promptTask prompt for spawn
taskIdTask ID for status, cancel, and result
profilePersona name to use as profile for spawn
providerOptional provider override for spawn
workingDirectoryOptional working directory for the worker
timeoutMinutesOptional timeout override for spawn, in minutes

User sends: “Analyze all TypeScript files in /home/user/project and produce a dependency graph.”

The foreground agent:

  1. Calls background_agent action="profiles" to check available profiles
  2. Selects an appropriate profile
  3. Calls background_agent action="spawn" with the task description and timeout
  4. Immediately responds to the user: “Started analysis. I’ll let you know when it’s done — this should take about 15 minutes.”

When the worker finishes, the user receives a completion message with results.

  • Workers cannot spawn additional background agents
  • Results arrive in the originating thread via the daemon after completion
  • If a worker exceeds its timeout (defaultTimeoutMinutes unless the spawn call sets timeoutMinutes), it’s killed and the originating thread is notified
  • The daemon enforces maxConcurrent. If the limit is reached, a new spawn request fails with a concurrency-limit error. The agent can retry when a worker has finished

Check running background workers via daemon status:

Terminal window
npx talonctl status

The status output includes active background worker count and any recently completed/failed tasks.