Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add ToolRegistry #372

Merged
merged 3 commits into from
Mar 2, 2025
Merged

refactor: add ToolRegistry #372

merged 3 commits into from
Mar 2, 2025

Conversation

rmarescu
Copy link
Member

@rmarescu rmarescu commented Mar 2, 2025

What

Implement a comprehensive refactoring of the AI tools system

  • Create a modular tool system with a central ToolRegistry class
  • Move tools from hardcoded implementation in AIClient to dedicated files
  • Implement tool registration through createToolRegistry()
  • Map Anthropic's computer actions to internal actions

Why

In preparation for adding Claude 3.7.

Ref #369 (comment)

@rmarescu rmarescu self-assigned this Mar 2, 2025
Copy link

vercel bot commented Mar 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
shortest ⬜️ Ignored (Inspect) Visit Preview Mar 2, 2025 3:16am

@rmarescu rmarescu force-pushed the rmarescu/tool-registry branch from eae6747 to 32480a7 Compare March 2, 2025 00:05
@rmarescu rmarescu marked this pull request as ready for review March 2, 2025 03:38
@rmarescu rmarescu added this to the v0.4.5 milestone Mar 2, 2025
import { LanguageModelV1FinishReason } from "@ai-sdk/provider";
import {
CoreMessage,
CoreTool,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated in Vercel AI SDK.

AnthropicModelFamily,
Record<AnthropicToolType, AnthropicToolVersion>
> = {
"claude-3-5": {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy to extend with 3.7.

tools["bash"] = bashToolEntry.factory();
} catch (error) {
if (!(error instanceof ShortestError)) throw error;
this.log.trace("Bash tool not found for model, skipping", { model });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a tool is not found (e.g. bash for 3.7 not yet available upstream), the package will still work without the tool.

});
});

it("registers tools with expected keys", () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures all the tools available are properly registered. If a tool doesn't get registered, and not passed to the AI, the AI will do its best to complete the task with the missing tool. It will not be obvious - through a script error - that a tool is missing).

@rmarescu rmarescu merged commit d80a19f into main Mar 2, 2025
6 checks passed
@rmarescu rmarescu deleted the rmarescu/tool-registry branch March 2, 2025 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant