Skip to content

Commit 33f4410

Browse files
committed
Fix config_loader documentation inconsistencies
- Correct documentation to match actual implementation - Focus on dictionary-based configuration vs file-based loading - Remove hallucinated features and examples - Add missing Swarm-as-Tool and Graph-as-Tool examples - Clarify experimental nature of config loaders - Ensure all examples match public interface - Update API usage examples to be accurate
1 parent 05b140d commit 33f4410

File tree

12 files changed

+117
-2470
lines changed

12 files changed

+117
-2470
lines changed

src/strands/experimental/config_loader/config_schema/README.md

Lines changed: 95 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# Strands Agents Configuration Schema Validation
22

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.
44

55
## 🎯 Features
66

77
- **JSON Schema Validation**: Complete validation against JSON Schema Draft-07
88
- **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
1210
- **Multiple Configuration Types**: Support for agents, swarms, graphs, tools, and composite configurations
11+
- **Clear Error Reporting**: Actionable error messages with precise locations
1312

1413
## 📁 Directory Structure
1514

@@ -21,47 +20,17 @@ config_schema/
2120
│ ├── graph-config.schema.json # Graph configuration schema
2221
│ ├── tool-config.schema.json # Tool configuration schema
2322
│ └── 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
3123
├── vscode/ # VSCode integration files
3224
│ ├── settings.json # Schema associations
3325
│ └── README.md # IDE setup instructions
34-
└── test_schema_validation.py # Comprehensive test script
26+
└── __init__.py # Module initialization
3527
```
3628

3729
## 🚀 Quick Start
3830

39-
### 1. Python Validation
31+
### 1. VSCode Integration
4032

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:
6534
```bash
6635
cp vscode/settings.json /path/to/your/project/.vscode/settings.json
6736
```
@@ -72,26 +41,21 @@ graph_result = validator.validate_graph_config("path/to/graph.yml")
7241

7342
3. Start editing YAML files with automatic validation and auto-completion!
7443

75-
### 3. Running Tests
44+
### 2. Python Validation
7645

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:
8047

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
8851
```
8952

9053
## 📋 Supported Configuration Types
9154

9255
### Agent Configurations
93-
Files matching: `*-agent.yml`, `agent.yml`
56+
Supports both direct and wrapped formats:
9457

58+
**Direct format:**
9559
```yaml
9660
name: "my_agent"
9761
model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
@@ -101,62 +65,98 @@ tools:
10165
temperature: 0.7
10266
```
10367
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+
```
10678
79+
### Swarm Configurations
10780
```yaml
10881
swarm:
10982
max_handoffs: 15
11083
agents:
11184
- name: "research_agent"
11285
model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
11386
system_prompt: "You are a research specialist..."
87+
handoff_conditions:
88+
- condition: "research_complete"
89+
target_agent: "creative_agent"
11490
- name: "creative_agent"
11591
model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
11692
system_prompt: "You are a creative specialist..."
11793
```
11894
11995
### Graph Configurations
120-
Files matching: `graph*.yml`
121-
12296
```yaml
12397
graph:
124-
graph_id: "my_workflow"
125-
name: "My Workflow"
12698
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:
131105
model: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
132-
system_prompt: "You coordinate the workflow..."
106+
system_prompt: "You process documents..."
133107
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"
137114
```
138115
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
140152

141-
### 1. Schema Validation
153+
### Validation Capabilities
142154
- **Structure**: YAML/JSON structure validation
143155
- **Types**: Data type checking (string, number, boolean, etc.)
144156
- **Required Fields**: Ensures all required properties are present
145157
- **Constraints**: Validates ranges, patterns, and enums
146158
- **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
160160

161161
## 🎨 IDE Integration
162162

@@ -176,57 +176,6 @@ The schema system automatically detects configuration types based on file names:
176176
- **Tools**: `tool*.yml`, `tools.yml`
177177
- **Composite**: `*-as-tools.yml`, `agents-as-tools.yml`
178178

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-
230179
## 📚 Schema Reference
231180

232181
### Common Patterns
@@ -267,6 +216,14 @@ class CustomSemanticValidator(SemanticValidator):
267216
- **Temperatures**: Must be 0.0-2.0 for most models
268217
- **Tokens**: Must be positive integers within model limits
269218

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+
270227
## 🐛 Troubleshooting
271228

272229
### Common Issues
@@ -286,24 +243,20 @@ class CustomSemanticValidator(SemanticValidator):
286243
- Check YAML extension is active
287244
- Try "YAML: Reload Schema Cache" command
288245

289-
### Debug Mode
246+
## 🔧 Schema Updates
290247

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
299253

300254
## 🤝 Contributing
301255

302256
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
307260

308261
## 📄 License
309262

src/strands/experimental/config_loader/config_schema/examples/invalid/invalid-agent.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)