Skip to content

Commit 5d0e6ea

Browse files
authored
Merge pull request #414 from dgageot/update-claude-md
Update Claude.md
2 parents de682d7 + 5769dab commit 5d0e6ea

1 file changed

Lines changed: 87 additions & 59 deletions

File tree

CLAUDE.md

Lines changed: 87 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
99
- `task build` - Build the application binary
1010
- `task test` - Run Go tests
1111
- `task lint` - Run golangci-lint
12+
- `task format` - Format code
1213
- `task link` - Create symlink to ~/bin for easy access
1314

1415
### Docker Operations
1516

1617
- `task build-image` - Build Docker image
18+
- `task push-image` - Build and push Docker image
1719
- `task build-local` - Build binaries for local platform using Docker
1820
- `task cross` - Build cross-platform binaries using Docker
1921

2022
### Running cagent
2123

22-
- `./bin/cagent run <config.yaml>` - Run agent with configuration
24+
- `./bin/cagent run <config.yaml>` - Run agent with configuration (uses TUI by default)
25+
- `./bin/cagent run <config.yaml> --tui=false` - Run in CLI mode
2326
- `./bin/cagent run <config.yaml> -a <agent_name>` - Run specific agent
24-
- `./bin/cagent init` - Initialize new project
27+
- `./bin/cagent exec <config.yaml>` - Execute agent without TUI
2528

2629
### Single Test Execution
2730

@@ -35,14 +38,6 @@ cagent is a multi-agent AI system with hierarchical agent structure and pluggabl
3538

3639
### Core Components
3740

38-
#### ServiceCore Layer (`pkg/servicecore/`)
39-
40-
- **Multi-tenant architecture**: Client-isolated operations ensuring security between different users
41-
- **Transport-agnostic design**: Core business logic independent of MCP/HTTP transport specifics
42-
- **Agent resolution**: File-based and Docker store-based agent discovery with explicit reference formatting
43-
- **Session management**: Per-client session lifecycle with proper resource cleanup
44-
- **Security-first design**: All operations require client ID scoping, preventing cross-client data access
45-
4641
#### Agent System (`pkg/agent/`)
4742

4843
- **Agent struct**: Core abstraction with name, description, instruction, toolsets, models, and sub-agents
@@ -56,27 +51,21 @@ cagent is a multi-agent AI system with hierarchical agent structure and pluggabl
5651
- **Tool execution**: Handles tool calls and coordinates between agents and external tools
5752
- **Session management**: Maintains conversation state and message history
5853
- **Task delegation**: Routes tasks between agents using transfer_task tool
54+
- **Remote runtime support**: Can connect to remote runtime servers
5955

6056
#### Configuration System (`pkg/config/`)
6157

6258
- **YAML-based configuration**: Declarative agent, model, and tool definitions
63-
- **Agent properties**: name, model, description, instruction, sub_agents, toolsets, think, todo, memory, add_date, add_environment_info
64-
- **Model providers**: openai, anthropic, dmr with configurable parameters
65-
- **Tool configuration**: MCP tools (local stdio and remote), builtin tools (filesystem, shell)
59+
- **Agent properties**: name, model, description, instruction, sub_agents, toolsets, add_date, add_environment_info, code_mode_tools, max_iterations, num_history_items
60+
- **Model providers**: openai, anthropic, gemini, dmr with configurable parameters
61+
- **Tool configuration**: MCP tools (local stdio and remote), builtin tools (filesystem, shell, think, todo, memory, etc.)
6662

6763
#### Command Layer (`cmd/root/`)
6864

69-
- **Multiple interfaces**: CLI (`run.go`), TUI (`tui.go`), API (`api.go`)
70-
- **Interactive commands**: `/exit`, `/reset`, `/eval` during sessions
65+
- **Multiple interfaces**: CLI (`run.go`), TUI (default for `run` command), API (`api.go`)
66+
- **Interactive commands**: `/exit`, `/reset`, `/eval`, `/usage`, `/compact` during sessions
7167
- **Debug support**: `--debug` flag for detailed logging
72-
- **MCP server mode**: SSE-based transport for external MCP clients like Claude Code
73-
74-
#### MCP Server (`pkg/mcpserver/`)
75-
76-
- **Protocol compliance**: Full MCP specification implementation with SSE transport
77-
- **Tool handlers**: Agent listing, invocation, session management, and Docker image operations
78-
- **Client isolation**: Per-client contexts preventing cross-client interference
79-
- **Structured responses**: Explicit agent_ref formatting for file vs store-based agents
68+
- **Gateway mode**: SSE-based transport for external MCP clients like Claude Code
8069

8170
### Tool System (`pkg/tools/`)
8271

@@ -88,21 +77,26 @@ cagent is a multi-agent AI system with hierarchical agent structure and pluggabl
8877
- **transfer_task**: Agent-to-agent task delegation
8978
- **filesystem**: File operations
9079
- **shell**: Command execution
80+
- **script**: Custom shell scripts
81+
- **fetch**: HTTP requests
9182

9283
#### MCP Integration
9384

9485
- **Local MCP servers**: stdio-based tools via command execution
9586
- **Remote MCP servers**: SSE/streamable transport for remote tools
87+
- **Docker-based MCP**: Reference MCP servers from Docker images (e.g., `docker:github-official`)
9688
- **Tool filtering**: Optional tool whitelisting per agent
9789

9890
### Key Patterns
9991

10092
#### Agent Configuration
10193

10294
```yaml
95+
version: "2"
96+
10397
agents:
10498
root:
105-
model: model_ref
99+
model: model_ref # Can be inline like "openai/gpt-4o" or reference defined models
106100
description: purpose
107101
instruction: detailed_behavior
108102
sub_agents: [list]
@@ -111,8 +105,14 @@ agents:
111105
- type: think
112106
- type: todo
113107
- type: memory
114-
path: { path: string }
108+
path: ./path/to/db
115109
- ...
110+
111+
models:
112+
model_ref:
113+
provider: anthropic
114+
model: claude-sonnet-4-0
115+
max_tokens: 64000
116116
```
117117
118118
#### Task Delegation Flow
@@ -140,7 +140,7 @@ agents:
140140
### Configuration Validation
141141

142142
- All agent references must exist in config
143-
- Model references must be defined
143+
- Model references can be inline (e.g., `openai/gpt-4o`) or defined in models section
144144
- Tool configurations validated at startup
145145

146146
### Adding New Features
@@ -150,30 +150,10 @@ agents:
150150
- Add configuration support if needed
151151
- Consider both CLI and TUI interface impacts, along with API server impacts
152152

153-
### Key Patterns
154-
155-
#### Agent Reference Formatting
156-
157-
- **File agents**: Use relative path from agents directory (e.g., `agent.yaml`)
158-
- **Store agents**: Use full Docker image reference with tag (e.g., `user/agent:latest`)
159-
- **Explicit agent_ref field**: MCP responses include unambiguous agent reference for tool calls
160-
161-
#### MCP vs HTTP API
162-
163-
- **MCP Server**: Designed for multi-tenant with client isolation, secure by design, recommended for external integrations
164-
- **HTTP API**: Legacy single-tenant mode, no client isolation, used for backward compatibility
165-
- **ServiceCore abstraction**: Shared business logic between both transport layers
166-
167-
#### Current Multi-Tenant Limitation
168-
169-
- **ServiceCore layer**: Fully supports multi-tenant operation with client isolation
170-
- **MCP implementation**: Client ID extraction from MCP context is not yet implemented
171-
- **Current behavior**: All MCP clients use `DEFAULT_CLIENT_ID` ("\_\_global"), making them effectively share sessions
172-
- **Impact**: Multiple MCP clients can see and interact with each other's agent sessions
173-
- **Recommendation**: Use single MCP client per cagent instance until full multi-tenant support is implemented
174-
175153
## Model Provider Configuration Examples
176154

155+
Models can be referenced inline (e.g., `openai/gpt-4o`) or defined explicitly:
156+
177157
### OpenAI
178158

179159
```yaml
@@ -205,6 +185,15 @@ models:
205185
temperature: 0.5
206186
```
207187

188+
### DMR
189+
190+
```yaml
191+
models:
192+
dmr:
193+
provider: dmr
194+
model: ai/llama3.2
195+
```
196+
208197
## Tool Configuration Examples
209198

210199
### Local MCP Server (stdio)
@@ -216,7 +205,7 @@ toolsets:
216205
args: ["-m", "mcp_server"]
217206
tools: ["specific_tool"] # optional filtering
218207
env:
219-
- "API_KEY=value"
208+
API_KEY: "value"
220209
```
221210

222211
### Remote MCP Server (SSE)
@@ -231,6 +220,16 @@ toolsets:
231220
Authorization: "Bearer token"
232221
```
233222

223+
### Docker-based MCP Server
224+
225+
```yaml
226+
toolsets:
227+
- type: mcp
228+
ref: docker:github-official
229+
instruction: |
230+
Use these tools to help with GitHub tasks.
231+
```
232+
234233
### Memory Tool with Custom Path
235234

236235
```yaml
@@ -239,75 +238,104 @@ toolsets:
239238
path: "./agent_memory.db"
240239
```
241240

241+
### Shell Tool
242+
243+
```yaml
244+
toolsets:
245+
- type: shell
246+
```
247+
248+
### Filesystem Tool
249+
250+
```yaml
251+
toolsets:
252+
- type: filesystem
253+
```
254+
242255
## Common Development Patterns
243256

244257
### Agent Hierarchy Example
245258

246259
```yaml
260+
version: "2"
261+
247262
agents:
248263
root:
249-
model: claude
264+
model: anthropic/claude-sonnet-4-0
250265
description: "Main coordinator"
251266
sub_agents: ["researcher", "writer"]
252267
toolsets:
253268
- type: transfer_task
254269
- type: think
255270
256271
researcher:
257-
model: gpt4
272+
model: openai/gpt-4o
258273
description: "Research specialist"
259274
toolsets:
260275
- type: mcp
261-
command: "web_search_tool"
276+
ref: docker:search-tools
262277
263278
writer:
264-
model: claude
279+
model: anthropic/claude-sonnet-4-0
265280
description: "Writing specialist"
266281
toolsets:
267282
- type: filesystem
268283
- type: memory
284+
path: ./writer_memory.db
269285
```
270286

271287
### Session Commands During CLI Usage
272288

273289
- `/exit` - End the session
274290
- `/reset` - Clear session history
275-
- `/eval <expression>` - Evaluate expression (debug mode)
291+
- `/usage` - Show token usage statistics
292+
- `/compact` - Generate summary and compact session history
293+
- `/eval` - Save evaluation data
276294

277295
## File Locations and Patterns
278296

279297
### Key Package Structure
280298

281-
- `pkg/servicecore/` - Multi-tenant business logic layer
282299
- `pkg/agent/` - Core agent abstraction and management
283300
- `pkg/runtime/` - Event-driven execution engine
284301
- `pkg/tools/` - Built-in and MCP tool implementations
285302
- `pkg/model/provider/` - AI provider implementations
286303
- `pkg/session/` - Conversation state management
287304
- `pkg/config/` - YAML configuration parsing and validation
288-
- `pkg/mcpserver/` - MCP protocol server implementation
305+
- `pkg/gateway/` - MCP gateway/server implementation
306+
- `pkg/tui/` - Terminal User Interface components
307+
- `pkg/api/` - API server implementation
289308

290309
### Configuration File Locations
291310

292-
- `examples/config/` - Sample agent configurations
311+
- `examples/` - Sample agent configurations
293312
- Root directory - Main project configurations (`Taskfile.yml`, `go.mod`)
294313

295314
### Environment Variables
296315

297316
- `OPENAI_API_KEY` - OpenAI authentication
298317
- `ANTHROPIC_API_KEY` - Anthropic authentication
299318
- `GOOGLE_API_KEY` - Google/Gemini authentication
300-
- `MCP_SSE_ENDPOINT` - Override MCP test endpoint
319+
- `TELEMETRY_ENABLED` - Control telemetry (set to false to disable)
320+
- `CAGENT_HIDE_TELEMETRY_BANNER` - Hide telemetry banner message
321+
- `CAGENT_HIDE_FEEDBACK_LINK` - Hide feedback link
301322

302323
## Debugging and Troubleshooting
303324

304325
### Debug Mode
305326

306327
- Add `--debug` flag to any command for detailed logging
328+
- Logs written to `~/.cagent/cagent.debug.log` by default
329+
- Use `--log-file <path>` to specify custom log location
307330
- Example: `./bin/cagent run config.yaml --debug`
308331

332+
### OpenTelemetry Tracing
333+
334+
- Add `--otel` flag to enable OpenTelemetry tracing
335+
- Example: `./bin/cagent run config.yaml --otel`
336+
309337
### Common Issues
310338

311339
- **Agent not found**: Check agent name matches config file agent definitions
312340
- **Tool startup failures**: Verify MCP tool commands and dependencies are available
313-
- **Multi-tenant sessions**: Remember all MCP clients currently share sessions
341+
- **Model not found**: Ensure model is defined in config or use inline format (provider/model)

0 commit comments

Comments
 (0)