Skip to content

Commit 16d358f

Browse files
committed
Implement add_environment_info
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent d66fa53 commit 16d358f

6 files changed

Lines changed: 23 additions & 13 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ cagent is a multi-agent AI system with hierarchical agent structure and pluggabl
6666
#### Configuration System (`pkg/config/`)
6767

6868
- **YAML-based configuration**: Declarative agent, model, and tool definitions
69-
- **Agent properties**: name, model, description, instruction, sub_agents, toolsets, think, todo, memory, add_date
69+
- **Agent properties**: name, model, description, instruction, sub_agents, toolsets, think, todo, memory, add_date, add_environment_info
7070
- **Model providers**: openai, anthropic, dmr with configurable parameters
7171
- **Tool configuration**: MCP tools (local stdio and remote), builtin tools (filesystem, shell)
7272

docs/USAGE.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,16 @@ During CLI sessions, you can use special commands:
8080

8181
### Agent Properties
8282

83-
| Property | Type | Description | Required |
84-
|---------------|---------|--------------------------------|----------|
85-
| `name` | string | Agent identifier ||
86-
| `model` | string | Model reference ||
87-
| `description` | string | Agent purpose ||
88-
| `instruction` | string | Detailed behavior instructions ||
89-
| `sub_agents` | array | List of sub-agent names ||
90-
| `toolsets` | array | Available tools ||
91-
| `add_date` | boolean | Add current date to context ||
83+
| Property | Type | Description | Required |
84+
|------------------------|---------|-----------------------------------------------------------------|----------|
85+
| `name` | string | Agent identifier ||
86+
| `model` | string | Model reference ||
87+
| `description` | string | Agent purpose ||
88+
| `instruction` | string | Detailed behavior instructions ||
89+
| `sub_agents` | array | List of sub-agent names ||
90+
| `toolsets` | array | Available tools ||
91+
| `add_date` | boolean | Add current date to context ||
92+
| `add_environment_info` | boolean | Add information about the environment (working dir, OS, git...) ||
9293

9394
#### Example
9495

@@ -101,6 +102,7 @@ agents:
101102
tools: [] # Available tools (optional)
102103
sub_agents: [] # Sub-agent names (optional)
103104
add_date: boolean # Add current date to context (optional)
105+
add_environment_info: boolean # Add information about the environment (working dir, OS, git...) (optional)
104106
```
105107
106108
### Model Properties

examples/gopher.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ agents:
6262
- `task build` - Build the application binary
6363
- `task test` - Run Go tests
6464
- `task lint` - Run golangci-lint for code quality
65-
65+
add_date: true
66+
add_environment_info: true
6667
toolsets:
6768
- type: think
6869
- type: filesystem

golang_developer.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ agents:
9090
9191
**Configuration System** (`pkg/config/`):
9292
- YAML-based declarative agent, model, and tool definitions
93-
- Support for agent properties: name, model, description, instruction, sub_agents, toolsets, think, todo, memory, add_date
93+
- Support for agent properties: name, model, description, instruction, sub_agents, toolsets, think, todo, memory, add_date, add_environment_info
9494
- Model provider configuration for openai, anthropic, dmr
9595
- Tool configuration for MCP tools and builtin tools (filesystem, shell)
9696

internal/creator/instructions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ agent_name:
2727
toolsets: [] # Available tools (optional)
2828
sub_agents: [] # Sub-agent names (optional)
2929
add_date: boolean # Add current date to context (optional)
30+
add_environment_info: boolean # Add information about the environment (working dir, OS, git...) (optional)
3031
```
3132

3233
**Each model can have a list of toolsets**

pkg/session/session.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package session
22

33
import (
44
"log/slog"
5+
"os"
56
"strings"
67
"time"
78

@@ -213,7 +214,12 @@ func (s *Session) GetMessages(a *agent.Agent) []chat.Message {
213214
}
214215

215216
if a.AddEnvironmentInfo() {
216-
content += "\n\n" + getEnvironmentInfo(s.GetWorkingDir())
217+
wd, err := os.Getwd()
218+
if err != nil {
219+
slog.Error("getting current working directory for environment info", "error", err)
220+
} else {
221+
content += "\n\n" + getEnvironmentInfo(wd)
222+
}
217223
}
218224

219225
messages = append(messages, chat.Message{

0 commit comments

Comments
 (0)