|
| 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 |
0 commit comments