Subagents and background agents.
Delegate a bounded task, choose a role and lifetime, monitor background agents, and distinguish shared-workspace work from worktree isolation and Crew.
For setup and updates, see Install and update. Check
kaitoi --versionand usekaitoi code --helpto confirm available commands. Older builds may interpret unsupportedcode acporcode servecommands as model prompts.
A subagent handles a focused task and returns a result to the main session. Give it a useful brief: the objective, relevant files, constraints, and the evidence you expect. It receives that task context, not the entire parent conversation.
Match the role to the job
| Built-in role | Intended work |
|---|---|
explore, planner, reviewer |
Read, search, and report. |
tester |
Run tests or commands without editing files. |
implementer, general |
Broader implementation work under the allowed authority. |
The current mode narrows the available role effects. Read-only foreground
delegation can use agent.ask; work with additional effects uses
agent.delegate in Build mode. These are model tools: ask in plain language
rather than typing them as slash commands.
Ask a reviewer to inspect the retry path without edits. Give it the accepted contract and have it return concrete defects with file and line evidence.
External-engine starts and background starts require their own approval even when the task is read-only. For a writing delegate, read both the start scope and any later permission request.
Choose the right lifetime
A foreground subagent returns its report during the current task. An ordinary background agent returns an agent ID and works under a bounded grant while the Code session remains alive; exiting stops it. A delegated task with verification uses a durable Crew run with its own run ID and admission. That run can outlive the terminal. These are different controls and identities.
For ordinary background work, approve the bounded grant and inspect the returned agent ID. Subsequent actions must fit that grant rather than asking for every individual action. Inside Code:
/agents
/agents show <agent-id>
/agents cancel <agent-id>
Ordinary background agents belong to the session and are stopped during the exit flow. In headless/JSON mode, ordinary background requests run in the foreground instead. A delegated task with explicit verification is different: it starts a durable Crew build with its own admission and controls.
Decide where edits happen
Ordinary delegation normally uses the current workspace. Separate assignments do not prevent two agents from editing the same file. Give each an explicit scope and inspect the combined result.
For worktree isolation, ask for isolation: "worktree". That worktree starts
from the last commit; it does not include uncommitted checkout changes. The
child's changes are committed only when it finishes on its own. Cancelled,
timed-out or stopped children leave uncommitted work in the worktree. Branches
use kaitoi/agent/<agent-id> (with a suffix if needed); worktrees live under
~/.kaitoi/worktrees/<repository-hash>/<name>. Commits skip Git hooks, so run
your checks before merging. There is no automatic merge back. /agents clean
removes leftover clean worktrees only; branches are always kept.
This ordinary-agent behavior differs from Crew's default checkout mirror. Read Crew results before treating the two isolation options as interchangeable.
Set limits or define a role
User agent.json can set agents.maxBackground (default 3, range 1–8) and
agents.timeoutSeconds (default 1,800 seconds, range 60–7,200). Merge these
settings into the existing file; changes apply from your next message.
Custom agent Markdown files require name and description front matter.
They can specify a role, engine, provider, model, and supported tool names.
For duplicate names, later sources win: user ~/.kaitoi/agents, user
~/.claude/agents, project .claude/agents, then project .kaitoi/agents.
Project files win over user files, as for skills. Project roles
still require trust. Only compatible tool names are accepted; patterns such as
Bash(git:*) and MCP tool names are ignored.
Children cannot recursively delegate through the agent tools. Keep the task bounded enough to return an inspectable report, and verify its findings before acting on them.
Define permissions explicitly
Omitting role selects general, which can write and run commands. A
nonempty tools list replaces the role's effects rather than narrowing them:
role: reviewer with tools: Read, Bash permits commands. An empty list keeps
the role defaults. Accepted names are Read, Grep, Glob, LS, NotebookRead,
WebFetch, WebSearch, Edit, Write, MultiEdit, NotebookEdit and Bash.
For a read-only reviewer, save .kaitoi/agents/retry-review.md:
---
name: retry-review
description: Inspect retry behavior and report defects with file and line evidence.
role: reviewer
tools: Read, Grep, Glob
---
Inspect the requested paths without edits. Report only verified defects.
Last reviewed against Kaitoi on 26 October 2026. View this page as Markdown