/coder and /agent into an orchestration system where the LLM dispatches specialist agents in parallel to solve complex tasks faster and more efficiently.
Activation
The multi-agent mode is enabled by default. To disable it, set:When disabled,
/coder and /agent work exactly as before — with no impact.Architecture
<agent_call> tags:
Two Execution Modes
The orchestrator has two execution mechanisms, choosing the most appropriate one by context:| Mode | Syntax | When to Use |
|---|---|---|
| agent_call | <agent_call agent="..." task="..." /> | New work phases, parallel tasks, exploratory reading, multi-file refactoring |
| tool_call | <tool_call name="@coder" args="..." /> | Quick fixes, error diagnosis, point patches, post-agent validation. IMPORTANT: multiple independent tool_calls must be emitted in a SINGLE response |
Decision Guide
| Situation | Mode |
|---|---|
| Read multiple files + search references | agent_call (file + search in parallel) |
| Fix a compilation error | tool_call (direct patch) |
| Write a new module + tests | agent_call (coder + shell) |
| Verify an agent’s result | tool_call (quick read/exec) |
| Fix after agent failure | tool_call (precise diagnosis) |
| Resume after applied fix | agent_call (next phase) |
Embedded Specialist Agents
FileAgent (Reading and Analysis)
FileAgent (Reading and Analysis)
Access: Read-only (
read, tree, search)Skills:batch-read— Accelerator script: reads N files in parallel goroutines without calling the LLMfind-pattern— Searches for patterns in filesanalyze-structure— Analyzes code structuremap-deps— Maps dependencies between modules
CoderAgent (Writing and Modification)
CoderAgent (Writing and Modification)
Access: Read/Write (
write, patch, read, tree)Skills:write-file— Creating new filespatch-file— Precise modification of existing codecreate-module— Boilerplate generationrefactor— Safe renaming and refactoring
ShellAgent (Execution and Tests)
ShellAgent (Execution and Tests)
Access: Execution (
exec, test)Skills:run-tests— Accelerator script: runsgo test ./... -jsonand parses resultsbuild-check— Accelerator script: runsgo build ./... && go vet ./...lint-fix— Automatic lint correction
GitAgent (Version Control)
GitAgent (Version Control)
Access: Git ops (
git-status, git-diff, git-log, git-changed, git-branch, exec)Skills:smart-commit— Accelerator script: collects status + diff for intelligent commitreview-changes— Accelerator script: analyzes changes with changed + diff + logcreate-branch— Branch creation
SearchAgent (Codebase Search)
SearchAgent (Codebase Search)
Access: Read-only (
search, tree, read)Skills:find-usages— Finds symbol usagesfind-definition— Finds definitionsfind-dead-code— Detects dead codemap-project— Accelerator script: maps project in parallel (tree + interfaces + structs + funcs)
PlannerAgent (Pure Reasoning)
PlannerAgent (Pure Reasoning)
Access: None (no tools — pure LLM reasoning)Skills:
analyze-task— Complexity and risk analysiscreate-plan— Execution plan creationdecompose— Complex task decomposition
ReviewerAgent (Code Review and Quality)
ReviewerAgent (Code Review and Quality)
Access: Read-only (
read, search, tree)Skills:review-file— Analyzes files for bugs, code smells, SOLID violations, and security issuesdiff-review— Accelerator script: reviews staged changes via git-diff and git-changedscan-lint— Accelerator script: runsgo vetandstaticcheckand categorizes issues
TesterAgent (Tests and Coverage)
TesterAgent (Tests and Coverage)
Access: Read/Write/Execute (
read, write, patch, exec, test, search, tree)Skills:generate-tests— Comprehensive test generation for functions and packages (LLM-driven)run-coverage— Accelerator script: runsgo test -coverprofileand parses coverage per functionfind-untested— Accelerator script: finds exported functions without corresponding testsgenerate-table-test— Idiomatic Go table-driven test generation
RefactorAgent (Structural Transformations)
RefactorAgent (Structural Transformations)
Access: Read/Write (
read, write, patch, search, tree)Skills:rename-symbol— Accelerator script: renames symbol across all.gofiles, ignoring strings and commentsextract-interface— Extracts interface from a concrete type’s methodsmove-function— Moves function between packages adjusting importsinline-variable— Replaces variable with its value at all usage points
DiagnosticsAgent (Troubleshooting and Investigation)
DiagnosticsAgent (Troubleshooting and Investigation)
Access: Read/Execute (
read, search, tree, exec)Skills:analyze-error— Parses error messages and stack traces mapping to code locationscheck-deps— Accelerator script: runsgo mod tidy,go mod verifyand checks dependency healthbisect-bug— Guides investigation to find the commit that introduced a bugprofile-bottleneck— Runs benchmarks or pprof and analyzes performance hotspots
FormatterAgent (Formatting and Style)
FormatterAgent (Formatting and Style)
Access: Write/Execute (
read, patch, exec, tree)Skills:format-code— Accelerator script: runsgofmt -w(orgoimports -w) on Go filesfix-imports— Accelerator script: runsgoimportsto organize importsnormalize-style— Applies consistent naming and style conventions (LLM-driven)
DepsAgent (Dependency Management)
DepsAgent (Dependency Management)
Access: Read/Execute (
read, exec, search, tree)Skills:audit-deps— Accelerator script: runsgo mod verifyandgovulncheckfor auditingupdate-deps— Accelerator script: lists outdated dependencies with available updates (dry-run)why-dep— Accelerator script: explains why a dependency exists viago mod whyandgo mod graphfind-outdated— Finds all dependencies with newer versions available
Custom Agents as Workers
Agent personas defined in~/.chatcli/agents/ are automatically loaded as workers in the orchestration system when starting /coder or /agent. The LLM can dispatch them via <agent_call> with the same ReAct loop, parallel reading, and error recovery as the embedded agents.
How It Works
CustomAgent Creation
For each agent found, creates a
CustomAgent that implements the WorkerAgent interfaceTool Mapping
Thetools field in the YAML frontmatter maps Claude Code-style tools to @coder subcommands:
| Tool in YAML | @coder Command(s) | Description |
|---|---|---|
Read | read | Read file contents |
Grep | search | Search for patterns in files |
Glob | tree | List directories |
Bash | exec, test, git-status, git-diff, git-log, git-changed, git-branch | Execution and git operations |
Write | write | Create/overwrite files |
Edit | patch | Precise editing (search/replace) |
Custom Agent Example
Protection Rules
- No tools = read-only: Agents without a
toolsfield automatically receiveread,search,treeand are marked as read-only - Duplicates ignored: If two agents have the same name, only the first one is registered
Skills: Scripts vs Descriptive
Each agent has two types of skills:- Executable Skills (Accelerator Scripts)
- Descriptive Skills
Pre-defined command sequences that bypass the LLM for mechanical and repetitive operations, executing directly on the engine:
Skills V2 (Packages)
Skills V2 are directories containing:SKILL.md— Main content with frontmatter- Subskills (
.md) — Additional knowledge documents scripts/— Executable scripts automatically registered in the worker
read command and execute scripts with exec during its autonomous operation.
Error Recovery Strategy
When anagent_call fails, the orchestrator follows an intelligent recovery protocol:
Diagnosis via tool_call
Uses direct
tool_call to read relevant files and understand the error (already has the context)Key rule: Error recovery =
tool_call (fast, precise). New work phases = agent_call (parallel, scalable).Configuration
| Variable | Default | Description |
|---|---|---|
CHATCLI_AGENT_PARALLEL_MODE | true | Enables/disables multi-agent mode |
CHATCLI_AGENT_MAX_WORKERS | 4 | Maximum simultaneous goroutines |
CHATCLI_AGENT_WORKER_MAX_TURNS | 10 | Maximum turns per worker |
CHATCLI_AGENT_WORKER_TIMEOUT | 5m | Timeout per worker |
.env Example
Anti-Race Safety
The system implements multiple layers of protection against race conditions:FileLockManager
Per-filepath mutex (normalized absolute paths). Write operations acquire locks; reads do not block.
Isolated History
Each worker maintains its own
[]models.Message, with no sharing.Independent LLM Clients
Each worker creates its own LLM client instance via factory pattern.
Stateless Engine
Each worker instantiates its own fresh
engine.Engine.Context Tree
The parent context can cancel all workers via
context.WithCancel.Policy Enforcement
Workers fully respect the
coder_policy.json (allow/deny/ask). Actions with an “ask” policy pause the spinner and display a serialized security prompt to the user.Security Governance in Parallel Mode
Parallel workers respect all rules from thecoder_policy.json file (global and local). This means that actions like write, patch, exec go through the same policy verification as sequential mode.
Behavior by Rule Type
| Rule | Behavior in Worker |
|---|---|
| allow | Action executed automatically, without interruption |
| deny | Action silently blocked; worker receives [BLOCKED BY POLICY] error |
| ask | Worker pauses, spinner is suspended, and a security prompt is displayed to the user |
Prompt Serialization
When multiple workers need approval simultaneously, prompts are serialized via mutex — only one prompt is displayed at a time. After the user responds, the next worker in the queue receives its prompt. This prevents:- Visual overlap of prompts in the terminal
- stdin reading conflicts
- Spinner rendering over the security prompt
Prompt with Agent Context
The security prompt in parallel mode displays contextual information about which agent is requesting the action:Runtime Provider/Model Respect
Parallel workers always use the active provider and model at the time of dispatch. If the user switches providers (e.g., from Anthropic to Google AI) via/switch, the next agent dispatches will use the new provider correctly.
Execution Flow (Example)
Dispatcher creates goroutines
FileAgent and SearchAgent run in parallel, each with their own LLM client and isolated mini ReAct loop (within the maxWorkers limit).
Parallelism Maximization
ChatCLI’s prompt system explicitly instructs the AI to maximize parallelism at all levels:- tool_call: Independent operations (read 3 files, search + read) must be emitted in a SINGLE response, not in separate turns
- agent_call: For 3+ independent tasks, prefer
agent_callwhich runs in parallel goroutines - Per-turn anchor: Every ReAct loop turn, a reminder reinforces the need for parallelism
Compatibility
CHATCLI_AGENT_PARALLEL_MODE=false: everything works exactly as before<tool_call>tags continue to work even with parallel mode active- No existing function signatures were changed
- The
cli/agent/workers/package is completely isolated and does not impact existing functionality