|
| 1 | +# Strands Agents Configuration Schema |
| 2 | + |
| 3 | +This directory contains the comprehensive JSON Schema for validating all Strands Agents configuration files. The schema enforces proper structure and types while providing IDE support for autocompletion and validation. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The `strands-config-schema.json` file provides validation for four types of Strands Agents configurations: |
| 8 | + |
| 9 | +- **Agent Configuration** (`agent:`) - Single agent with tools, structured output, and advanced features |
| 10 | +- **Graph Configuration** (`graph:`) - Multi-agent workflows with nodes, edges, and conditions |
| 11 | +- **Swarm Configuration** (`swarm:`) - Collaborative agent teams with autonomous coordination |
| 12 | +- **Tools Configuration** (`tools:`) - Standalone tool definitions and configurations |
| 13 | + |
| 14 | +## Schema Features |
| 15 | + |
| 16 | +### ✅ **Comprehensive Type Validation** |
| 17 | +- Enforces correct data types (string, number, boolean, array, object) |
| 18 | +- No restrictive length or value constraints (except logical minimums) |
| 19 | +- Supports both simple and complex configuration patterns |
| 20 | +- Handles nested configurations (agents-as-tools, graphs-as-tools, swarms-as-tools) |
| 21 | + |
| 22 | +### ✅ **Flexible Structure** |
| 23 | +- Required fields enforced where necessary |
| 24 | +- Optional fields with sensible defaults documented |
| 25 | +- `additionalProperties: true` for extensibility |
| 26 | +- Support for `null` values where appropriate |
| 27 | + |
| 28 | +### ✅ **Advanced Features** |
| 29 | +- Graph edge conditions with 6+ condition types |
| 30 | +- Structured output schema validation |
| 31 | +- Tool configuration with multiple formats |
| 32 | +- Message and model configuration validation |
| 33 | + |
| 34 | +## Configuration Types |
| 35 | + |
| 36 | +### Agent Configuration |
| 37 | + |
| 38 | +```yaml |
| 39 | +# yaml-language-server: $schema=./strands-config-schema.json |
| 40 | + |
| 41 | +agent: |
| 42 | + model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0" |
| 43 | + system_prompt: "You are a helpful assistant" |
| 44 | + name: "MyAgent" |
| 45 | + tools: |
| 46 | + - weather_tool.weather |
| 47 | + - name: "custom_tool" |
| 48 | + description: "A custom tool" |
| 49 | + input_schema: |
| 50 | + type: object |
| 51 | + properties: |
| 52 | + query: {type: string} |
| 53 | + structured_output: "MySchema" |
| 54 | + |
| 55 | +# Optional global schemas |
| 56 | +schemas: |
| 57 | + - name: "MySchema" |
| 58 | + schema: |
| 59 | + type: object |
| 60 | + properties: |
| 61 | + result: {type: string} |
| 62 | +``` |
| 63 | +
|
| 64 | +### Graph Configuration |
| 65 | +
|
| 66 | +```yaml |
| 67 | +# yaml-language-server: $schema=./strands-config-schema.json |
| 68 | + |
| 69 | +graph: |
| 70 | + name: "Research Workflow" |
| 71 | + nodes: |
| 72 | + - node_id: "researcher" |
| 73 | + type: "agent" |
| 74 | + config: |
| 75 | + model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0" |
| 76 | + system_prompt: "You are a researcher" |
| 77 | + - node_id: "analyst" |
| 78 | + type: "agent" |
| 79 | + config: |
| 80 | + model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0" |
| 81 | + system_prompt: "You are an analyst" |
| 82 | + edges: |
| 83 | + - from_node: "researcher" |
| 84 | + to_node: "analyst" |
| 85 | + condition: |
| 86 | + type: "expression" |
| 87 | + expression: "state.results.get('researcher', {}).get('status') == 'complete'" |
| 88 | + entry_points: ["researcher"] |
| 89 | +``` |
| 90 | +
|
| 91 | +### Swarm Configuration |
| 92 | +
|
| 93 | +```yaml |
| 94 | +# yaml-language-server: $schema=./strands-config-schema.json |
| 95 | + |
| 96 | +swarm: |
| 97 | + max_handoffs: 20 |
| 98 | + execution_timeout: 900.0 |
| 99 | + agents: |
| 100 | + - name: "researcher" |
| 101 | + model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0" |
| 102 | + system_prompt: "You are a research specialist" |
| 103 | + tools: [] |
| 104 | + - name: "writer" |
| 105 | + model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0" |
| 106 | + system_prompt: "You are a writing specialist" |
| 107 | + tools: [] |
| 108 | +``` |
| 109 | +
|
| 110 | +### Tools Configuration |
| 111 | +
|
| 112 | +```yaml |
| 113 | +# yaml-language-server: $schema=./strands-config-schema.json |
| 114 | + |
| 115 | +tools: |
| 116 | + - weather_tool.weather |
| 117 | + - strands_tools.file_write |
| 118 | + - name: "custom_agent_tool" |
| 119 | + description: "An agent as a tool" |
| 120 | + agent: |
| 121 | + model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0" |
| 122 | + system_prompt: "You are a specialized tool agent" |
| 123 | + input_schema: |
| 124 | + type: object |
| 125 | + properties: |
| 126 | + query: {type: string} |
| 127 | +``` |
| 128 | +
|
| 129 | +## IDE Integration |
| 130 | +
|
| 131 | +### VSCode Setup |
| 132 | +
|
| 133 | +To enable YAML validation and autocompletion in VSCode: |
| 134 | +
|
| 135 | +1. **Install the YAML Extension**: |
| 136 | + - Install the "YAML" extension by Red Hat from the VSCode marketplace |
| 137 | +
|
| 138 | +2. **Configure Schema Association**: |
| 139 | +
|
| 140 | + **Option A: File-level schema reference (Recommended)** |
| 141 | + Add this line at the top of your configuration files: |
| 142 | + ```yaml |
| 143 | + # yaml-language-server: $schema=https://strandsagents.com/schemas/config/v1 |
| 144 | + |
| 145 | + agent: |
| 146 | + model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0" |
| 147 | + # ... rest of configuration |
| 148 | + ``` |
| 149 | + |
| 150 | + **Option B: VSCode settings for `.strands.yml` files** |
| 151 | + Add to your VSCode `settings.json`: |
| 152 | + ```json |
| 153 | + { |
| 154 | + "yaml.schemas": { |
| 155 | + "https://strandsagents.com/schemas/config/v1": "*.strands.yml" |
| 156 | + } |
| 157 | + } |
| 158 | + ``` |
| 159 | + |
| 160 | + **Option C: Local schema file reference** |
| 161 | + For development with local schema file: |
| 162 | + ```yaml |
| 163 | + # yaml-language-server: $schema=./path/to/strands-config-schema.json |
| 164 | + ``` |
| 165 | + |
| 166 | +3. **File Naming Convention**: |
| 167 | + While not required, using the `.strands.yml` extension makes it easy for VSCode to automatically apply the correct schema and provides clear identification of Strands configuration files. |
| 168 | + |
| 169 | +### Other IDEs |
| 170 | + |
| 171 | +**IntelliJ IDEA / PyCharm**: |
| 172 | +- The schema works with the built-in YAML plugin |
| 173 | +- Configure schema mapping in Settings → Languages & Frameworks → Schemas and DTDs → JSON Schema Mappings |
| 174 | + |
| 175 | +**Vim/Neovim**: |
| 176 | +- Use with `coc-yaml` or similar LSP plugins |
| 177 | +- Configure schema association in the plugin settings |
| 178 | + |
| 179 | +## Schema Validation Rules |
| 180 | + |
| 181 | +### Required Fields |
| 182 | + |
| 183 | +| Configuration Type | Required Fields | |
| 184 | +|-------------------|----------------| |
| 185 | +| Agent | `agent.model` | |
| 186 | +| Graph | `graph.nodes`, `graph.edges`, `graph.entry_points` | |
| 187 | +| Swarm | `swarm.agents` | |
| 188 | +| Tools | `tools` (array) | |
| 189 | + |
| 190 | +### Default Values |
| 191 | + |
| 192 | +The schema documents these sensible defaults: |
| 193 | + |
| 194 | +```yaml |
| 195 | +# Agent defaults |
| 196 | +record_direct_tool_call: true |
| 197 | +load_tools_from_directory: false |
| 198 | + |
| 199 | +# Graph defaults |
| 200 | +reset_on_revisit: false |
| 201 | + |
| 202 | +# Swarm defaults |
| 203 | +max_handoffs: 20 |
| 204 | +max_iterations: 20 |
| 205 | +execution_timeout: 900.0 |
| 206 | +node_timeout: 300.0 |
| 207 | +repetitive_handoff_detection_window: 0 |
| 208 | +repetitive_handoff_min_unique_agents: 0 |
| 209 | +``` |
| 210 | +
|
| 211 | +### Flexible Validation |
| 212 | +
|
| 213 | +- **Timeout Values**: Accept `null` for unlimited timeouts |
| 214 | +- **Model Configuration**: Support both string IDs and complex objects |
| 215 | +- **Tool Definitions**: Handle simple strings and complex objects |
| 216 | +- **Additional Properties**: Allow extension fields for future compatibility |
| 217 | + |
| 218 | +## Condition Types |
| 219 | + |
| 220 | +The schema supports comprehensive validation for graph edge conditions: |
| 221 | + |
| 222 | +### Expression Conditions |
| 223 | +```yaml |
| 224 | +condition: |
| 225 | + type: "expression" |
| 226 | + expression: "state.results.get('node_id', {}).get('status') == 'complete'" |
| 227 | + description: "Check if node completed successfully" |
| 228 | +``` |
| 229 | + |
| 230 | +### Rule Conditions |
| 231 | +```yaml |
| 232 | +condition: |
| 233 | + type: "rule" |
| 234 | + rules: |
| 235 | + - field: "results.validator.status" |
| 236 | + operator: "equals" |
| 237 | + value: "valid" |
| 238 | + - field: "results.validator.confidence" |
| 239 | + operator: "greater_than" |
| 240 | + value: 0.8 |
| 241 | + logic: "and" |
| 242 | +``` |
| 243 | + |
| 244 | +### Function Conditions |
| 245 | +```yaml |
| 246 | +condition: |
| 247 | + type: "function" |
| 248 | + module: "my_conditions" |
| 249 | + function: "check_completion" |
| 250 | + timeout: 5.0 |
| 251 | + default: false |
| 252 | +``` |
| 253 | + |
| 254 | +### Template Conditions |
| 255 | +```yaml |
| 256 | +condition: |
| 257 | + type: "template" |
| 258 | + template: "node_result_contains" |
| 259 | + parameters: |
| 260 | + node_id: "classifier" |
| 261 | + search_text: "technical" |
| 262 | +``` |
| 263 | + |
| 264 | +### Composite Conditions |
| 265 | +```yaml |
| 266 | +condition: |
| 267 | + type: "composite" |
| 268 | + logic: "and" |
| 269 | + conditions: |
| 270 | + - type: "expression" |
| 271 | + expression: "state.execution_count < 10" |
| 272 | + - type: "rule" |
| 273 | + rules: |
| 274 | + - field: "status" |
| 275 | + operator: "equals" |
| 276 | + value: "ready" |
| 277 | +``` |
| 278 | + |
| 279 | +## Validation Tools |
| 280 | + |
| 281 | +### Command Line Validation |
| 282 | + |
| 283 | +You can validate configurations using standard JSON Schema tools: |
| 284 | + |
| 285 | +```bash |
| 286 | +# Using ajv-cli |
| 287 | +npm install -g ajv-cli |
| 288 | +ajv validate -s strands-config-schema.json -d config.yml |
| 289 | +
|
| 290 | +# Using python jsonschema |
| 291 | +pip install jsonschema pyyaml |
| 292 | +python -c " |
| 293 | +import json, yaml |
| 294 | +from jsonschema import validate |
| 295 | +schema = json.load(open('strands-config-schema.json')) |
| 296 | +config = yaml.safe_load(open('config.yml')) |
| 297 | +validate(config, schema) |
| 298 | +print('✅ Configuration is valid') |
| 299 | +" |
| 300 | +``` |
| 301 | + |
| 302 | +### Online Validation |
| 303 | + |
| 304 | +You can use online JSON Schema validators: |
| 305 | +- [JSON Schema Validator](https://www.jsonschemavalidator.net/) |
| 306 | +- [Schema Validator](https://jsonschemalint.com/) |
| 307 | + |
| 308 | +## Error Messages |
| 309 | + |
| 310 | +The schema provides clear validation error messages: |
| 311 | + |
| 312 | +``` |
| 313 | +❌ VALIDATION ERROR: 'model' is a required property |
| 314 | + Path: ['agent'] |
| 315 | +
|
| 316 | +❌ VALIDATION ERROR: 'invalid_type' is not one of ['agent', 'swarm', 'graph'] |
| 317 | + Path: ['graph', 'nodes', 0, 'type'] |
| 318 | +
|
| 319 | +❌ VALIDATION ERROR: None is not of type 'string' |
| 320 | + Path: ['swarm', 'agents', 0, 'name'] |
| 321 | +``` |
| 322 | + |
| 323 | +## Schema Evolution |
| 324 | + |
| 325 | +### Versioning |
| 326 | +- Current version: `v1` (`https://strandsagents.com/schemas/config/v1`) |
| 327 | +- Future versions will maintain backward compatibility where possible |
| 328 | +- Breaking changes will increment the major version |
| 329 | + |
| 330 | +### Extensibility |
| 331 | +- The schema uses `additionalProperties: true` for extensibility |
| 332 | +- New optional fields can be added without breaking existing configurations |
| 333 | +- Custom properties are supported for specialized use cases |
| 334 | + |
| 335 | +## Best Practices |
| 336 | + |
| 337 | +### File Organization |
| 338 | +``` |
| 339 | +project/ |
| 340 | +├── configs/ |
| 341 | +│ ├── agents/ |
| 342 | +│ │ ├── researcher.strands.yml |
| 343 | +│ │ └── writer.strands.yml |
| 344 | +│ ├── graphs/ |
| 345 | +│ │ ├── workflow.strands.yml |
| 346 | +│ │ └── pipeline.strands.yml |
| 347 | +│ └── swarms/ |
| 348 | +│ └── team.strands.yml |
| 349 | +└── tools/ |
| 350 | + └── custom-tools.strands.yml |
| 351 | +``` |
| 352 | +
|
| 353 | +### Configuration Management |
| 354 | +- Use meaningful names for agents, nodes, and tools |
| 355 | +- Include descriptions for complex configurations |
| 356 | +- Leverage the schema's validation to catch errors early |
| 357 | +- Use consistent naming conventions across configurations |
| 358 | +
|
| 359 | +### Development Workflow |
| 360 | +1. Create configuration files with `.strands.yml` extension |
| 361 | +2. Add schema reference at the top of files |
| 362 | +3. Use IDE validation during development |
| 363 | +4. Test configurations with ConfigLoaders |
| 364 | +5. Validate in CI/CD pipelines if needed |
| 365 | +
|
| 366 | +## Troubleshooting |
| 367 | +
|
| 368 | +### Common Issues |
| 369 | +
|
| 370 | +**Schema not loading in VSCode**: |
| 371 | +- Ensure the YAML extension is installed and enabled |
| 372 | +- Check that the schema URL or path is correct |
| 373 | +- Restart VSCode after configuration changes |
| 374 | +
|
| 375 | +**Validation errors for working configurations**: |
| 376 | +- Ensure you're using the latest schema version |
| 377 | +- Check that required top-level keys (`agent:`, `graph:`, etc.) are present |
| 378 | +- Verify that all required fields are included |
| 379 | +
|
| 380 | +**Schema not found errors**: |
| 381 | +- For local development, use relative paths to the schema file |
| 382 | +- For production, ensure the schema URL is accessible |
| 383 | +- Consider hosting the schema file in your project repository |
| 384 | +
|
| 385 | +## Contributing |
| 386 | +
|
| 387 | +When updating configurations or adding new features: |
| 388 | +
|
| 389 | +1. Ensure all example configurations validate against the schema |
| 390 | +2. Update the schema if new fields or structures are added |
| 391 | +3. Test schema changes against existing configurations |
| 392 | +4. Update this documentation for any new features or changes |
| 393 | +
|
| 394 | +The schema serves as both validation and documentation, so keeping it accurate and comprehensive is essential for the developer experience. |
0 commit comments