feat: add model switching support to think, agent_graph, swarm and use_llm tools #117
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.
Summary
This PR adds model provider switching capabilities to
think
,use_llm
,agent_graph
, andswarm
tools while migrating them from TOOL_SPEC to @tool decorator pattern.Changes Made
New Model Provider System:
bedrock
,anthropic
,litellm
,llamaapi
,ollama
,openai
utils/models.py
for dynamic model creation and configurationTool Enhancements:
think
: Addedmodel_provider
,model_settings
,thinking_system_prompt
parametersuse_llm
: Migrated to @tool decorator, added model switchingagent_graph
: Migrated to @tool decorator, added per-node model configurationswarm
: Migrated to @tool decorator, added swarm-wide model controlSecurity & Access Control:
tools
parameter to all enhanced tools for security isolationTechnical Details
All new parameters are optional with backward-compatible defaults:
Model providers are loaded dynamically based on the
model_provider
parameter. Configuration can be set via environment variables or passed directly inmodel_settings
.Use Cases
Testing
Files Changed
src/strands_tools/models/
- New model provider modules (6 files)src/strands_tools/utils/models.py
- Model factory and utilitiessrc/strands_tools/think.py
- Enhanced with model switchingsrc/strands_tools/use_llm.py
- Migrated to @tool + model switchingsrc/strands_tools/agent_graph.py
- Migrated to @tool + per-node modelssrc/strands_tools/swarm.py
- Migrated to @tool + swarm modelsBackward Compatibility
100% backward compatible. All existing tool calls work unchanged. New parameters are optional and use environment-based defaults.
Related
Addresses issues;
#74 - Multi-model support request
#20 - Unable to use custom LLM providers with tools like swarm, agent_graph, workflow
PS: Workflow tool is not in this list of changes.
Previous PR closed due messy git history, #110