|
| 1 | +--- |
| 2 | +title: cagent |
| 3 | +description: cagent lets you build, orchestrate, and share AI agents that work together as a team. |
| 4 | +weight: 60 |
| 5 | +params: |
| 6 | + sidebar: |
| 7 | + group: Open source |
| 8 | +keywords: [ai, agent, cagent] |
| 9 | +--- |
| 10 | + |
| 11 | +{{< summary-bar feature_name="cagent" >}} |
| 12 | + |
| 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. |
| 15 | + |
| 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-gateway/_index.md). |
| 22 | +- works in its own context. They do not share knowledge. |
| 23 | + |
| 24 | +The root agent is your main contact point. Each agent has its own context, |
| 25 | +they don't share knowledge. |
| 26 | + |
| 27 | +## Key features |
| 28 | + |
| 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. Download the [latest release](https://github.com/docker/cagent/releases) |
| 41 | + for your operating system. |
| 42 | + |
| 43 | + > [!NOTE] |
| 44 | + > You might need to give the binary executable permissions. |
| 45 | + > On macOS and Linux, run: |
| 46 | +
|
| 47 | + ```console |
| 48 | + chmod +x /path/to/downloads/cagent-linux-<arm/amd>64 |
| 49 | + ``` |
| 50 | + |
| 51 | + > [!NOTE] |
| 52 | + > You can also build cagent from the source. See the [repository](https://github.com/docker/cagent?tab=readme-ov-file#build-from-source). |
| 53 | + |
| 54 | +1. Optional: Rename the binary as needed and update your PATH to include |
| 55 | + cagent's executable. |
| 56 | + |
| 57 | +1. Set the following environment variables: |
| 58 | + |
| 59 | + ```bash |
| 60 | + # If using the Docker AI Gateway, set this environment variable or use |
| 61 | + # the `--models-gateway <url_to_docker_ai_gateway>` CLI flag |
| 62 | + |
| 63 | + export CAGENT_MODELS_GATEWAY=<url_to_docker_ai_gateway> |
| 64 | + |
| 65 | + # Alternatively, set keys for remote inference services. |
| 66 | + # These are not needed if you are using Docker AI Gateway. |
| 67 | + |
| 68 | + export OPENAI_API_KEY=<your_api_key_here> # For OpenAI models |
| 69 | + export ANTHROPIC_API_KEY=<your_api_key_here> # For Anthropic models |
| 70 | + export GOOGLE_API_KEY=<your_api_key_here> # For Gemini models |
| 71 | + ``` |
| 72 | + |
| 73 | +1. Create an agent by saving this sample as `assistant.yaml`: |
| 74 | + |
| 75 | + ```yaml {title="assistant.yaml"} |
| 76 | + agents: |
| 77 | + root: |
| 78 | + model: openai/gpt-5-mini |
| 79 | + description: A helpful AI assistant |
| 80 | + instruction: | |
| 81 | + You are a knowledgeable assistant that helps users with various tasks. |
| 82 | + Be helpful, accurate, and concise in your responses. |
| 83 | + ``` |
| 84 | +
|
| 85 | +1. Start your prompt with your agent: |
| 86 | +
|
| 87 | + ```bash |
| 88 | + cagent run assistant.yaml |
| 89 | + ``` |
| 90 | + |
| 91 | +## Create an agentic team |
| 92 | + |
| 93 | +You can use AI prompting to generate a team of agents with the `cagent new` |
| 94 | +command: |
| 95 | + |
| 96 | +```console |
| 97 | +$ cagent new |
| 98 | + |
| 99 | +For any feedback, visit: https://docker.qualtrics.com/jfe/form/SV_cNsCIg92nQemlfw |
| 100 | + |
| 101 | +Welcome to cagent! (Ctrl+C to exit) |
| 102 | + |
| 103 | +What should your agent/agent team do? (describe its purpose): |
| 104 | + |
| 105 | +> I need a cross-functional feature team. The team owns a specific product |
| 106 | + feature end-to-end. Include the key responsibilities of each of the roles |
| 107 | + involved (engineers, designer, product manager, QA). Keep the description |
| 108 | + short, clear, and focused on how this team delivers value to users and the business. |
| 109 | +``` |
| 110 | + |
| 111 | +Alternatively, you can write your configuration file manually. For example: |
| 112 | + |
| 113 | +```yaml {title="agentic-team.yaml"} |
| 114 | +agents: |
| 115 | + root: |
| 116 | + model: claude |
| 117 | + description: "Main coordinator agent that delegates tasks and manages workflow" |
| 118 | + instruction: | |
| 119 | + You are the root coordinator agent. Your job is to: |
| 120 | + 1. Understand user requests and break them down into manageable tasks. |
| 121 | + 2. Delegate appropriate tasks to your helper agent. |
| 122 | + 3. Coordinate responses and ensure tasks are completed properly. |
| 123 | + 4. Provide final responses to the user. |
| 124 | + When you receive a request, analyze what needs to be done and decide whether to: |
| 125 | + - Handle it yourself if it's simple. |
| 126 | + - Delegate to the helper agent if it requires specific assistance. |
| 127 | + - Break complex requests into multiple sub-tasks. |
| 128 | + sub_agents: ["helper"] |
| 129 | + |
| 130 | + helper: |
| 131 | + model: claude |
| 132 | + description: "Assistant agent that helps with various tasks as directed by the root agent" |
| 133 | + instruction: | |
| 134 | + You are a helpful assistant agent. Your role is to: |
| 135 | + 1. Complete specific tasks assigned by the root agent. |
| 136 | + 2. Provide detailed and accurate responses. |
| 137 | + 3. Ask for clarification if tasks are unclear. |
| 138 | + 4. Report back to the root agent with your results. |
| 139 | +
|
| 140 | + Focus on being thorough and helpful in whatever task you're given. |
| 141 | +
|
| 142 | +models: |
| 143 | + claude: |
| 144 | + provider: anthropic |
| 145 | + model: claude-sonnet-4-0 |
| 146 | + max_tokens: 64000 |
| 147 | +``` |
| 148 | +
|
| 149 | +[See the reference documentation](https://github.com/docker/cagent?tab=readme-ov-file#-configuration-reference). |
| 150 | +
|
| 151 | +## Built-in tools |
| 152 | +
|
| 153 | +cagent includes a set of built-in tools that enhance your agents' capabilities. |
| 154 | +You don't need to configure any external MCP tools to use them. |
| 155 | +
|
| 156 | +```yaml |
| 157 | +agents: |
| 158 | + root: |
| 159 | + # ... other config |
| 160 | + toolsets: |
| 161 | + - type: todo |
| 162 | + - type: transfer_task |
| 163 | +``` |
| 164 | +
|
| 165 | +### Think tool |
| 166 | +
|
| 167 | +The think tool allows agents to reason through problems step by step: |
| 168 | +
|
| 169 | +```yaml |
| 170 | +agents: |
| 171 | + root: |
| 172 | + # ... other config |
| 173 | + toolsets: |
| 174 | + - type: think |
| 175 | +``` |
| 176 | +
|
| 177 | +### Todo tool |
| 178 | +
|
| 179 | +The todo tool helps agents manage task lists: |
| 180 | +
|
| 181 | +```yaml |
| 182 | +agents: |
| 183 | + root: |
| 184 | + # ... other config |
| 185 | + toolsets: |
| 186 | + - type: todo |
| 187 | +``` |
| 188 | +
|
| 189 | +### Memory tool |
| 190 | +
|
| 191 | +The memory tool provides persistent storage: |
| 192 | +
|
| 193 | +```yaml |
| 194 | +agents: |
| 195 | + root: |
| 196 | + # ... other config |
| 197 | + toolsets: |
| 198 | + - type: memory |
| 199 | + path: "./agent_memory.db" |
| 200 | +``` |
| 201 | +
|
| 202 | +### Task transfer tool |
| 203 | +
|
| 204 | +The task transfer tool is an internal tool that allows an agent to delegate a task |
| 205 | +to sub-agents. To prevent an agent from delegating work, make sure it doesn't have |
| 206 | +sub-agents defined in its configuration. |
| 207 | +
|
| 208 | +### Using tools via the Docker MCP Gateway |
| 209 | +
|
| 210 | +If you use the [Docker MCP gateway](/manuals/ai/mcp-gateway.md), |
| 211 | +you can configure your agent to interact with the |
| 212 | +gateway and use the MCP servers configured in it. See [docker mcp |
| 213 | +gateway run](/reference/cli/docker/mcp/gateway/gateway_run.md). |
| 214 | +
|
| 215 | +For example, to enable an agent to use Duckduckgo via the MCP Gateway: |
| 216 | +
|
| 217 | +```yaml |
| 218 | +toolsets: |
| 219 | + - type: mcp |
| 220 | + command: docker |
| 221 | + args: ["mcp", "gateway", "run", "--servers=duckduckgo"] |
| 222 | +``` |
| 223 | +
|
| 224 | +## CLI interactive commands |
| 225 | +
|
| 226 | +You can use the following CLI commands, during |
| 227 | +CLI sessions with your agents: |
| 228 | +
|
| 229 | +| Command | Description | |
| 230 | +|----------|------------------------------------------| |
| 231 | +| /exit | Exit the program | |
| 232 | +| /reset | Clear conversation history | |
| 233 | +| /eval | Save current conversation for evaluation | |
| 234 | +| /compact | Compact the current session | |
| 235 | +
|
| 236 | +## Share your agents |
| 237 | +
|
| 238 | +Agent configurations can be packaged and shared via Docker Hub. |
| 239 | +Before you start, make sure you have a [Docker repository](/manuals/docker-hub/repos/create.md). |
| 240 | +
|
| 241 | +To push an agent: |
| 242 | +
|
| 243 | +```bash |
| 244 | +cagent push ./<agent-file>.yaml <namespace>/<reponame> |
| 245 | +``` |
| 246 | + |
| 247 | +To pull an agent to the current directory: |
| 248 | + |
| 249 | +```bash |
| 250 | +cagent pull <namespace>/<reponame> |
| 251 | +``` |
| 252 | + |
| 253 | +The agent's configuration file is named `<namespace>_<reponame>.yaml`. Run |
| 254 | +it with the `cagent run <filename>` command. |
| 255 | + |
| 256 | +## Related pages |
| 257 | + |
| 258 | +- For more information about cagent, see the |
| 259 | +[GitHub repository](https://github.com/docker/cagent). |
| 260 | +- [Docker MCP Gateway](/manuals/ai/mcp-gateway/_index.md) |
0 commit comments