Skip to content

Commit 27bb82f

Browse files
committed
feat: limit config_to_agent to core configuration keys
- Remove support for advanced Agent parameters in config_to_agent - Only support: model, prompt, tools, name in configuration - Advanced parameters can still be passed via kwargs - Remove agent_id test and update function mapping - Keep interface simple and focused on basic agent configuration 🤖 Assisted by Amazon Q Developer
1 parent f372666 commit 27bb82f

File tree

3 files changed

+127
-13
lines changed

3 files changed

+127
-13
lines changed

REFACTOR_TODO.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Agent Config Refactor TODO
2+
3+
## Plan
4+
Refactor from class-based `AgentConfig` to function-based `config_to_agent` approach:
5+
6+
### Current Interface
7+
```python
8+
from strands.experimental.agent_config import AgentConfig
9+
config = AgentConfig("/path/to/config.json")
10+
agent = config.to_agent()
11+
```
12+
13+
### Target Interface
14+
```python
15+
from strands.experimental import config_to_agent
16+
agent = config_to_agent("/path/to/config.json")
17+
```
18+
19+
## Tasks
20+
21+
### 1. Core Function Implementation
22+
- [ ] Create `config_to_agent` function in `src/strands/experimental/agent_config.py`
23+
- [ ] Support both file path and dictionary input
24+
- [ ] Handle `file://` prefix for file paths
25+
- [ ] Parse JSON configuration files
26+
- [ ] Pass configuration directly to Agent constructor
27+
28+
### 2. Tool Handling Simplification
29+
- [ ] Remove ToolRegistry usage - let Agent handle tools internally
30+
- [ ] Remove DEFAULT_TOOLS concept
31+
- [ ] Pass tools list directly from config to Agent
32+
- [ ] Remove `raise_exception_on_missing_tool` parameter (use Agent's default behavior)
33+
34+
### 3. Configuration Handling
35+
- [ ] Only pass non-None config values to Agent constructor
36+
- [ ] Use Agent's default configs when values not specified
37+
- [ ] Support all Agent constructor parameters from config
38+
39+
### 4. Module Exports
40+
- [ ] Update `src/strands/experimental/__init__.py` to export `config_to_agent`
41+
- [ ] Remove `AgentConfig` class export
42+
43+
### 5. Tests Update
44+
- [ ] Refactor all tests to use `config_to_agent` function
45+
- [ ] Remove class-based test patterns
46+
- [ ] Update test imports
47+
- [ ] Simplify tool-related tests (no more ToolRegistry mocking)
48+
- [ ] Update file handling tests
49+
50+
### 6. Cleanup
51+
- [ ] Remove `AgentConfig` class entirely
52+
- [ ] Remove unused imports and dependencies
53+
- [ ] Clean up any remaining ToolRegistry references
54+
55+
## Progress Tracking
56+
- [x] Task 1: Core Function Implementation
57+
- [x] Task 2: Tool Handling Simplification
58+
- [x] Task 3: Configuration Handling
59+
- [x] Task 4: Module Exports
60+
- [x] Task 5: Tests Update
61+
- [x] Task 6: Cleanup
62+
63+
## Completed Work
64+
65+
### ✅ Core Function Implementation
66+
- Created `config_to_agent` function in `src/strands/experimental/agent_config.py`
67+
- Supports both file path and dictionary input
68+
- Handles `file://` prefix for file paths
69+
- Parses JSON configuration files
70+
- Passes configuration directly to Agent constructor
71+
72+
### ✅ Tool Handling Simplification
73+
- Removed ToolRegistry usage - Agent handles tools internally
74+
- Removed DEFAULT_TOOLS concept
75+
- Pass tools list directly from config to Agent
76+
- Removed `raise_exception_on_missing_tool` parameter (uses Agent's default behavior)
77+
78+
### ✅ Configuration Handling
79+
- Only passes non-None config values to Agent constructor
80+
- Uses Agent's default configs when values not specified
81+
- Supports all Agent constructor parameters from config
82+
83+
### ✅ Module Exports
84+
- Updated `src/strands/experimental/__init__.py` to export `config_to_agent`
85+
- Removed `AgentConfig` class export
86+
87+
### ✅ Tests Update
88+
- Refactored all tests to use `config_to_agent` function
89+
- Removed class-based test patterns
90+
- Updated test imports
91+
- Simplified tool-related tests (no more ToolRegistry mocking)
92+
- Updated file handling tests
93+
- Fixed model attribute access (`agent.model.config["model_id"]`)
94+
95+
### ✅ Cleanup
96+
- Removed `AgentConfig` class entirely
97+
- Removed unused imports and dependencies
98+
- Cleaned up ToolRegistry references
99+
100+
## Final Interface
101+
102+
### Current Interface (Experimental)
103+
```python
104+
from strands.experimental import config_to_agent
105+
106+
agent = config_to_agent("/path/to/amazing-agent.json")
107+
agent("do the thing")
108+
```
109+
110+
### Example Configuration
111+
```json
112+
{
113+
"model": "anthropic.claude-3-5-sonnet-20241022-v2:0",
114+
"prompt": "You are a helpful assistant",
115+
"tools": ["strands_tools.file_read", "my_app.tools.cake_tool", "/path/to/another_tool.py"],
116+
"name": "MyAgent",
117+
"agent_id": "agent-123"
118+
}
119+
```
120+
121+
## All Tasks Complete! ✅
122+
123+
## Notes
124+
- Preserve support for both file paths and dictionary inputs
125+
- Let Agent class handle all tool loading and validation
126+
- Use Agent's default behavior for missing tools/configs
127+
- Keep the `file://` prefix functionality

src/strands/experimental/agent_config.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ def config_to_agent(config: Union[str, Dict[str, Any]], **kwargs) -> Agent:
6666
"prompt": "system_prompt",
6767
"tools": "tools",
6868
"name": "name",
69-
"agent_id": "agent_id",
70-
"session_manager": "session_manager",
71-
"conversation_manager": "conversation_manager",
72-
"hooks": "hooks",
73-
"callback_handler": "callback_handler",
74-
"state": "state",
75-
"trace_attributes": "trace_attributes",
7669
}
7770

7871
# Only include non-None values from config

tests/strands/experimental/test_agent_config.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ def test_config_to_agent_with_name(self):
109109
agent = config_to_agent(config)
110110
assert agent.name == "TestAgent"
111111

112-
def test_config_to_agent_with_agent_id(self):
113-
"""Test config_to_agent handles agent_id."""
114-
config = {"model": "test-model", "agent_id": "test-agent-123"}
115-
agent = config_to_agent(config)
116-
assert agent.agent_id == "test-agent-123"
117-
118112
def test_config_to_agent_ignores_none_values(self):
119113
"""Test that None values in config are ignored."""
120114
config = {"model": "test-model", "prompt": None, "name": None}

0 commit comments

Comments
 (0)