Overview
Hyperbolic AgentKit uses LangChain’s tool system to extend agent capabilities. This guide shows you how to create custom tools following the framework’s patterns.Tool Basics
Tools are registered in two locations depending on your interface:- Chat/Terminal Interface -
chatbot.pyviacreate_agent_tools()(line 283) - Voice Agent Interface -
server/src/server/tools.pyviacreate_tools()
Tool Types
The framework supports two main tool implementations:LangChain BaseTool
Full-featured tools with async support, schema validation, and rich descriptions
LangChain Tool Wrapper
Simple function-based tools for quick implementations
Creating a Simple Tool
Let’s create a basic tool using the Tool wrapper pattern fromchatbot.py:158-180.
Create Tool Wrapper
Wrap your function using LangChain’s Tool class:
The description is crucial - it tells the agent when and how to use your tool.
Creating an Advanced Tool with BaseTool
For more complex tools with async support and validation, extendBaseTool. Here’s an example based on browser_agent/browser_tool.py:
Tool Organization Patterns
The framework organizes tools by domain. Follow this structure from the README (lines 268-306):Creating a Tool Module
Real-World Examples
Example 1: Twitter Tools
Fromtwitter_agent/custom_twitter_actions.py:90-129, here’s how Twitter tools are implemented:
twitter_agent/custom_twitter_actions.py
Example 2: Hyperbolic GPU Tools
Fromhyperbolic_agentkit_core/actions/rent_compute.py:28-115, complex tools use Pydantic schemas:
hyperbolic_agentkit_core/actions/rent_compute.py
Example 3: Writing Agent
Fromwriting_agent/writing_tool.py:15-129, tools with complex inputs use Pydantic schemas:
writing_agent/writing_tool.py
Environment-Based Tool Registration
Fromchatbot.py:286-398, use environment variables to conditionally enable tools:
chatbot.py
.env:
.env
Tool Best Practices
Write Clear Descriptions
Write Clear Descriptions
The agent uses tool descriptions to decide when to use each tool. Include:
- What the tool does
- Expected input format
- Example usage
- Any constraints or requirements
Handle Errors Gracefully
Handle Errors Gracefully
Always return useful error messages:
Use Async When Possible
Use Async When Possible
For I/O-bound operations, implement
_arun() for better performance:Validate Inputs with Pydantic
Validate Inputs with Pydantic
Use Pydantic schemas for complex inputs:
Store Configuration in Environment
Store Configuration in Environment
Use environment variables for API keys and settings:
Testing Your Tool
Advanced: Creating Tool Toolkits
For related tools, create a toolkit likebrowser_agent/browser_toolkit.py:
my_agent/my_toolkit.py
chatbot.py
Debugging Tools
Enable detailed logging to debug tool execution:Next Steps
Knowledge Bases
Create knowledge bases for contextual tools
Core Actions
Learn from existing tool implementations
Hyperbolic Tools
GPU compute tool examples
Twitter Tools
Social media integration patterns