CubePi
CubePi is a Pythonic, async-native agent framework designed for high
performance, readability, and production-grade persistence. It provides a
leaner alternative to graph-based agent runtimes by modeling agent logic as
a linear while loop that developers can easily trace and debug.
pip install cubepi
Then jump to the Quick Start to ship a working tool-using agent in under five minutes.
What you get
- Plain async functions, not graph nodes. The agent loop is a
whileloop over message turns. You build tools asasync deffunctions; the framework routes calls and executes them in parallel. - One streaming pattern. Every provider yields
StreamEvents through aMessageStream. You iterate it withasync for. No callback registries, no separate handler types for text vs. tools. - Append-only checkpointing. Persistence writes the new messages on each turn, not the full transcript. O(1) DB I/O regardless of conversation length — SQLite for laptops, Postgres for production.
- Native multi-provider. Anthropic and OpenAI ship in the box,
through a
ProviderProtocol. Add a new provider in one class. - Eight-hook middleware.
transform_context,convert_to_llm,transform_system_prompt,before_tool_call,after_tool_call,should_stop_after_turn,after_model_response,on_run_end— each with explicit composition rules. No mystery node ordering. - MCP loaders. Point at any
Model Context Protocol server
(HTTP or stdio) and get back a list of
AgentTools. - OpenTelemetry built in. Attach a
Tracerand every prompt produces a tree of OTel spans aligned with the GenAI Semantic Conventions — works with Jaeger, Tempo, Honeycomb, Datadog, or any OTLP-compatible backend. No payloads recorded by default; opt in withrecord_content=Trueand aredactcallback. - Human-in-the-Loop. Suspend an agent mid-run, route a decision to a human (approve/reject/answer), then resume — with full checkpoint persistence so the agent survives a process restart while waiting.
Where to go next
| If you want to… | Start here |
|---|---|
| Install and run your first agent | Getting Started → Installation |
| Understand the building blocks | Getting Started → Core Concepts |
| Wire a real tool-using agent | Guides → Building Your First Agent |
| Persist a conversation across restarts | Guides → SQLite Checkpointing |
| Ship traces to Jaeger / Tempo / Honeycomb | Guides → Tracing |
| Look up a specific symbol | API Reference |
| See full working examples | Recipes |
| Port an existing langgraph agent | Migration → From langgraph |
Status
You are reading the CubePi 0.9 release docs. This is the latest stable documentation set for installing CubePi and building against the published 0.9 API.
CubePi 0.9 adds FallbackBoundModel for automatic provider failover,
BoundModel.generate() / .stream() for direct provider calls without
an agent loop, and TodoListMiddleware for structured task tracking in
multi-step agents. Several internal APIs tightened around BoundModel
(see Changelog for migration notes).
Source, issues, and discussion live on GitHub.