/ releasenotes / notes / add-tool-search-toolset-ca7c9c04f9e4b7cf.yaml
add-tool-search-toolset-ca7c9c04f9e4b7cf.yaml
 1  ---
 2  features:
 3    - |
 4      Added ``SearchableToolset`` to ``haystack.tools`` module. This new toolset enables agents to dynamically discover
 5      tools from large catalogs using keyword-based (BM25) search. Instead of exposing all tools upfront (which can
 6      overwhelm LLMs with large tool definitions), agents start with a single ``search_tools`` function and progressively
 7      discover relevant tools as needed. For smaller catalogs, it operates in passthrough mode exposing all tools
 8      directly.
 9  
10      Key features include configurable search threshold for automatic passthrough mode and top-k result limiting.
11  
12      Example usage:
13  
14      .. code:: python
15  
16        from haystack.components.agents import Agent
17        from haystack.components.generators.chat import OpenAIChatGenerator
18        from haystack.dataclasses import ChatMessage
19        from haystack.tools import Tool, SearchableToolset
20  
21        # Create a catalog of tools
22        catalog = [
23            Tool(name="get_weather", description="Get weather for a city", ...),
24            Tool(name="search_web", description="Search the web", ...),
25            # ... 100s more tools
26        ]
27        toolset = SearchableToolset(catalog=catalog)
28  
29        agent = Agent(chat_generator=OpenAIChatGenerator(), tools=toolset)
30  
31        # The agent is initially provided only with the search_tools tool and will use it to find relevant tools.
32        result = agent.run(messages=[ChatMessage.from_user("What's the weather in Milan?")])