|
| 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. |
0 commit comments