Skip to content

[Feature][AWS Strands] Add tools_provider to StrandsAgentConfig for per-request tool filtering #1372

Description

@rajjayaaws

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),
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions