Skip to content

Commit 7edf636

Browse files
mrlee-amazonUnshure
authored andcommitted
docs: add JSON schema validation documentation
- Document configuration validation with detailed error examples - Show validation error messages for invalid fields, types, and tool items - Explain how validation provides helpful error paths for debugging - Add examples of common validation errors users might encounter 🤖 Assisted by Amazon Q Developer
1 parent 71dd104 commit 7edf636

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/user-guide/concepts/experimental/agent-config.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,32 @@ agent = config_to_agent(
103103

104104
## Error Handling
105105

106+
### Configuration Validation
107+
108+
The `config_to_agent` function validates configuration against a JSON schema and provides detailed error messages:
109+
110+
```python
111+
from strands.experimental import config_to_agent
112+
113+
# Invalid field
114+
try:
115+
agent = config_to_agent({"model": "test-model", "invalid_field": "value"})
116+
except ValueError as e:
117+
print(f"Error: {e}") # Configuration validation error at root: Additional properties are not allowed ('invalid_field' was unexpected)
118+
119+
# Wrong field type
120+
try:
121+
agent = config_to_agent({"model": "test-model", "tools": "not-a-list"})
122+
except ValueError as e:
123+
print(f"Error: {e}") # Configuration validation error at tools: 'not-a-list' is not of type 'array'
124+
125+
# Invalid tool item
126+
try:
127+
agent = config_to_agent({"model": "test-model", "tools": ["valid-tool", 123]})
128+
except ValueError as e:
129+
print(f"Error: {e}") # Configuration validation error at tools -> 1: 123 is not of type 'string'
130+
```
131+
106132
### File Not Found
107133
```python
108134
from strands.experimental import config_to_agent

0 commit comments

Comments
 (0)