You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,18 +14,6 @@ The experimental `config_to_agent` function provides a simple way to create agen
14
14
- Support both file paths and dictionary configurations
15
15
- Leverage the Agent class's built-in tool loading capabilities
16
16
17
-
!!! note "Tool Loading Limitations"
18
-
Configuration-based agent setup only works for tools that don't require code-based instantiation. For tools that need constructor arguments or complex setup, use the programmatic approach after creating the agent:
- **Module names**: Python modules with @tool annotated functions
101
-
- **Function references**: Specific @tool annotated functions in modules
102
-
103
-
Support for tools in other languages will be added when MCP server support is introduced to this feature.
104
-
105
84
The Agent class handles all tool loading internally, including:
85
+
106
86
- Loading from module paths
107
87
- Loading from file paths
108
88
- Error handling for missing tools
109
89
- Tool validation
110
90
91
+
!!! note "Tool Loading Limitations"
92
+
Configuration-based agent setup only works for tools that don't require code-based instantiation. For tools that need constructor arguments or complex setup, use the programmatic approach after creating the agent:
print(f"Error: {e}") # Configuration file not found
176
-
```
177
-
178
-
### Invalid JSON
179
-
```python
180
-
try:
181
-
agent = config_to_agent("/path/to/invalid.json")
182
-
except json.JSONDecodeError as e:
183
-
print(f"Error: {e}") # Invalid JSON format
184
-
```
185
-
186
-
### Invalid Configuration Type
187
-
```python
188
-
try:
189
-
agent = config_to_agent(123) # Invalid type
190
-
exceptValueErroras e:
191
-
print(f"Error: {e}") # Config must be a file path string or dictionary
192
-
```
193
-
194
-
### Tool Loading Errors
195
-
196
-
Tool loading errors are handled by the Agent class according to its standard behavior:
197
-
198
-
```python
199
-
# If tools cannot be loaded, Agent will raise appropriate errors
200
-
agent = config_to_agent({
201
-
"model": "test-model",
202
-
"tools": ["nonexistent_tool"]
203
-
})
204
-
# This will raise an error from the Agent class during tool loading
205
-
```
206
-
207
118
## Best Practices
208
119
209
-
1.**Use absolute paths**: Prefer absolute file paths for configuration files
210
-
2.**Handle errors gracefully**: Catch FileNotFoundError and JSONDecodeError for robust applications
211
-
3.**Override when needed**: Use kwargs to override configuration values dynamically
212
-
4.**Leverage Agent defaults**: Only specify configuration values you want to override
213
-
5.**Use standard tool formats**: Follow Agent class conventions for tool specifications
214
-
215
-
## Migration from AgentConfig Class
216
-
217
-
If you were using the previous `AgentConfig` class, here's how to migrate:
218
-
219
-
### Before (AgentConfig class)
220
-
```python
221
-
from strands.experimental.agent_config import AgentConfig
222
-
223
-
config = AgentConfig("/path/to/config.json")
224
-
agent = config.to_agent()
225
-
```
226
-
227
-
### After (config_to_agent function)
228
-
```python
229
-
from strands.experimental import config_to_agent
230
-
231
-
agent = config_to_agent("/path/to/config.json")
232
-
```
233
-
234
-
The new interface is simpler and delegates all complexity to the existing Agent class, providing a more consistent experience.
120
+
1.**Override when needed**: Use kwargs to override configuration values dynamically
121
+
2.**Leverage Agent defaults**: Only specify configuration values you want to override
122
+
3.**Use standard tool formats**: Follow Agent class conventions for tool specifications
123
+
4.**Handle errors gracefully**: Catch FileNotFoundError and JSONDecodeError for robust applications
235
124
236
-
This experimental feature provides a foundation for more advanced agent configuration patterns while maintaining full compatibility with the existing Agent API.
0 commit comments