Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

docs: add CubePi brand assets and refresh README

Chris6d99653deec7
diff --git a/README.md b/README.md
index 2a010e2..f941d67 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,8 @@
-# cubepi
+<p align="center">
+ <img src="https://raw.githubusercontent.com/cubeplexai/cubepi/main/assets/brand/cubepi-logo.svg" alt="CubePi logo" width="160">
+</p>
+
+<h1 align="center">CubePi</h1>
[![CI](https://github.com/cubeplexai/cubepi/actions/workflows/ci.yml/badge.svg)](https://github.com/cubeplexai/cubepi/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/cubeplexai/cubepi/graph/badge.svg)](https://codecov.io/gh/cubeplexai/cubepi)
@@ -6,52 +10,37 @@
[![Python](https://img.shields.io/pypi/pyversions/cubepi)](https://pypi.org/project/cubepi/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
-Pythonic async-native agent framework. Built to replace [langgraph](https://github.com/langchain-ai/langgraph) with something simpler, faster, and easier to reason about.
-
-Inspired by [pi-agent-core](https://github.com/anthropics/pi-agent-core) (TypeScript), redesigned for Python.
-
-## Why cubepi
+A Pythonic, async-native agent framework — a leaner, more readable take on agent runtimes like [langgraph](https://github.com/langchain-ai/langgraph).
-### vs langgraph
+## Why CubePi
-| | langgraph | cubepi |
+| | langgraph | CubePi |
|---|---|---|
| **Abstraction** | Graph nodes + edges + channels — you model your agent as a state machine | Plain async functions — `run_agent_loop` is a while loop you can read in 5 minutes |
| **Streaming** | Callback-based, multiple handler types | `async for event in stream` — one pattern everywhere |
| **Checkpointing** | Full snapshot per step — serializes entire message list on every channel change | Append-only — writes only new messages, O(1) DB I/O regardless of conversation length |
| **Dependencies** | Pulls in langchain-core, langgraph-sdk, and transitive deps | 3 core deps: `pydantic`, `anthropic`, `openai` |
| **Tool execution** | Tools are graph nodes with manual wiring | Declare tools as functions, framework handles routing and parallel execution |
-| **Multi-provider** | Via langchain chat model adapters | Native Provider protocol — Anthropic, OpenAI built in, add your own with one class |
+| **Multi-provider** | Via langchain chat model adapters | Native `Provider` protocol — Anthropic, OpenAI built in, add your own with one class |
| **Middleware** | Graph-level middleware on node entry/exit | Agent-level middleware with 5 typed hooks and declarative composition rules |
| **Observability** | LangSmith / Langfuse integration, full trace visualization | Events + middleware hooks — bring your own tracing |
-### vs pi-agent-core
-
-cubepi is a Python port of pi's architecture with Pythonic improvements:
-
-| | pi-agent-core | cubepi |
-|---|---|---|
-| **Language** | TypeScript | Python (async-native) |
-| **Type system** | Zod schemas | Pydantic v2 — validation, serialization, JSON Schema generation in one |
-| **Cancel signal** | `AbortSignal` (Web API) | `asyncio.Event` — same semantics, native to Python |
-| **Middleware** | Hooks only (callbacks on Agent) | Hooks + composable Middleware protocol with `compose_middleware()` |
-| **Checkpointing** | Not built in | Built-in `MemoryCheckpointer` + `SQLiteCheckpointer` |
-| **Test utility** | Internal test helpers | `FauxProvider` as public API — ship it, use it in your tests |
-
## Install
```bash
pip install cubepi
-# With SQLite checkpointer
-pip install cubepi[sqlite]
+# Optional extras
+pip install cubepi[sqlite] # SQLite checkpointer
+pip install cubepi[postgres] # Postgres checkpointer
+pip install cubepi[mcp] # MCP tool loaders
```
Or with [uv](https://github.com/astral-sh/uv):
```bash
uv add cubepi
-uv add cubepi[sqlite]
+uv add cubepi[sqlite,postgres,mcp]
```
## Quick Start
@@ -59,7 +48,7 @@ uv add cubepi[sqlite]
```python
import asyncio
from cubepi import Agent, AgentTool, Model
-from cubepi.providers import AnthropicProvider
+from cubepi.providers.anthropic import AnthropicProvider
provider = AnthropicProvider(api_key="sk-...")
@@ -68,7 +57,7 @@ def get_weather(city: str) -> str:
return f"72°F and sunny in {city}"
agent = Agent(
- model=Model(provider=provider, model="claude-sonnet-4-20250514"),
+ model=Model(provider=provider, model="claude-sonnet-4-5-20250929"),
tools=[
AgentTool(
name="get_weather",
@@ -99,21 +88,24 @@ asyncio.run(main())
```
cubepi/
├── providers/ # LLM provider abstraction
-│ ├── base.py # Provider protocol, message types, MessageStream
-│ ├── anthropic.py # Anthropic provider
-│ ├── openai.py # OpenAI provider
-│ └── faux.py # Test utility — pre-configured responses with realistic streaming
+│ ├── base.py # Provider protocol, message types, MessageStream
+│ ├── anthropic.py # Anthropic provider
+│ ├── openai.py # OpenAI Chat Completions provider
+│ ├── openai_responses.py # OpenAI Responses provider
+│ └── faux.py # Test utility — pre-configured responses with realistic streaming
├── agent/ # Agent runtime
│ ├── agent.py # Stateful Agent class
│ ├── loop.py # Stateless core loop (the actual algorithm)
│ ├── tools.py # Tool execution engine (sequential + parallel)
│ └── types.py # Events, AgentTool, AgentContext, hook types
-├── middleware/ # Composable middleware protocol
+├── middleware/ # Composable middleware protocol
│ └── base.py # 5 hooks with distinct composition rules
-└── checkpointer/ # Persistence
- ├── base.py # Checkpointer protocol
- ├── memory.py # In-memory (dev/test)
- └── sqlite.py # SQLite (lightweight persistence)
+├── checkpointer/ # Persistence
+│ ├── base.py # Checkpointer protocol
+│ ├── memory.py # In-memory (dev/test)
+│ ├── sqlite.py # SQLite (lightweight persistence)
+│ └── postgres/ # Postgres (production persistence)
+└── mcp/ # MCP tool loaders (HTTP + stdio transports)
```
## Core Concepts
@@ -123,7 +115,9 @@ cubepi/
Abstract LLM interaction behind a `Provider` protocol. All providers return `MessageStream` — an async iterator of `StreamEvent`s.
```python
-from cubepi.providers import AnthropicProvider, OpenAIProvider, FauxProvider
+from cubepi.providers.anthropic import AnthropicProvider
+from cubepi.providers.openai import OpenAIProvider
+from cubepi.providers import FauxProvider
# Real providers
anthropic = AnthropicProvider(api_key="...")
@@ -190,7 +184,7 @@ hooks = compose_middleware([LoggingMiddleware(), SafetyMiddleware()])
Persist conversation state with append-only semantics:
```python
-from cubepi.checkpointer import MemoryCheckpointer, SQLiteCheckpointer
+from cubepi.checkpointer import MemoryCheckpointer, SQLiteCheckpointer, PostgresCheckpointer
# In-memory for dev/test
cp = MemoryCheckpointer()
@@ -198,6 +192,10 @@ cp = MemoryCheckpointer()
# SQLite for lightweight persistence
async with SQLiteCheckpointer("agent.db") as cp:
agent = Agent(model=model, checkpointer=cp, thread_id="conv-1")
+
+# Postgres for production
+async with PostgresCheckpointer("postgresql://...") as cp:
+ agent = Agent(model=model, checkpointer=cp, thread_id="conv-1")
```
### FauxProvider for Testing
@@ -224,7 +222,11 @@ stream = await agent.prompt("Search for python")
- Python >= 3.11
- Core: `pydantic`, `anthropic`, `openai`
-- Optional: `aiosqlite` (for `SQLiteCheckpointer`)
+- Optional: `aiosqlite` (`[sqlite]`), `asyncpg` + `sqlalchemy` + `msgpack` (`[postgres]`), `mcp` (`[mcp]`)
+
+## Credits
+
+Architecture inspired by [pi-agent-core](https://github.com/anthropics/pi-agent-core) (TypeScript); CubePi is an independent Python reimplementation with Pydantic v2, asyncio-native primitives, and built-in checkpointing.
## License
diff --git a/assets/brand/cubepi-logo.png b/assets/brand/cubepi-logo.png
new file mode 100644
index 0000000..baf7bba
Binary files /dev/null and b/assets/brand/cubepi-logo.png differ
diff --git a/assets/brand/cubepi-logo.svg b/assets/brand/cubepi-logo.svg
new file mode 100644
index 0000000..657fb5f
--- /dev/null
+++ b/assets/brand/cubepi-logo.svg
@@ -0,0 +1,19 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" role="img" aria-labelledby="title desc">
+ <title id="title">cubepi logo</title>
+ <desc id="desc">An isometric cube shell with two vertical operator eyes on the open front face.</desc>
+ <defs>
+ <style>
+ .ink { fill: #050608; }
+ .accent { fill: #3042d5; }
+ </style>
+ </defs>
+
+ <rect width="512" height="512" fill="#ffffff"/>
+
+ <path class="ink" d="M261 117 L396 183 L244 252 L120 183 Z"/>
+ <path class="ink" d="M115 198 L232 263 L232 432 L115 365 Z"/>
+ <path class="ink" d="M355 346 L397 365 L397 376 L252 446 L247 442 L247 395 Z"/>
+
+ <rect class="accent" x="287" y="268" width="26" height="74" rx="12"/>
+ <rect class="accent" x="351" y="247" width="26" height="76" rx="12"/>
+</svg>
\ No newline at end of file
diff --git a/assets/brand/cubepi-social-preview.png b/assets/brand/cubepi-social-preview.png
new file mode 100644
index 0000000..a12bc25
Binary files /dev/null and b/assets/brand/cubepi-social-preview.png differ
diff --git a/assets/brand/cubepi-social-preview.svg b/assets/brand/cubepi-social-preview.svg
new file mode 100644
index 0000000..9ae39aa
--- /dev/null
+++ b/assets/brand/cubepi-social-preview.svg
@@ -0,0 +1,63 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 640" role="img" aria-labelledby="title desc">
+ <title id="title">cubepi social preview</title>
+ <desc id="desc">Social preview for cubepi, a Pythonic async-native agent framework.</desc>
+ <defs>
+ <style>
+ .ink { fill: #050608; }
+ .muted { fill: #52525b; }
+ .line { stroke: #e4e4e7; }
+ .accent { fill: #3042d5; }
+ </style>
+ <linearGradient id="bgGrad" x1="0" y1="0" x2="1" y2="1">
+ <stop offset="0%" stop-color="#fbfbfd"/>
+ <stop offset="100%" stop-color="#eef0f5"/>
+ </linearGradient>
+ <linearGradient id="waveGrad" x1="0" y1="0" x2="1" y2="1">
+ <stop offset="0%" stop-color="#e1e7fc"/>
+ <stop offset="100%" stop-color="#c7d1f6"/>
+ </linearGradient>
+ <radialGradient id="accentBlob" cx="0.5" cy="0.5" r="0.5">
+ <stop offset="0%" stop-color="#c7d1f6" stop-opacity="0.7"/>
+ <stop offset="100%" stop-color="#c7d1f6" stop-opacity="0"/>
+ </radialGradient>
+ <pattern id="dotgrid" x="0" y="0" width="36" height="36" patternUnits="userSpaceOnUse">
+ <circle cx="2" cy="2" r="1.1" fill="#d6d6dd"/>
+ </pattern>
+ </defs>
+
+ <rect width="1280" height="640" fill="url(#bgGrad)"/>
+ <rect width="1280" height="640" fill="url(#dotgrid)" opacity="0.45"/>
+
+ <!-- right-side wave: deeper, gradient layered -->
+ <path d="M1032 0h248v640h-160c-52-72-78-156-78-252 0-92 20-181-10-388Z" fill="url(#waveGrad)"/>
+ <path d="M1090 0h190v580h-110c-40-58-60-128-60-208 0-78 12-150-20-372Z" fill="#c7d1f6" opacity="0.55"/>
+ <circle cx="1180" cy="120" r="160" fill="url(#accentBlob)"/>
+
+ <!-- subtle floating accents -->
+ <rect x="74" y="68" width="14" height="14" rx="3" fill="#3042d5" opacity="0.14"/>
+ <rect x="50" y="558" width="22" height="22" rx="5" fill="#3042d5" opacity="0.10" transform="rotate(18 61 569)"/>
+ <rect x="980" y="48" width="10" height="10" rx="2" fill="#3042d5" opacity="0.18"/>
+ <circle cx="500" cy="80" r="4" fill="#3042d5" opacity="0.18"/>
+ <circle cx="180" cy="540" r="3" fill="#3042d5" opacity="0.22"/>
+
+ <path d="M0 552h1280" class="line" stroke-width="1" opacity="0.7"/>
+
+ <g transform="translate(120 101) scale(.78)">
+ <path class="ink" d="M261 117 L396 183 L244 252 L120 183 Z"/>
+ <path class="ink" d="M115 198 L232 263 L232 432 L115 365 Z"/>
+ <path class="ink" d="M355 346 L397 365 L397 376 L252 446 L247 442 L247 395 Z"/>
+ <rect class="accent" x="287" y="268" width="26" height="74" rx="12"/>
+ <rect class="accent" x="351" y="247" width="26" height="76" rx="12"/>
+ </g>
+
+ <g transform="translate(552 222)">
+ <text x="0" y="0" font-family="DejaVu Sans, Liberation Sans, Arial, sans-serif" font-size="96" font-weight="700" fill="#050608">CubePi</text>
+ <text x="4" y="68" font-family="DejaVu Sans, Liberation Sans, Arial, sans-serif" font-size="31" font-weight="400" fill="#52525b">Pythonic async-native agent framework</text>
+ <g transform="translate(4 120)">
+ <path d="M0 0h536" class="line" stroke-width="1"/>
+ <path d="M0 56h148M196 56h148M392 56h148" stroke="#050608" stroke-width="10" stroke-linecap="round"/>
+ <rect x="164" y="43" width="18" height="26" rx="6" class="accent"/>
+ <rect x="360" y="43" width="18" height="26" rx="6" class="accent"/>
+ </g>
+ </g>
+</svg>
\ No newline at end of file