langgraph_agent_toolkit.core.tool_selection module
Configure optional LangChain tool selection without shared request state.
- class langgraph_agent_toolkit.core.tool_selection.ToolSelectionMiddleware(config, *, selector_model=None, protected_tools=())[source][source]
Bases:
AgentMiddlewareAdapt native selectors to the tools in each model request.
Each call creates a native middleware instance. Required Deep Agents tools stay visible when they exist in that request. Concurrent calls do not change one another’s tool lists or selection configuration.
- Parameters:
config (ToolSelectionConfig)
selector_model (BaseChatModel | None)
protected_tools (Sequence[str])
- transformers = (<class 'langchain.agents.middleware.internal_call_transformer.InternalCallTransformer'>,)
Stream transformer factories registered by the middleware.
Each entry is a scope-aware factory invoked as factory(scope) so every invocation receives a fresh instance. Factories are merged with the transformers argument of [create_agent][langchain.agents.create_agent] at graph compile time, after the ToolCallTransformer and before any user-supplied entries.
- __init__(config, *, selector_model=None, protected_tools=())[source][source]
- Parameters:
config (ToolSelectionConfig)
selector_model (BaseChatModel | None)
protected_tools (Sequence[str])
- Return type:
None
- langgraph_agent_toolkit.core.tool_selection.create_tool_selection_middleware(config=None, *, selector_model=None, protected_tools=())[source][source]
Resolve settings and optional managed model configuration at graph setup.
- Parameters:
config (ToolSelectionConfig | None)
selector_model (BaseChatModel | None)
protected_tools (Sequence[str])
- Return type:
list[AgentMiddleware]