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

1

Tool Registry

The ToolRegistry is the foundation of your agent's capabilities. It manages all the tools (functions) that your AI agent can execute.

Key Features:

  • Automatic function registration

  • Type hints for parameter validation

  • Docstrings used by AI for tool selection

  • Async/await support

2

OmniAgent Configuration

The OmniAgent is the core component that orchestrates AI reasoning, tool execution, and memory management.

Configuration Options:

Parameter
Description
Default

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

3

Memory Management

The memory system maintains conversation context across interactions:

Memory Modes:

  • token_budget: Maintains last N tokens of conversation

  • sliding_window: Keeps last N messages

4

Event Streaming

Events provide real-time visibility into agent operations:

Event Types:

  • agent.start - Agent begins processing

  • tool.call - Tool execution started

  • tool.result - Tool execution completed

  • agent.response - Agent generates response

  • agent.error - Error occurred

🌐 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

1

Balance Verification

Always check balance before transfers:

2

Error Handling

Implement robust error handling in tools:

3

Environment Variables

Store sensitive data securely:

4

Session Management

Use session IDs for context preservation:

🎯 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