Back to catalog / Agent tools
Use semantic retrieval to select tools from a large library
Embed tool descriptions locally and retrieve relevant capabilities for the current task through one narrow search tool.
Goal
Avoid loading hundreds of tool definitions into the model context at once.
Steps
- Prepare tool name, description, parameter JSON, and permission labels; index a readable representation. [tool-search]
- Follow the notebook with
SentenceTransformer("all-MiniLM-L6-v2")for local embeddings and semantic top-k lookup. [tool-search] - Pass candidates only to a permission-controlled executor; measure Precision@k and missed tools on a labeled set. [tool-search]
How to verify
Even with a large catalog, context contains only search and a few candidates; low-confidence results do not execute.
Troubleshooting
If semantic search misses exact tools, add name/keyword lookup or raise top-k, then remeasure precision.
Permissions
Prerequisites
- Python, sentence-transformers, numpy; live Claude calls also require an Anthropic API key.
Permissions
- Include reviewed tool definitions only; the executor must repeat permission and parameter checks.
Limitations
The notebook’s embedding model runs locally; tool discovery grants no permission and is not an authorization boundary.
Pinned upstream source
- Repository
- anthropics/anthropic-cookbook
- File path
- tool_use/tool_search_with_embeddings.ipynb
- Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT