Skip to content

Commit 7918ce0

Browse files
docs: document AgentConfig file schema
1 parent 04278ae commit 7918ce0

File tree

3 files changed

+115
-1
lines changed

3 files changed

+115
-1
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# AgentConfig File Reference
2+
3+
`AgentConfig.from_file()` loads `.yaml`, `.yml`, and `.json` files into the
4+
`AgentConfig` dataclass in `packages/agent-os/src/agent_os/base_agent.py`.
5+
6+
Use [`../examples/agent_config.yaml`](../examples/agent_config.yaml) as the
7+
baseline example when creating new agent configs.
8+
9+
## Supported file keys
10+
11+
| Field | Type | Required | Default | Notes |
12+
|-------|------|----------|---------|-------|
13+
| `agent_id` | string | Yes, in practice | `"agent"` when omitted | Must match `^[a-zA-Z0-9][a-zA-Z0-9-]{2,63}$`. Set this explicitly to avoid collisions between agents. |
14+
| `agentId` | string | No | None | Camel-case alias accepted only when `agent_id` is absent. Prefer `agent_id` in new configs. |
15+
| `policies` | array of strings | No | `[]` | Policy names copied into every execution context created by the agent. |
16+
| `metadata` | mapping | No | `{}` | Free-form metadata copied into the execution context before each request. |
17+
| `max_audit_log_size` | integer | No | `10000` | Maximum number of in-memory audit entries retained by `BaseAgent`. |
18+
| `max_metadata_size_bytes` | integer | No | `1048576` | Per-value byte limit checked when metadata is copied into a new execution context. |
19+
20+
## Constructor-only fields
21+
22+
The `AgentConfig` dataclass also accepts `state_backend` when instantiated in
23+
Python, but `from_file()` does not read a `state_backend` key from YAML or JSON
24+
files. Configure custom state backends in code:
25+
26+
```python
27+
from agent_os.base_agent import AgentConfig
28+
from agent_os.state_backends import InMemoryStateBackend
29+
30+
config = AgentConfig(
31+
agent_id="agent-with-custom-state",
32+
state_backend=InMemoryStateBackend(),
33+
)
34+
```
35+
36+
## Validation rules
37+
38+
### `agent_id`
39+
40+
- Minimum length: 3 characters
41+
- Maximum length: 64 characters
42+
- First character: letter or number
43+
- Remaining characters: letters, numbers, or `-`
44+
45+
Examples:
46+
47+
- Valid: `research-agent-01`
48+
- Invalid: `my_agent` because `_` is not allowed
49+
- Invalid: `ab` because it is too short
50+
51+
### `metadata`
52+
53+
Metadata is accepted as free-form YAML/JSON, but each value is size-checked
54+
later when `BaseAgent` creates a new execution context. If any single value
55+
exceeds `max_metadata_size_bytes`, Agent OS raises a `ValueError`.
56+
57+
## Valid example
58+
59+
```yaml
60+
agent_id: review-agent-01
61+
policies:
62+
- read_only
63+
- no_pii
64+
metadata:
65+
environment: staging
66+
owner: team-platform
67+
max_audit_log_size: 5000
68+
max_metadata_size_bytes: 262144
69+
```
70+
71+
## Invalid examples
72+
73+
### Invalid `agent_id`
74+
75+
```yaml
76+
agent_id: my_agent
77+
policies:
78+
- read_only
79+
```
80+
81+
This fails validation because `agent_id` contains `_`.
82+
83+
### Metadata value too large at runtime
84+
85+
```yaml
86+
agent_id: oversized-metadata-demo
87+
metadata:
88+
huge_blob: "<very large string or object here>"
89+
max_metadata_size_bytes: 1024
90+
```
91+
92+
This file can load successfully, but `BaseAgent` raises a `ValueError` when it
93+
builds an execution context if `huge_blob` is larger than 1024 bytes.

packages/agent-os/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Learn by doing with our Jupyter notebooks:
3838
### 🔧 Reference
3939

4040
- [Framework Integrations](integrations.md) - LangChain, OpenAI, CrewAI
41+
- [AgentConfig File Reference](agent-config-reference.md) - Supported YAML keys and validation rules
4142
- [Dependencies](dependencies.md) - Package dependencies
4243
- [Security Specification](security-spec.md) - Security model
4344
- [FAQ](faq.md) - Common questions and answers
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
# Example Agent OS configuration file
1+
# Example Agent OS configuration file.
22
# Load with: AgentConfig.from_file("examples/agent_config.yaml")
3+
# Supported keys are documented in ../docs/agent-config-reference.md.
34

5+
# Required in practice. Must be 3-64 characters, start with an alphanumeric
6+
# character, and then use only letters, numbers, or dashes.
47
agent_id: my-example-agent
8+
9+
# Optional alias for mixed-style configs. Use either `agent_id` or `agentId`,
10+
# not both.
11+
# agentId: my-example-agent
12+
13+
# Optional. Policies are applied in order and passed through to the execution
14+
# context for every request made by this agent.
515
policies:
616
- read_only
717
- no_pii
18+
19+
# Optional free-form metadata copied into the execution context. Keep values
20+
# small enough to fit within `max_metadata_size_bytes`.
821
metadata:
922
environment: development
1023
owner: team-platform
1124
version: "1.0"
25+
26+
# Optional. Maximum number of in-memory audit entries retained for this agent.
27+
max_audit_log_size: 10000
28+
29+
# Optional. Per-value byte limit enforced when metadata is copied into a new
30+
# execution context.
31+
max_metadata_size_bytes: 1048576

0 commit comments

Comments
 (0)