Problem
StrandsAgent uses a fixed tool set, whatever tools the template agent was created with. There's no way to vary tools per request based on the caller's identity, role, or context.
This is needed for multi-user deployments where different users should have access to different tools. For example:
- Role-based access: admin users get write tools, regular users get read-only tools
- Feature gating: gradually enabling new tools for a subset of users
- Context-dependent: different workflows require different tool sets
Proposed Solution
Add a tools_provider callback to StrandsAgentConfig:
ToolsProvider = Callable[[RunAgentInput], Optional[List[Any]]]
The callback receives the full RunAgentInput (which includes thread_id, state, messages, and forwarded_props, useful for extracting auth/role info) and returns the tool list for that request. If it returns None or is not configured, the default tools from the template agent are used.
When the returned tool set changes between requests on the same thread, the agent instance is recreated with the new tools.
Usage
def resolve_tools(input_data: RunAgentInput) -> list:
role = input_data.forwarded_props.get("user_role", "viewer")
if role == "admin":
return [read_tool, write_tool, delete_tool]
return [read_tool]
agui_agent = StrandsAgent(
agent=agent,
name="my_agent",
config=StrandsAgentConfig(tools_provider=resolve_tools),
)
Problem
StrandsAgentuses a fixed tool set, whatever tools the template agent was created with. There's no way to vary tools per request based on the caller's identity, role, or context.This is needed for multi-user deployments where different users should have access to different tools. For example:
Proposed Solution
Add a
tools_providercallback toStrandsAgentConfig:The callback receives the full
RunAgentInput(which includesthread_id,state,messages, andforwarded_props, useful for extracting auth/role info) and returns the tool list for that request. If it returnsNoneor is not configured, the default tools from the template agent are used.When the returned tool set changes between requests on the same thread, the agent instance is recreated with the new tools.
Usage