feat(ai): find lazy tools by search #2255
Merged
AlemTuzlakmerged 14 commits into
main fromfeat/lazy-tools-search·merged by tombeckenham View on GitHubShowing 26 changed files with 27 additions and 4 deletions (loading 22).
x
@@ -0,0 +1,6 @@
+---
+'@tanstack/ai': minor
+'@tanstack/ai-code-mode': minor
+---
+
+Add `lazyToolsConfig.catalog: 'search'`. The discovery catalog then lists no lazy tool names, so hundreds of lazy tools cost almost no prompt tokens. The model finds tools with a `query` to `__lazy__tool__discovery__` (`chat()`) or `discover_tools` (Code Mode), and gets at most 10 keyword matches. Common words such as "a", "to", and "tool" do not score. Exact `toolNames` still work. A later `chat()` query that finds only tools already discovered says those tools are already available. `@tanstack/ai` also exports `searchLazyTools(tools, query, limit?)`, the ranking that both use.
@@ -85,7 +85,7 @@
-| `lazyToolsConfig` | How much of each lazy tool description goes into the discovery catalog. See [Lazy Tool Discovery](../tools/lazy-tool-discovery). |
+| `lazyToolsConfig` | How much of each lazy tool description goes into the discovery catalog, or `catalog: 'search'` to list no tools and find them by query. See [Lazy Tool Discovery](../tools/lazy-tool-discovery). |
@@ -15,7 +15,7 @@
-Mark the rarely used tools `lazy: true`. The prompt then lists only their names. When the model needs one, it calls `discover_tools` to get the signature, then uses the tool in `execute_typescript`.
+Mark the rarely used tools `lazy: true`. By default the prompt lists only their names. Set `lazyToolsConfig.catalog` to `'search'` to list no names. The model then finds a tool with a query. It calls `discover_tools` for the signature, then uses the tool in `execute_typescript`.