1
1
# Strands Agents Configuration Schema Validation
2
2
3
- This directory contains a comprehensive schema validation system for Strands Agents configurations, providing JSON Schema validation, semantic validation, and IDE integration support.
3
+ This directory contains JSON Schema definitions for validating Strands Agents configurations, providing schema validation and IDE integration support.
4
4
5
5
## 🎯 Features
6
6
7
7
- ** JSON Schema Validation** : Complete validation against JSON Schema Draft-07
8
8
- ** IDE Integration** : VSCode auto-completion and real-time validation
9
- - ** Semantic Validation** : Business logic and best practice validation
10
- - ** Compatibility Checking** : Cross-component reference validation
11
- - ** Detailed Error Reporting** : Clear, actionable error messages with precise locations
9
+ - ** Flexible Configuration Formats** : Support for both direct and wrapped configuration formats
12
10
- ** Multiple Configuration Types** : Support for agents, swarms, graphs, tools, and composite configurations
11
+ - ** Clear Error Reporting** : Actionable error messages with precise locations
13
12
14
13
## 📁 Directory Structure
15
14
@@ -21,47 +20,17 @@ config_schema/
21
20
│ ├── graph-config.schema.json # Graph configuration schema
22
21
│ ├── tool-config.schema.json # Tool configuration schema
23
22
│ └── composite-config.schema.json # Composite configuration schema
24
- ├── validators/ # Python validation modules
25
- │ ├── schema_validator.py # Core schema validation
26
- │ ├── semantic_validator.py # Business logic validation
27
- │ └── compatibility_validator.py # Cross-component validation
28
- ├── examples/ # Example configurations
29
- │ ├── valid/ # Valid configuration examples
30
- │ └── invalid/ # Invalid examples for testing
31
23
├── vscode/ # VSCode integration files
32
24
│ ├── settings.json # Schema associations
33
25
│ └── README.md # IDE setup instructions
34
- └── test_schema_validation .py # Comprehensive test script
26
+ └── __init__ .py # Module initialization
35
27
```
36
28
37
29
## 🚀 Quick Start
38
30
39
- ### 1. Python Validation
31
+ ### 1. VSCode Integration
40
32
41
- ``` python
42
- from strands.experimental.config_loader.config_schema import SchemaValidator
43
-
44
- # Initialize validator
45
- validator = SchemaValidator()
46
-
47
- # Validate an agent configuration
48
- result = validator.validate_agent_config(" path/to/agent.yml" )
49
-
50
- if result.is_valid:
51
- print (" ✅ Configuration is valid!" )
52
- else :
53
- print (" ❌ Validation failed:" )
54
- for error in result.errors:
55
- print (f " - { error} " )
56
-
57
- # Validate other configuration types
58
- swarm_result = validator.validate_swarm_config(" path/to/swarm.yml" )
59
- graph_result = validator.validate_graph_config(" path/to/graph.yml" )
60
- ```
61
-
62
- ### 2. VSCode Integration
63
-
64
- 1 . Copy the VSCode settings:
33
+ 1 . Copy the VSCode settings to your project:
65
34
``` bash
66
35
cp vscode/settings.json /path/to/your/project/.vscode/settings.json
67
36
```
@@ -72,26 +41,21 @@ graph_result = validator.validate_graph_config("path/to/graph.yml")
72
41
73
42
3 . Start editing YAML files with automatic validation and auto-completion!
74
43
75
- ### 3. Running Tests
44
+ ### 2. Python Validation
76
45
77
- ``` bash
78
- # Run the comprehensive test suite
79
- python test_schema_validation.py
46
+ For programmatic validation, use the schema validation system in the samples:
80
47
81
- # Test specific configuration files
82
- python -c "
83
- from validators import SchemaValidator
84
- validator = SchemaValidator()
85
- result = validator.validate_agent_config('examples/valid/weather-agent.yml')
86
- print('Valid!' if result.is_valid else 'Invalid!')
87
- "
48
+ ``` python
49
+ # See samples/01-tutorials/01-fundamentals/09-configuration-loader/
50
+ # for comprehensive validation examples and notebooks
88
51
```
89
52
90
53
## 📋 Supported Configuration Types
91
54
92
55
### Agent Configurations
93
- Files matching: ` *-agent.yml ` , ` agent.yml `
56
+ Supports both direct and wrapped formats:
94
57
58
+ ** Direct format:**
95
59
``` yaml
96
60
name : " my_agent"
97
61
model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
@@ -101,62 +65,98 @@ tools:
101
65
temperature : 0.7
102
66
` ` `
103
67
104
- ### Swarm Configurations
105
- Files matching: ` swarm*.yml`
68
+ **Wrapped format:**
69
+ ` ` ` yaml
70
+ agent :
71
+ name : " my_agent"
72
+ model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
73
+ system_prompt : " You are a helpful assistant..."
74
+ tools :
75
+ - " weather_tool.weather"
76
+ temperature : 0.7
77
+ ` ` `
106
78
79
+ ### Swarm Configurations
107
80
` ` ` yaml
108
81
swarm :
109
82
max_handoffs : 15
110
83
agents :
111
84
- name : " research_agent"
112
85
model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
113
86
system_prompt : " You are a research specialist..."
87
+ handoff_conditions :
88
+ - condition : " research_complete"
89
+ target_agent : " creative_agent"
114
90
- name : " creative_agent"
115
91
model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
116
92
system_prompt : " You are a creative specialist..."
117
93
` ` `
118
94
119
95
### Graph Configurations
120
- Files matching : ` graph*.yml`
121
-
122
96
` ` ` yaml
123
97
graph :
124
- graph_id: "my_workflow"
125
- name: "My Workflow"
126
98
nodes :
127
- - node_id: "start"
128
- type: "agent"
129
- config:
130
- name: "starter_agent"
99
+ - name : " validator"
100
+ agent :
101
+ model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
102
+ system_prompt : " You validate documents..."
103
+ - name : " processor"
104
+ agent :
131
105
model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
132
- system_prompt: "You coordinate the workflow ..."
106
+ system_prompt : " You process documents ..."
133
107
edges :
134
- - from_node: "start"
135
- to_node: "end"
136
- entry_points: ["start"]
108
+ - from : " validator"
109
+ to : " processor"
110
+ condition :
111
+ type : " expression"
112
+ expression : " state.results.get('validator', {}).get('status') == 'valid'"
113
+ entry_point : " validator"
137
114
` ` `
138
115
139
- # # 🔍 Validation Levels
116
+ ### Tool Configurations
117
+ ` ` ` yaml
118
+ tools :
119
+ - name : " weather"
120
+ description : " Get current weather information"
121
+ function : " weather_tool.weather"
122
+ parameters :
123
+ type : " object"
124
+ properties :
125
+ location :
126
+ type : " string"
127
+ description : " City name"
128
+ required : ["location"]
129
+ ` ` `
130
+
131
+ ### Composite Configurations (Agents/Swarms/Graphs as Tools)
132
+ ` ` ` yaml
133
+ agent :
134
+ model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
135
+ system_prompt : " You coordinate complex tasks..."
136
+ tools :
137
+ - name : " research_team"
138
+ description : " A collaborative research team"
139
+ swarm :
140
+ agents :
141
+ - name : " researcher"
142
+ model : " us.anthropic.claude-3-7-sonnet-20250219-v1:0"
143
+ system_prompt : " You gather information..."
144
+ ` ` `
145
+
146
+ ## 🔍 Schema Features
147
+
148
+ ### Flexible Configuration Support
149
+ - **Direct Format**: Configuration properties at root level
150
+ - **Wrapped Format**: Configuration under ` agent:`, `swarm:`, or `graph:` keys
151
+ - **Automatic Detection**: Schemas support both formats seamlessly
140
152
141
- # ## 1. Schema Validation
153
+ # ## Validation Capabilities
142
154
- **Structure**: YAML/JSON structure validation
143
155
- **Types**: Data type checking (string, number, boolean, etc.)
144
156
- **Required Fields**: Ensures all required properties are present
145
157
- **Constraints**: Validates ranges, patterns, and enums
146
158
- **Additional Properties**: Prevents unknown configuration keys
147
-
148
- # ## 2. Semantic Validation
149
- - **Business Logic**: Validates configuration makes sense
150
- - **Best Practices**: Suggests improvements and optimizations
151
- - **Model Compatibility**: Checks model parameters and capabilities
152
- - **Tool References**: Validates tool availability and configuration
153
- - **Resource Limits**: Warns about performance implications
154
-
155
- # ## 3. Compatibility Validation
156
- - **Cross-References**: Validates references between components
157
- - **Circular Dependencies**: Detects circular references
158
- - **Tool Conflicts**: Identifies potential tool usage conflicts
159
- - **Version Compatibility**: Ensures component versions work together
159
+ - **Complex Tools**: Validates agent-as-tool, swarm-as-tool, graph-as-tool configurations
160
160
161
161
# # 🎨 IDE Integration
162
162
@@ -176,57 +176,6 @@ The schema system automatically detects configuration types based on file names:
176
176
- **Tools**: `tool*.yml`, `tools.yml`
177
177
- **Composite**: `*-as-tools.yml`, `agents-as-tools.yml`
178
178
179
- # # 🧪 Testing
180
-
181
- # ## Test Categories
182
-
183
- 1. **Schema Loading Tests** : Verify all schemas load correctly
184
- 2. **Valid Configuration Tests** : Test known-good configurations
185
- 3. **Invalid Configuration Tests** : Test error detection
186
- 4. **Error Message Tests** : Verify error message quality
187
- 5. **Semantic Validation Tests** : Test business logic validation
188
- 6. **Compatibility Tests** : Test cross-component validation
189
-
190
- # ## Running Tests
191
-
192
- ` ` ` bash
193
- # Run all tests
194
- python test_schema_validation.py
195
-
196
- # Test specific schema
197
- python -c "
198
- from validators import SchemaValidator
199
- validator = SchemaValidator()
200
- print('Available schemas:', validator.get_available_schemas())
201
- "
202
- ` ` `
203
-
204
- # # 🔧 Extending the System
205
-
206
- # ## Adding New Schema Types
207
-
208
- 1. Create a new JSON Schema file in `schemas/`
209
- 2. Add validation method to `SchemaValidator`
210
- 3. Add semantic validation to `SemanticValidator`
211
- 4. Update VSCode settings for file pattern matching
212
- 5. Add test examples
213
-
214
- # ## Custom Validation Rules
215
-
216
- ` ` ` python
217
- from validators import SemanticValidator
218
-
219
- class CustomSemanticValidator(SemanticValidator):
220
- def validate_agent_config(self, config):
221
- result = super().validate_agent_config(config)
222
-
223
- # Add custom validation logic
224
- if config.get("name", "").startswith("test_"):
225
- result.add_warning("Agent name starts with 'test_' - is this intentional?")
226
-
227
- return result
228
- ` ` `
229
-
230
179
# # 📚 Schema Reference
231
180
232
181
# ## Common Patterns
@@ -267,6 +216,14 @@ class CustomSemanticValidator(SemanticValidator):
267
216
- **Temperatures**: Must be 0.0-2.0 for most models
268
217
- **Tokens**: Must be positive integers within model limits
269
218
219
+ # # 🧪 Testing and Examples
220
+
221
+ For comprehensive examples and testing :
222
+
223
+ - **Tutorial Notebooks**: `samples/01-tutorials/01-fundamentals/09-configuration-loader/`
224
+ - **Configuration Examples**: `samples/01-tutorials/01-fundamentals/09-configuration-loader/configs/`
225
+ - **Schema Validation Demo**: `samples/01-tutorials/01-fundamentals/09-configuration-loader/09-yaml-schema-simple.ipynb`
226
+
270
227
# # 🐛 Troubleshooting
271
228
272
229
# ## Common Issues
@@ -286,24 +243,20 @@ class CustomSemanticValidator(SemanticValidator):
286
243
- Check YAML extension is active
287
244
- Try "YAML : Reload Schema Cache" command
288
245
289
- # ## Debug Mode
246
+ # # 🔧 Schema Updates
290
247
291
- ` ` ` python
292
- import logging
293
- logging.basicConfig(level=logging.DEBUG)
294
-
295
- from validators import SchemaValidator
296
- validator = SchemaValidator()
297
- result = validator.validate_agent_config("config.yml")
298
- ` ` `
248
+ Recent improvements :
249
+ - **Flexible Format Support**: Schemas now support both direct and wrapped configuration formats
250
+ - **Enhanced Agent Schema**: Supports complex tool configurations (agent-as-tool, swarm-as-tool, graph-as-tool)
251
+ - **Improved Swarm Schema**: More flexible handoff conditions
252
+ - **Better Graph Schema**: Enhanced condition support with function-based conditions
299
253
300
254
# # 🤝 Contributing
301
255
302
256
1. **Adding Schemas** : Follow JSON Schema Draft-07 standards
303
- 2. **Validation Logic** : Add comprehensive error messages
304
- 3. **Testing** : Include both valid and invalid examples
305
- 4. **Documentation** : Update README and inline docs
306
- 5. **IDE Support** : Update VSCode settings for new patterns
257
+ 2. **Testing** : Use the validation notebooks in samples for testing changes
258
+ 3. **Documentation** : Update README and inline docs
259
+ 4. **IDE Support** : Update VSCode settings for new patterns
307
260
308
261
# # 📄 License
309
262
0 commit comments