Skip to content

Commit 6a66da0

Browse files
mrlee-amazonUnshure
authored andcommitted
docs: clarify tool limitations and add validation details
- Add prominent note about tool loading limitations for code-based instantiation - Document Python-specific tool support (files, modules, @tool functions) - Add example of programmatic tool addition after agent creation - Explain tool validation error messages with examples - Clarify that MCP server support will enable other language tools - Update tool loading examples to be more specific about Python requirements 🤖 Assisted by Amazon Q Developer
1 parent 7edf636 commit 6a66da0

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ The experimental `config_to_agent` function provides a simple way to create agen
1414
- Support both file paths and dictionary configurations
1515
- Leverage the Agent class's built-in tool loading capabilities
1616

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:
19+
20+
```python
21+
import http.client
22+
from sample_module import ToolWithConfigArg
23+
24+
agent = config_to_agent("config.json")
25+
# Add tools that need code-based instantiation
26+
agent.process_tools([ToolWithConfigArg(http.client.HTTPSConnection("localhost"))])
27+
```
28+
1729
## Basic Usage
1830

1931
### Dictionary Configuration
@@ -63,23 +75,33 @@ agent = config_to_agent("file:///path/to/config.json")
6375

6476
- `model`: Model identifier (string) - see [model provider documentation](https://strandsagents.com/latest/user-guide/quickstart/#using-a-string-model-id)
6577
- `prompt`: System prompt for the agent (string)
66-
- `tools`: List of tool names, module paths, or file paths (list of strings)
78+
- `tools`: List of tool specifications (list of strings)
6779
- `name`: Agent name (string)
6880

6981
### Tool Loading
7082

71-
The `tools` configuration supports the same formats as the Agent class:
83+
The `tools` configuration supports Python-specific tool loading formats:
7284

7385
```json
7486
{
7587
"tools": [
76-
"strands_tools.file_read", // Module path
88+
"strands_tools.file_read", // Python module path
7789
"my_app.tools.cake_tool", // Custom module path
78-
"/path/to/another_tool.py" // File path
90+
"/path/to/another_tool.py", // File path
91+
"my_module.my_tool_function" // @tool annotated function
7992
]
8093
}
8194
```
8295

96+
!!! important "Python Tool Support Only"
97+
Currently, tool loading is Python-specific and supports:
98+
99+
- **File paths**: Python files containing @tool annotated functions
100+
- **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+
83105
The Agent class handles all tool loading internally, including:
84106
- Loading from module paths
85107
- Loading from file paths
@@ -129,6 +151,20 @@ except ValueError as e:
129151
print(f"Error: {e}") # Configuration validation error at tools -> 1: 123 is not of type 'string'
130152
```
131153

154+
### Tool Validation Errors
155+
156+
The function validates that tools can be loaded and provides helpful error messages:
157+
158+
```python
159+
# Tool not found
160+
try:
161+
agent = config_to_agent({"model": "test-model", "tools": ["nonexistent_tool"]})
162+
except ValueError as e:
163+
print(f"Error: {e}")
164+
# Tool 'nonexistent_tool' not found. The configured tool is not annotated with @tool,
165+
# and is not a module or file. To properly import this tool, you must annotate it with @tool.
166+
```
167+
132168
### File Not Found
133169
```python
134170
from strands.experimental import config_to_agent

0 commit comments

Comments
 (0)