-
-
Notifications
You must be signed in to change notification settings - Fork 408
feat(tools): add simple endpoint toggle to createTool #640
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
base: main
Are you sure you want to change the base?
Conversation
|
|
Hey @fav-devs , thanks a lot for the PR! I think we could directly expose the tools of the agents registered in |
✅ Branch History Cleaned!The branch has been rebased on the latest Tool Endpoint Feature Commits:
The old unrelated commits from the About Auto-DiscoveryRegarding your suggestion about auto-discovery from I'd like to discuss the best approach for auto-discovery in the new architecture: Option 1: Server Provider Integration import { honoServer } from "@voltagent/server-hono";
import { generateToolEndpoints } from "@voltagent/core";
new VoltAgent({
agents: { agent },
server: honoServer({
port: 3141,
configureApp: (app) => {
// Auto-generate tool endpoints
const endpoints = generateToolEndpoints(agentRegistry);
endpoints.forEach(endpoint => {
app[endpoint.method](endpoint.path, endpoint.handler);
});
},
}),
});Option 2: Built-in Server Provider Option new VoltAgent({
agents: { agent },
server: honoServer({
port: 3141,
enableToolEndpoints: true, // Auto-discover and register
}),
});Which approach would you prefer? Or do you have a different pattern in mind for the new architecture? |
837573a to
a346d60
Compare
- add optional endpoint configuration to Tool class
- endpoints are OFF by default for security
- simple toggle pattern: endpoint: { enabled: true }
- support for custom paths, methods, auth, rate limiting
- add generateEndpointsFromTools utility function
- add batch and listing endpoint generators
- fix tool spreading in reasoning tools
- add complete documentation and working example
- backward compatible with existing tools
- change default basePath from /api/tools to /tools
- update all documentation and examples
- align with agent endpoint pattern (/agents/{id}/...)
- maintain consistency across API surface
- use Object.assign with prototype to maintain tool class methods - fixes TypeScript build errors for canBeEndpoint, toEndpoint, getEndpointInfo - wrapped tools now retain all Tool class functionality - resolves DTS generation failures
2985b6b to
ce87b1c
Compare
|
Please check it now |
Overview
Adds a simplified approach for exposing agent tools as HTTP endpoints. Instead of requiring separate functions or decorators, tools can now be exposed as endpoints by simply adding an optional
endpointparameter to the existingcreateTool()function.Key Features
endpoint: { enabled: true }to any tool/tools/{id}matching/agents/{id}/...)Changes
Core Implementation
ToolEndpointConfiginterface for endpoint configurationendpointparameter toToolOptions<T>endpointproperty toToolclasscanBeEndpoint(),toEndpoint(),getEndpointInfo()generateEndpointsFromTools(),createBatchEndpoint(),createListingEndpoint()API Endpoints
POST /tools/{toolName}- Execute tool with JSON bodyGET /tools/{toolName}- Execute via query params (ifsupportsGet: true)POST /tools/batch- Execute multiple tools in a single requestGET /tools- List all available tools and their schemasDocumentation
docs/tool-endpoints.mdexamples/simple-tool-endpoints/Example Usage
Testing
Migration
Existing tools continue to work unchanged. To add endpoints:
No breaking changes. No refactoring required.
Commits
d31687bd- feat(tools): add simple endpoint toggle to createTool5343f8d5- refactor(tools): update endpoint paths from /api/tools to /tools3a8028d9- fix(agent): preserve tool instance methods when wrapping execute