File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
docs/user-guide/concepts/experimental Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff 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
108134from strands.experimental import config_to_agent
You can’t perform that action at this time.
0 commit comments