generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 105
Add comprehensive agent configuration documentation #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mr-lee
wants to merge
46
commits into
strands-agents:main
Choose a base branch
from
mr-lee:feature/agent-config-docs-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+126
−0
Open
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
453e404
Add agent configuration documentation and examples
mrlee-amazon 64d956e
Fix model ID format in documentation to align with Strands expectations
mrlee-amazon 2f97b66
Fix tool names to match strands-agents/tools specifications
mrlee-amazon 14c6e34
Update documentation to show correct tool usage
mrlee-amazon b27683d
feat: add experimental AgentConfig and ToolPool documentation
mrlee-amazon ec5d627
refactor: update experimental docs per feedback
mrlee-amazon ce1dad0
docs: update experimental AgentConfig with latest enhancements
mrlee-amazon 0da957a
docs: add examples using default tools from strands_tools
mrlee-amazon 5414454
docs: clarify ToolPool configuration requirement
mrlee-amazon 879eed1
fix: update coding-assistant.json with correct tools
mrlee-amazon be10716
docs: update experimental docs for ToolPool to ToolBox rename
mrlee-amazon da4e62f
docs: fix method name from toAgent to to_agent
mrlee-amazon dd7cf0e
docs: update experimental features to use ToolRegistry instead of Too…
mrlee-amazon 71346a7
Update docs/user-guide/concepts/experimental/agent-config.md
mr-lee 7f5c711
Update docs/user-guide/concepts/experimental/agent-config.md
mr-lee b58b7fe
Update docs/user-guide/concepts/experimental/agent-config.md
mr-lee 22a420c
Update docs/user-guide/concepts/experimental/agent-config.md
mr-lee 3205434
Apply suggestions from code review
mr-lee 37bc11a
docs: comprehensive improvements to experimental AgentConfig document…
mrlee-amazon 9e5dc85
docs: fix Using Default Tools example to use pirate agent without tools
mrlee-amazon 1f47b0f
docs: add model provider documentation reference
mrlee-amazon af49e96
docs: move agent config JSON examples inline
mrlee-amazon c3627fd
docs: add GitHub links to default tools in AgentConfig
mrlee-amazon fb93065
docs: fix invalid Agent parameters in AgentConfig examples
mrlee-amazon a7e747d
docs: update line 112 to use file_read and editor tools
mrlee-amazon dc17712
docs: consolidate Default Tools Behavior into Using Default Tools sec…
mrlee-amazon 0705376
docs: fix inaccurate description of default tools behavior
mrlee-amazon c6e8ae0
docs: update agent example to use file_read tool
mrlee-amazon 71af36a
docs: add back experimental caveat to tool list note
mrlee-amazon 241830d
docs: remove duplicate Selecting from Default Tools section
mrlee-amazon c74ad9a
docs: update error handling sections for raise_exception_on_missing_t…
mrlee-amazon 4795a6f
Update docs/user-guide/concepts/experimental/agent-config.md
mr-lee 3091714
Update docs/user-guide/concepts/experimental/agent-config.md
mr-lee 8af8cd9
Update docs/user-guide/concepts/experimental/agent-config.md
mr-lee bbb0c02
Apply suggestion from @Unshure
mr-lee 5158db9
Apply suggestion from @Unshure
mr-lee 80b61d0
Apply suggestion from @Unshure
mr-lee 331d6a2
Apply suggestion from @Unshure
mr-lee f7e5831
Apply suggestion from @Unshure
mr-lee 329f57f
Apply suggestion from @Unshure
mr-lee 04175f0
docs: remove Example: Complete Workflow section
mrlee-amazon 4e271cb
docs: update agent-config.md for new config_to_agent function
mrlee-amazon 71dd104
docs: limit config_to_agent supported keys to core configuration
mrlee-amazon 7edf636
docs: add JSON schema validation documentation
mrlee-amazon 6a66da0
docs: clarify tool limitations and add validation details
mrlee-amazon a895d25
update docs to match updated pr
Unshure File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# Agent Configuration [Experimental] | ||
|
||
!!! warning "Experimental Feature" | ||
This feature is experimental and may change in future versions. Use with caution in production environments. | ||
|
||
The experimental `config_to_agent` function provides a simple way to create agents from configuration files or dictionaries. | ||
|
||
## Overview | ||
|
||
`config_to_agent` allows you to: | ||
|
||
- Create agents from JSON files or dictionaries | ||
- Use a simple functional interface for agent instantiation | ||
- Support both file paths and dictionary configurations | ||
- Leverage the Agent class's built-in tool loading capabilities | ||
|
||
## Basic Usage | ||
|
||
### Dictionary Configuration | ||
|
||
```python | ||
from strands.experimental import config_to_agent | ||
|
||
# Create agent from dictionary | ||
agent = config_to_agent({ | ||
"model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0", | ||
"prompt": "You are a helpful assistant" | ||
}) | ||
``` | ||
|
||
### File Configuration | ||
|
||
```python | ||
from strands.experimental import config_to_agent | ||
|
||
# Load from JSON file (with or without file:// prefix) | ||
agent = config_to_agent("/path/to/config.json") | ||
# or | ||
agent = config_to_agent("file:///path/to/config.json") | ||
``` | ||
|
||
#### Simple Agent Example | ||
|
||
```json | ||
{ | ||
"prompt": "You are a helpful assistant." | ||
} | ||
``` | ||
|
||
#### Coding Assistant Example | ||
|
||
```json | ||
{ | ||
"model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0", | ||
"prompt": "You are a coding assistant. Help users write, debug, and improve their code. You have access to file operations and can execute shell commands when needed.", | ||
"tools": ["strands_tools.file_read", "strands_tools.editor", "strands_tools.shell"] | ||
} | ||
``` | ||
|
||
## Configuration Options | ||
|
||
### Supported Keys | ||
|
||
- `model`: Model identifier (string) - see [model provider documentation](https://strandsagents.com/latest/user-guide/quickstart/#using-a-string-model-id) | ||
- `prompt`: System prompt for the agent (string) | ||
- `tools`: List of tool specifications (list of strings) | ||
- `name`: Agent name (string) | ||
|
||
### Tool Loading | ||
|
||
The `tools` configuration supports Python-specific tool loading formats: | ||
|
||
```json | ||
{ | ||
"tools": [ | ||
"strands_tools.file_read", // Python module path | ||
"my_app.tools.cake_tool", // Custom module path | ||
"/path/to/another_tool.py", // File path | ||
"my_module.my_tool_function" // @tool annotated function | ||
] | ||
} | ||
``` | ||
|
||
The Agent class handles all tool loading internally, including: | ||
|
||
- Loading from module paths | ||
- Loading from file paths | ||
- Error handling for missing tools | ||
- Tool validation | ||
|
||
!!! note "Tool Loading Limitations" | ||
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: | ||
|
||
```python | ||
import http.client | ||
from sample_module import ToolWithConfigArg | ||
|
||
agent = config_to_agent("config.json") | ||
# Add tools that need code-based instantiation | ||
agent.process_tools([ToolWithConfigArg(http.client.HTTPSConnection("localhost"))]) | ||
``` | ||
|
||
## Function Parameters | ||
|
||
The `config_to_agent` function accepts: | ||
|
||
- `config`: Either a file path (string) or configuration dictionary | ||
- `**kwargs`: Additional [Agent constructor parameters](https://strandsagents.com/latest/api-reference/agent/#strands.agent.agent.Agent.__init__) that override config values | ||
|
||
```python | ||
# Override config values with valid Agent parameters | ||
agent = config_to_agent( | ||
"/path/to/config.json", | ||
name="Data Analyst" | ||
) | ||
``` | ||
|
||
## Best Practices | ||
|
||
1. **Override when needed**: Use kwargs to override configuration values dynamically | ||
2. **Leverage Agent defaults**: Only specify configuration values you want to override | ||
3. **Use standard tool formats**: Follow Agent class conventions for tool specifications | ||
4. **Handle errors gracefully**: Catch FileNotFoundError and JSONDecodeError for robust applications | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.