M
Mastraβ€’6d ago
sheerazz

Recreating Anthropic's Tool Search Tool

Hi, As our tools balloon in size, we were wondering if theres a good way to recreate Anthropic's Tool Search Tool with Mastra. Blog post: https://www.anthropic.com/engineering/advanced-tool-use We are limited to using open source models so having a good way to create this search without overloading context would be amazing. Any guidance would be appreciated. Thanks!
Introducing advanced tool use on the Claude Developer Platform
Claude can now discover, learn, and execute tools dynamically to enable agents that take action in the real world. Here’s how.
10 Replies
Mastra Triager
Mastra Triagerβ€’6d ago
πŸ“ Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10749 πŸ” If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly. πŸ™ Thank you for helping us improve Mastra!
Abhi Aiyer
Abhi Aiyerβ€’5d ago
Hey @sheerazz, I’m going to play with an experimental tool search utility soon. But conceptually you have a tool search tool that has a manifest of all the available tools and their description. The search can do relevance, or text search tool find the appropriate tool from the manifest and then execute it You should be able to build a lightweight one
sheerazz
sheerazzOPβ€’5d ago
Thanks @Abhi Aiyer! I built a tool search tool last night, but im having some trouble dynamically changing the tool list available during an agent's stream in between steps. I'd ideally like to keep the multistep interface if possible, but understand if thats not doable
Abhi Aiyer
Abhi Aiyerβ€’5d ago
How does it look? What ive been thinking is having
const toolSearch = createToolSearch({ tools: { tool1, tool2, tool3 }, method: 'regex' | BM25 })
const toolSearch = createToolSearch({ tools: { tool1, tool2, tool3 }, method: 'regex' | BM25 })
And somehow the tool gets added/removed in the agent
// BM25 (default) - no embedder needed
const toolSearch = await createToolSearch({
tools: myTools,
method: 'bm25',
});

// Regex - no embedder needed
const toolSearch = await createToolSearch({
tools: myTools,
method: 'regex',
});

// Embedding - requires embedder
const toolSearch = await createToolSearch({
tools: myTools,
method: 'embedding',
embedder: openai.embedding('text-embedding-3-small'),
});
// BM25 (default) - no embedder needed
const toolSearch = await createToolSearch({
tools: myTools,
method: 'bm25',
});

// Regex - no embedder needed
const toolSearch = await createToolSearch({
tools: myTools,
method: 'regex',
});

// Embedding - requires embedder
const toolSearch = await createToolSearch({
tools: myTools,
method: 'embedding',
embedder: openai.embedding('text-embedding-3-small'),
});
sheerazz
sheerazzOPβ€’5d ago
ours looks lke so:
sheerazz
sheerazzOPβ€’5d ago
what we're having trouble with is intercepting the tool search results and changing the activeTools / tool list on the agent during a stream call in between steps
Abhi Aiyer
Abhi Aiyerβ€’5d ago
i have a whacky idea for you what if you: mastra.getAgent('name').__setTools({}) Thatll set the active tools for the next step i think
sheerazz
sheerazzOPβ€’5d ago
Ill test it out this afternoon and will let you know the results!
Abhi Aiyer
Abhi Aiyerβ€’5d ago
sweet, i have cursor building out my idea too so we can see if it works lol
Abhi Aiyer
Abhi Aiyerβ€’5d ago
GitHub
Tool search and selection utility by abhiaiyer91 Β· Pull Request #1...
Description This PR introduces a toolSearch utility to enable agents to dynamically discover and utilize tools from a large library without loading all tool definitions into their context upfront. ...

Did you find this page helpful?