OmniCoreAgent
AgentiPy provides seamless integration with the OmniAgent framework, allowing you to create AI agents that can interact with the Solana blockchain through natural language interfaces. This integration enables developers to build sophisticated AI-driven blockchain applications with conversational capabilities, real-time event streaming, and robust memory management.
🚀 Quick Start
import asyncio
from mcpomni_connect.omni_agent import OmniAgent
from mcpomni_connect.memory_store.memory_router import MemoryRouter
from mcpomni_connect.events.event_router import EventRouter
from mcpomni_connect.agents.tools.local_tools_registry import ToolRegistry
from agentipy.agent import SolanaAgentKit
from agentipy.tools.get_balance import BalanceFetcher
from agentipy.tools.transfer import TokenTransferManager
from dotenv import load_dotenv
from typing import Optional
import os
load_dotenv()
# Initialize Solana agent
solana_agent = SolanaAgentKit(
private_key=os.getenv("SOLANA_PRIVATE_KEY"),
rpc_url="https://api.mainnet-beta.solana.com"
)
# Create tool registry
async def create_tool_registry() -> ToolRegistry:
"""Create a tool registry with Solana operations."""
tool_registry = ToolRegistry()
@tool_registry.register_tool("get_balance_solana")
async def get_balance(address: Optional[str] = None) -> str:
"""Get the balance of a Solana address."""
try:
balance_sol = await BalanceFetcher.get_balance(
solana_agent,
token_address=address
)
return {"status": "success", "data": balance_sol}
except Exception as e:
return {"status": "error", "message": str(e)}
@tool_registry.register_tool("transfer_solana")
async def transfer_solana(address: str, amount: float) -> str:
"""Transfer SOL to a Solana address."""
try:
sig = await TokenTransferManager.transfer(
solana_agent,
to=address,
amount=amount
)
return {
"status": "success",
"message": "SOL transferred successfully",
"signature": sig
}
except Exception as e:
return {"status": "error", "message": str(e)}
return tool_registry
# Initialize memory and event systems
memory_store = MemoryRouter(memory_store_type="in_memory")
event_router = EventRouter(event_store_type="in_memory")
# Create the OmniAgent
async def create_agent():
tool_registry = await create_tool_registry()
agent = OmniAgent(
name="solana_agent",
system_instruction="""
You are a Solana agent with the ability to check balances and transfer SOL.
CRITICAL RULES:
- Always check balance before transfers using get_balance_solana
- Verify sufficient funds before calling transfer_solana
- Only use available tools in the registry
""",
model_config={
"provider": "openai",
"model": "gpt-4.1",
"temperature": 0.7,
"max_context_length": 50000,
},
local_tools=tool_registry,
agent_config={
"max_steps": 15,
"tool_call_timeout": 60,
"request_limit": 1000,
"memory_config": {"mode": "token_budget", "value": 10000},
},
memory_store=memory_store,
event_router=event_router,
debug=True,
)
return agent
# Run the agent
async def main():
agent = await create_agent()
# Check balance
response = await agent.run(
"What's my SOL balance?",
session_id="session_001"
)
print(response)
# Transfer SOL
response = await agent.run(
"Transfer 0.5 SOL to <address>",
session_id="session_001"
)
print(response)
asyncio.run(main())🛠️ Key Components
OmniAgent Configuration
The OmniAgent is the core component that orchestrates AI reasoning, tool execution, and memory management.
Configuration Options:
name
Agent identifier
Required
system_instruction
AI behavior guidelines
Required
model_config
LLM configuration
Required
local_tools
Tool registry
None
agent_config
Execution settings
{}
memory_store
Conversation memory
None
event_router
Event tracking
None
debug
Enable debug logging
False
🌐 FastAPI Integration
Create a production-ready API service:
📋 Available Tools
Get Balance
Check the SOL balance of any Solana address:
Transfer SOL
Send SOL to any Solana address:
🔒 Best Practices
🎯 Use Cases
Conversational Wallet
Automated Trading Bot
Multi-User Support
🐛 Debugging
Enable debug mode for detailed logging:
This will log:
Tool selection reasoning
Parameter extraction
Execution results
Error traces
📚 API Reference
OmniAgent.run()
Execute a user message and return response.
OmniAgent.stream_events()
Stream real-time events from a session.
🚦 Next Steps
Explore CrewAI Integration
Learn about Google ADK Integration
Check Advanced Configuration
See Production Deployment Guide
