Subagents

Delegate a task to a subagent, choose its kind and its model, and follow its work.

A subagent is a second agent that a session starts for one task. The agent starts subagents on its own when a task splits into independent parts, and /agent starts one by hand.

Starting one

/agent researcher Find every place the checkout total is rounded

/agent <kind> <prompt> starts a subagent of that kind. Bare /agent opens a picker of the kinds.

Kind Role
general Reads, edits, runs commands and checks its work. The default.
planner Reads the code and writes a plan without carrying it out.
researcher Answers a question about the code or the web, with evidence for each claim.
security-reviewer Reviews a change for security issues without modifying anything.
advisor Gives a read-only second opinion from a different model.

Inherited or fresh context

A subagent starts from a copy of the session’s conversation, so it knows what was already found and decided. A kind that says context: fresh starts from the prompt alone, which suits an independent review.

Following its work

The chat shows a row for each subagent the session starts. /agents opens the Subagents and jobs panel, which lists every subagent of the session with its state, what it is doing and a timer. A row opens a page with Stop and Open conversation, which shows the subagent’s transcript beside the chat.

A session runs up to ten subagents at once (subagent.max_concurrent_per_session).

Models

A subagent runs on the model its kind names, else on one from the session’s helper pool, else on the session’s own model. /subagent picks the pool; with several models in it, each subagent takes one at random. The advisor runs on the model set in Settings › Subagents › Advisor model.

Custom kinds

A Markdown file in ~/.kcode/agents/ or <project>/.kcode/agents/ adds a kind. Its front matter names the kind and its tools, and its body is the kind’s instructions:

---
name: docs-writer
description: Writes and edits documentation only
tools: [fs_read, fs_write, fs_edit, grep]
---
You write documentation. Keep sentences short.
Never edit files outside docs/.

The agent kinds reference describes each built-in kind.

Product video