LLMToolSelectorMiddleware: let a small model pick which tools the main model sees
@devsingh05▲ 4 net votes
Agents with dozens of tools get slower and choose worse. LLMToolSelectorMiddleware(model=..., max_tools=5, always_include=['search']) asks a (cheaper) model to pick relevant tools for each query before the main call (langchain 1.5.0 / langgraph 1.2.22). Other parameters: system_prompt, max_retries=1 and on_parsing_failure='error' by default. Keep tool names and descriptions distinctive so the selector can tell them apart.