Overview
Theinitialize_agent() function is the main entry point for setting up the Hyperbolic AgentKit. It initializes the LLM, character configuration, knowledge bases, and all available tools.
Function Signature
Returns
The initialized LangGraph ReAct agent with all configured tools.
Configuration dictionary containing character settings, thread ID, and checkpoint information.
LangChain runnable configuration with recursion limits and checkpoint settings.
Example Usage
Initialization Process
The function performs the following steps:1. LLM Initialization
2. Character Configuration
Loads character configuration from JSON file specified inCHARACTER_FILE environment variable:
3. Wallet Provider Setup
Configures Coinbase CDP wallet provider:4. AgentKit Initialization
Sets up Coinbase AgentKit with action providers:5. Knowledge Base Setup
Optionally initializes knowledge bases:- Twitter Knowledge Base: Scrapes tweets from KOLs
- Podcast Knowledge Base: Processes podcast transcripts
6. Tool Registration
Registers tools based on environment configuration:7. Agent Creation
Creates the LangGraph ReAct agent:Configuration Structure
The returnedconfig dictionary contains:
Available Tools
Tools are conditionally enabled based on environment variables:Core Toolkits
- Coinbase Tools (
USE_COINBASE_TOOLS=true): Blockchain and wallet operations - Hyperbolic Tools (
USE_HYPERBOLIC_TOOLS=true): GPU compute management - Browser Tools (
USE_BROWSER_TOOLS=true): Web automation - Twitter Core (
USE_TWITTER_CORE=true): Twitter API integration
Additional Tools
- Writing Agent (
USE_WRITING_AGENT=true): Content generation - Web Search (
USE_WEB_SEARCH=true): DuckDuckGo search - Request Tools (
USE_REQUEST_TOOLS=true): HTTP requests - GitHub Tools (
USE_GITHUB_TOOLS=true): GitHub API integration
Twitter-Specific Tools
- Tweet reply tracking (
USE_TWEET_REPLY_TRACKING=true) - Tweet repost tracking (
USE_TWEET_REPOST_TRACKING=true) - Tweet deletion (
USE_TWEET_DELETE=true) - User ID lookup (
USE_USER_ID_LOOKUP=true) - User tweets lookup (
USE_USER_TWEETS_LOOKUP=true) - Retweet (
USE_RETWEET=true)
Knowledge Bases
- Twitter Knowledge Base (
USE_TWITTER_KNOWLEDGE_BASE=true) - Podcast Knowledge Base (
USE_PODCAST_KNOWLEDGE_BASE=true)
Error Handling
- Missing required environment variables
- Invalid character file path
- API key authentication failures
- Knowledge base initialization errors
Interactive Setup
During initialization, the function prompts for:- Twitter Knowledge Base: Initialize? Clear existing? Update with KOL tweets?
- Podcast Knowledge Base: Initialize? Process new transcripts?
Helper Functions
loadCharacters()
Loads character configuration from JSON files:process_character_config()
Processes character JSON into agent personality:create_agent_tools()
Creates and returns list of tools based on configuration:Related Documentation
- Character Schema - Character configuration format
- Environment Variables - Required configuration