Skip to content

Commit fd65faf

Browse files
committed
Add Future section to ConfigLoader documentation
- Document current Agent(), Graph(), and Swarm() constructor modifications - Detail config parameter integration approach before removal - Highlight API fluidity advantages and developer experience benefits - Preserve implementation approach for potential future use - Focus on public interface rather than internal implementation details
1 parent 1ddb553 commit fd65faf

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

docs/experimental/config-loader/overview.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,126 @@ Loads and serializes Strands Graph instances via dictionary configurations. Supp
181181
- `load_graph(config, cache_key=None)` - Load graph from dictionary configuration
182182
- `serialize_graph(graph)` - Serialize graph to dictionary configuration
183183
- `clear_cache()` - Clear internal graph cache
184+
185+
---
186+
187+
## Future: Constructor Integration
188+
189+
**Note**: This section documents a future enhancement that would integrate configuration loading directly into the main constructors for improved API fluidity and developer experience.
190+
191+
### Enhanced Constructor Interface
192+
193+
The future implementation would extend the main constructors (`Agent()`, `Graph()`, and `Swarm()`) with a `config` parameter, enabling seamless configuration-driven initialization alongside traditional programmatic instantiation.
194+
195+
#### Agent Constructor Enhancement
196+
197+
```python
198+
from strands import Agent
199+
200+
# File-based configuration
201+
agent = Agent(config="agent_config.yaml")
202+
agent = Agent(config="agent_config.json")
203+
204+
# Dictionary-based configuration
205+
agent = Agent(config={
206+
"model": "us.amazon.nova-pro-v1:0",
207+
"system_prompt": "You are a helpful assistant.",
208+
"tools": [{"name": "calculator"}]
209+
})
210+
211+
# Hybrid approach - config with parameter overrides
212+
agent = Agent(
213+
config="base_config.yaml",
214+
model="us.amazon.nova-lite-v1:0", # Override config model
215+
system_prompt="Custom prompt" # Override config prompt
216+
)
217+
```
218+
219+
#### Swarm Constructor Enhancement
220+
221+
```python
222+
from strands.multiagent import Swarm
223+
224+
# File-based configuration
225+
swarm = Swarm(config="swarm_config.yaml")
226+
227+
# Dictionary-based configuration
228+
swarm = Swarm(config={
229+
"max_handoffs": 15,
230+
"agents": [
231+
{
232+
"name": "researcher",
233+
"model": "us.amazon.nova-pro-v1:0",
234+
"system_prompt": "You are a research specialist."
235+
}
236+
]
237+
})
238+
239+
# Parameter override capability
240+
swarm = Swarm(
241+
config="base_swarm.yaml",
242+
max_handoffs=25, # Override config value
243+
execution_timeout=1200.0
244+
)
245+
```
246+
247+
#### Graph Constructor Enhancement
248+
249+
```python
250+
from strands.multiagent import Graph
251+
252+
# File-based configuration via GraphBuilder
253+
graph = Graph.from_config("graph_config.yaml").build()
254+
255+
# Dictionary-based configuration
256+
graph = Graph.from_config({
257+
"nodes": [
258+
{
259+
"id": "analyzer",
260+
"agent": {
261+
"model": "us.amazon.nova-pro-v1:0",
262+
"system_prompt": "Analyze the input data."
263+
}
264+
}
265+
],
266+
"edges": [
267+
{"from": "analyzer", "to": "reporter"}
268+
],
269+
"entry_points": ["analyzer"]
270+
}).build()
271+
```
272+
273+
### API Fluidity Advantages
274+
275+
#### Unified Interface
276+
- **Consistent Experience**: Single constructor interface supports both programmatic and configuration-driven approaches
277+
- **Seamless Migration**: Easy transition from code-based to config-based initialization without changing the fundamental API
278+
- **Reduced Learning Curve**: Developers familiar with the main constructors can immediately use configuration features
279+
280+
#### Flexible Configuration Management
281+
- **Parameter Override**: Config provides defaults while explicit parameters override specific values
282+
- **Environment Adaptation**: Same codebase can use different configurations for development, staging, and production
283+
- **Dynamic Configuration**: Runtime configuration selection based on conditions or user input
284+
285+
#### Enhanced Developer Experience
286+
- **Reduced Boilerplate**: Configuration files eliminate repetitive parameter specification
287+
- **Better Maintainability**: Centralized configuration management separate from application logic
288+
- **Version Control Friendly**: Configuration changes tracked separately from code changes
289+
- **IDE Support**: Full IntelliSense and type checking for both config and parameter approaches
290+
291+
#### Backward Compatibility
292+
- **Zero Breaking Changes**: Existing code continues to work unchanged
293+
- **Gradual Adoption**: Teams can migrate to configuration-driven approach incrementally
294+
- **Interoperability**: Mix and match approaches within the same application
295+
296+
### Implementation Benefits
297+
298+
The enhanced constructor approach provides superior API fluidity by:
299+
300+
1. **Eliminating Context Switching**: Developers stay within familiar constructor patterns rather than learning separate loader classes
301+
2. **Reducing Import Complexity**: No need to import and manage separate config loader classes
302+
3. **Maintaining Type Safety**: Full type hints and validation for both configuration and parameter approaches
303+
4. **Enabling Hybrid Workflows**: Seamless combination of configuration defaults with runtime parameter overrides
304+
5. **Preserving Existing Patterns**: All current usage patterns remain valid while adding new capabilities
305+
306+
This approach represents the natural evolution of the Strands Agents API, providing maximum flexibility while maintaining the simplicity and elegance that developers expect from the framework.

0 commit comments

Comments
 (0)