Basic Usage
This guide covers the most common patterns you’ll need when working with OmniCoreAgent — from running your first query to handling errors in production.Running an Agent
Every interaction starts withagent.run(). It returns a dictionary with the agent’s response and metadata.
Session Management
Usesession_id to give your agent persistent memory across multiple calls. Without it, each call is stateless.
Retrieving History
Clearing History
Adding Memory Persistence
By default, history is stored in-memory (lost on restart). Add aMemoryRouter to persist across restarts.
Using Tools
MCP Tools (External Servers)
Connect to any MCP-compatible tool server:Local Tools (Custom Python Functions)
Register any Python function as a tool the agent can call:Community Tools (Pre-built)
Use 40+ ready-made tools without writing any code:Event Streaming
Listen to agent events in real-time — useful for building UIs, logging, or debugging:Error Handling
Wrap agent calls with try/except for production use:Common Troubleshooting
| Error | Fix |
|---|---|
Invalid API key | Check .env: LLM_API_KEY=your_key |
ModuleNotFoundError | pip install omnicoreagent |
Redis connection failed | Start Redis or use MemoryRouter("in_memory") |
MCP connection refused | Ensure MCP server is running and path is correct |
Token limit exceeded | Increase total_tokens_limit or enable context management |