tools.search_tools module

Search the tool registry by keyword or semantic (vector) similarity.

Keyword mode performs a fast case-insensitive substring match over tool names and descriptions. Semantic mode embeds the query with Gemini via OpenRouterEmbeddings and runs a RediSearch KNN query against the pre-computed tool embedding index, falling back to keyword search if the index is unavailable.

async tools.search_tools.run(query, mode, top_k=10, include_parameters=False, ctx=None, **_kwargs)[source]

Search the tool registry and return matching tool definitions.

Parameters:
  • query (str) – The search query string.

  • mode (str) – "semantic" or "keyword".

  • top_k (int) – Maximum number of results.

  • include_parameters (bool) – Whether to include parameter schemas.

  • ctx – Injected tool context.

Return type:

str

Returns:

JSON string with success, mode, fallback, query, result_count, and results fields.