Interface ToolIndex

All Known Implementing Classes:
LuceneToolIndex, RegexToolIndex, VectorToolIndex

public interface ToolIndex
Interface for searching and discovering tools on-demand.

Implementations provide different search strategies — such as embedding-based semantic search, full-text keyword search, or regex pattern matching — to find relevant tools from a registered catalog based on search queries. This aligns with the Tool Search Tool concept for dynamic tool discovery.

Since:
2.0.0
Author:
Christian Tzolov
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clearIndex(String sessionId)
    Clears all indexed tools for the specified session.
    void
    indexTool(String sessionId, ToolReference toolReference)
    Registers a tool in the search index for the specified session.
    default void
    indexTools(String sessionId, List<ToolReference> toolReferences)
    Registers multiple tools in the search index for the specified session in a single batch operation.
    search(ToolSearchRequest toolSearchRequest)
    Searches for tools matching the given request criteria.
  • Method Details

    • indexTool

      void indexTool(String sessionId, ToolReference toolReference)
      Registers a tool in the search index for the specified session.
      Parameters:
      sessionId - the session identifier for tool isolation
      toolReference - the reference to the tool being indexed
    • indexTools

      default void indexTools(String sessionId, List<ToolReference> toolReferences)
      Registers multiple tools in the search index for the specified session in a single batch operation.

      Implementations should override this method when a batch operation is more efficient than repeated indexTool(java.lang.String, org.springframework.ai.tool.toolsearch.ToolReference) calls (e.g. a single embedding API call or a single write transaction). The default implementation simply iterates and delegates to indexTool(java.lang.String, org.springframework.ai.tool.toolsearch.ToolReference).

      Parameters:
      sessionId - the session identifier for tool isolation
      toolReferences - the tools to register
    • search

      ToolSearchResponse search(ToolSearchRequest toolSearchRequest)
      Searches for tools matching the given request criteria.
      Parameters:
      toolSearchRequest - the search request containing query and parameters
      Returns:
      a response containing matching tool references
    • clearIndex

      void clearIndex(String sessionId)
      Clears all indexed tools for the specified session.
      Parameters:
      sessionId - the session identifier