Skip to content

Commit 365ce6b

Browse files
rumpldvdksn
authored andcommitted
cagent: completely document fundamentals
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent 2bb9483 commit 365ce6b

File tree

16 files changed

+3189
-356
lines changed

16 files changed

+3189
-356
lines changed

_vale/config/vocabularies/Docker/accept.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,6 @@ Zsh
292292
[Vv]irtiofs
293293
[Vv]irtualize
294294
[Ww]alkthrough
295+
[Tt]oolsets?
296+
[Rr]erank(ing|ed)?
295297

content/manuals/ai/cagent/_index.md

Lines changed: 112 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -5,236 +5,158 @@ weight: 60
55
params:
66
sidebar:
77
group: Open source
8+
badge:
9+
color: violet
10+
text: Experimental
811
keywords: [ai, agent, cagent]
912
---
1013

1114
{{< summary-bar feature_name="cagent" >}}
1215

13-
[cagent](https://github.com/docker/cagent) lets you build, orchestrate, and share
14-
AI agents. You can use it to define AI agents that work as a team.
16+
[cagent](https://github.com/docker/cagent) is an open source tool for building
17+
teams of specialized AI agents. Instead of prompting one generalist model, you
18+
define agents with specific roles and instructions that collaborate to solve
19+
problems. Run these agent teams from your terminal using any LLM provider.
1520

16-
cagent relies on the concept of a _root agent_ that acts as a team lead and
17-
delegates tasks to the sub-agents you define.
18-
Each agent:
19-
- uses the model of your choice, with the parameters of your choice.
20-
- has access to the [built-in tools](#built-in-tools) and MCP servers
21-
configured in the [Docker MCP gateway](/manuals/ai/mcp-catalog-and-toolkit/mcp-gateway.md).
22-
- works in its own context. They do not share knowledge.
21+
## Why agent teams
2322

24-
The root agent is your main contact point. Each agent has its own context,
25-
they don't share knowledge.
23+
One agent handling complex work means constant context-switching. Split the work
24+
across focused agents instead - each handles what it's best at. cagent manages
25+
the coordination.
2626

27-
## Key features
27+
Here's a two-agent team that debugs problems:
2828

29-
- ️Multi-tenant architecture with client isolation and session management.
30-
- Rich tool ecosystem via Model Context Protocol (MCP) integration.
31-
- Hierarchical agent system with intelligent task delegation.
32-
- Multiple interfaces including CLI, TUI, API server, and MCP server.
33-
- Agent distribution via Docker registry integration.
34-
- Security-first design with proper client scoping and resource isolation.
35-
- Event-driven streaming for real-time interactions.
36-
- Multi-model support (OpenAI, Anthropic, Gemini, DMR, Docker AI Gateway).
37-
38-
## Get started with cagent
39-
40-
1. The easiest way to get cagent is to [install Docker Desktop version 4.49 or later](/manuals/desktop/release-notes.md) for your operating system.
41-
42-
> [!NOTE]
43-
> You can also build cagent from the source. For more information, see the [cagent GitHub repository](https://github.com/docker/cagent?tab=readme-ov-file#build-from-source).
44-
45-
1. Set the following environment variables:
46-
47-
```bash
48-
export OPENAI_API_KEY=<your_api_key_here> # For OpenAI models
49-
export ANTHROPIC_API_KEY=<your_api_key_here> # For Anthropic models
50-
export GOOGLE_API_KEY=<your_api_key_here> # For Gemini models
51-
```
52-
53-
1. Create an agent by saving this sample as `assistant.yaml`:
54-
55-
```yaml {title="assistant.yaml"}
56-
agents:
57-
root:
58-
model: openai/gpt-5-mini
59-
description: A helpful AI assistant
60-
instruction: |
61-
You are a knowledgeable assistant that helps users with various tasks.
62-
Be helpful, accurate, and concise in your responses.
63-
```
64-
65-
1. Start your prompt with your agent:
66-
67-
```bash
68-
cagent run assistant.yaml
69-
```
70-
71-
## Create an agentic team
72-
73-
You can use AI prompting to generate a team of agents with the `cagent new`
74-
command:
75-
76-
```console
77-
$ cagent new
78-
79-
For any feedback, visit: https://docker.qualtrics.com/jfe/form/SV_cNsCIg92nQemlfw
80-
81-
Welcome to cagent! (Ctrl+C to exit)
82-
83-
What should your agent/agent team do? (describe its purpose):
84-
85-
> I need a cross-functional feature team. The team owns a specific product
86-
feature end-to-end. Include the key responsibilities of each of the roles
87-
involved (engineers, designer, product manager, QA). Keep the description
88-
short, clear, and focused on how this team delivers value to users and the business.
89-
```
90-
91-
Alternatively, you can write your configuration file manually. For example:
92-
93-
```yaml {title="agentic-team.yaml"}
29+
```yaml
9430
agents:
9531
root:
96-
model: claude
97-
description: "Main coordinator agent that delegates tasks and manages workflow"
32+
model: openai/gpt-5-mini # Change to the model that you want to use
33+
description: Bug investigator
9834
instruction: |
99-
You are the root coordinator agent. Your job is to:
100-
1. Understand user requests and break them down into manageable tasks.
101-
2. Delegate appropriate tasks to your helper agent.
102-
3. Coordinate responses and ensure tasks are completed properly.
103-
4. Provide final responses to the user.
104-
When you receive a request, analyze what needs to be done and decide whether to:
105-
- Handle it yourself if it's simple.
106-
- Delegate to the helper agent if it requires specific assistance.
107-
- Break complex requests into multiple sub-tasks.
108-
sub_agents: ["helper"]
35+
Analyze error messages, stack traces, and code to find bug root causes.
36+
Explain what's wrong and why it's happening.
37+
Delegate fix implementation to the fixer agent.
38+
sub_agents: [fixer]
39+
toolsets:
40+
- type: filesystem
41+
- type: mcp
42+
ref: docker:duckduckgo
10943

110-
helper:
111-
model: claude
112-
description: "Assistant agent that helps with various tasks as directed by the root agent"
44+
fixer:
45+
model: anthropic/claude-sonnet-4-5 # Change to the model that you want to use
46+
description: Fix implementer
11347
instruction: |
114-
You are a helpful assistant agent. Your role is to:
115-
1. Complete specific tasks assigned by the root agent.
116-
2. Provide detailed and accurate responses.
117-
3. Ask for clarification if tasks are unclear.
118-
4. Report back to the root agent with your results.
119-
120-
Focus on being thorough and helpful in whatever task you're given.
121-
122-
models:
123-
claude:
124-
provider: anthropic
125-
model: claude-sonnet-4-0
126-
max_tokens: 64000
127-
```
128-
129-
[See the reference documentation](https://github.com/docker/cagent?tab=readme-ov-file#-configuration-reference).
130-
131-
## Built-in tools
132-
133-
cagent includes a set of built-in tools that enhance your agents' capabilities.
134-
You don't need to configure any external MCP tools to use them.
135-
136-
```yaml
137-
agents:
138-
root:
139-
# ... other config
48+
Write fixes for bugs diagnosed by the investigator.
49+
Make minimal, targeted changes and add tests to prevent regression.
14050
toolsets:
141-
- type: todo
142-
- type: transfer_task
51+
- type: filesystem
52+
- type: shell
14353
```
14454
145-
### Think tool
55+
The root agent investigates and explains the problem. When it understands the
56+
issue, it hands off to `fixer` for implementation. Each agent stays focused on
57+
its specialty.
14658

147-
The think tool allows agents to reason through problems step by step:
59+
## Installation
14860

149-
```yaml
150-
agents:
151-
root:
152-
# ... other config
153-
toolsets:
154-
- type: think
155-
```
61+
cagent is included in Docker Desktop 4.49 and later.
15662

157-
### Todo tool
63+
For Docker Engine users or custom installations:
15864

159-
The todo tool helps agents manage task lists:
65+
- **Homebrew**: `brew install cagent`
66+
- **Winget**: `winget install Docker.Cagent`
67+
- **Pre-built binaries**: [GitHub
68+
releases](https://github.com/docker/cagent/releases)
69+
- **From source**: See the [cagent
70+
repository](https://github.com/docker/cagent?tab=readme-ov-file#build-from-source)
16071

161-
```yaml
162-
agents:
163-
root:
164-
# ... other config
165-
toolsets:
166-
- type: todo
167-
```
72+
## Get started
16873

169-
### Memory tool
74+
Try the bug analyzer team:
17075

171-
The memory tool provides persistent storage:
76+
1. Set your API key for the model provider you want to use:
17277

173-
```yaml
174-
agents:
175-
root:
176-
# ... other config
177-
toolsets:
178-
- type: memory
179-
path: "./agent_memory.db"
180-
```
181-
182-
### Task transfer tool
78+
```console
79+
$ export ANTHROPIC_API_KEY=<your_key> # For Claude models
80+
$ export OPENAI_API_KEY=<your_key> # For OpenAI models
81+
$ export GOOGLE_API_KEY=<your_key> # For Gemini models
82+
```
18383

184-
The task transfer tool is an internal tool that allows an agent to delegate a task
185-
to sub-agents. To prevent an agent from delegating work, make sure it doesn't have
186-
sub-agents defined in its configuration.
84+
2. Save the [example configuration](#why-agent-teams) as `debugger.yaml`.
18785

188-
### Using tools via the Docker MCP Gateway
86+
3. Run your agent team:
18987

190-
If you use the [Docker MCP gateway](/manuals/ai/mcp-catalog-and-toolkit/mcp-gateway.md),
191-
you can configure your agent to interact with the
192-
gateway and use the MCP servers configured in it. See [docker mcp
193-
gateway run](/reference/cli/docker/mcp/gateway/gateway_run.md).
88+
```console
89+
$ cagent run debugger.yaml
90+
```
19491

195-
For example, to enable an agent to use Duckduckgo via the MCP Gateway:
92+
You'll see a prompt where you can describe bugs or paste error messages. The
93+
investigator analyzes the problem, then hands off to the fixer for
94+
implementation.
19695

197-
```yaml
198-
toolsets:
199-
- type: mcp
200-
command: docker
201-
args: ["mcp", "gateway", "run", "--servers=duckduckgo"]
202-
```
96+
## How it works
20397

204-
## CLI interactive commands
98+
You interact with the _root agent_, which can delegate work to sub-agents you
99+
define. Each agent:
205100

206-
You can use the following CLI commands, during
207-
CLI sessions with your agents:
101+
- Uses its own model and parameters
102+
- Has its own context (agents don't share knowledge)
103+
- Can access built-in tools like todo lists, memory, and task delegation
104+
- Can use external tools via [MCP
105+
servers](/manuals/ai/mcp-catalog-and-toolkit/mcp-gateway.md)
208106

209-
| Command | Description |
210-
|----------|------------------------------------------|
211-
| /exit | Exit the program |
212-
| /reset | Clear conversation history |
213-
| /eval | Save current conversation for evaluation |
214-
| /compact | Compact the current session |
107+
The root agent delegates tasks to agents listed under `sub_agents`. Sub-agents
108+
can have their own sub-agents for deeper hierarchies.
215109

216-
## Share your agents
110+
## Configuration options
217111

218-
Agent configurations can be packaged and shared via Docker Hub.
219-
Before you start, make sure you have a [Docker repository](/manuals/docker-hub/repos/create.md).
112+
Agent configurations are YAML files. A basic structure looks like this:
220113

221-
To push an agent:
114+
```yaml
115+
agents:
116+
root:
117+
model: claude-sonnet-4-0
118+
description: Brief role summary
119+
instruction: |
120+
Detailed instructions for this agent...
121+
sub_agents: [helper]
222122
223-
```bash
224-
cagent push ./<agent-file>.yaml <namespace>/<reponame>
123+
helper:
124+
model: gpt-5-mini
125+
description: Specialist agent role
126+
instruction: |
127+
Instructions for the helper agent...
225128
```
226129

227-
To pull an agent to the current directory:
130+
You can also configure model settings (like context limits), tools (including
131+
MCP servers), and more. See the [configuration
132+
reference](./reference/config.md)
133+
for complete details.
228134

229-
```bash
230-
cagent pull <namespace>/<reponame>
231-
```
135+
## Share agent teams
232136

233-
The agent's configuration file is named `<namespace>_<reponame>.yaml`. Run
234-
it with the `cagent run <filename>` command.
137+
Agent configurations are packaged as OCI artifacts. Push and pull them like
138+
container images:
235139

236-
## Related pages
140+
```console
141+
$ cagent push ./debugger.yaml myusername/debugger
142+
$ cagent pull myusername/debugger
143+
```
237144

238-
- For more information about cagent, see the
239-
[GitHub repository](https://github.com/docker/cagent).
240-
- [Docker MCP Gateway](/manuals/ai/mcp-catalog-and-toolkit/mcp-gateway.md)
145+
Use Docker Hub or any OCI-compatible registry. Pushing creates the repository if
146+
it doesn't exist yet.
147+
148+
## What's next
149+
150+
- Follow the [tutorial](./tutorial.md) to build your first coding agent
151+
- Learn [best practices](./best-practices.md) for building effective agents
152+
- Integrate cagent with your [editor](./integrations/acp.md) or use agents as
153+
[tools in MCP clients](./integrations/mcp.md)
154+
- Browse example agent configurations in the [cagent
155+
repository](https://github.com/docker/cagent/tree/main/examples)
156+
- Use `cagent new` to generate agent teams with AI <!-- TODO: link to some page
157+
where we explain this, probably a CLI reference? -->
158+
- Connect agents to external tools via the [Docker MCP
159+
Gateway](/manuals/ai/mcp-catalog-and-toolkit/mcp-gateway.md)
160+
- Read the full [configuration
161+
reference](https://github.com/docker/cagent?tab=readme-ov-file#-configuration-reference)
162+
<!-- TODO: move to this site/repo -->

0 commit comments

Comments
 (0)