Skip to content

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

docs(v0.8): sync recipes with current — add Run the example sections, fix resumable-tasks resume guard, update model IDs

xf gong2f7868c7f0c5
diff --git a/website/versioned_docs/version-0.8/recipes/ask-user-form.md b/website/versioned_docs/version-0.8/recipes/ask-user-form.md
index 2da7bbf..58fd089 100644
--- a/website/versioned_docs/version-0.8/recipes/ask-user-form.md
+++ b/website/versioned_docs/version-0.8/recipes/ask-user-form.md
@@ -182,3 +182,18 @@ async def main():
asyncio.run(main())
```
+
+## Run the example
+
+A self-contained, runnable version of this recipe is in the repository at
+[`examples/ask_user_form.py`](https://github.com/cubeplexai/cubepi/blob/main/examples/ask_user_form.py).
+The host loop answers all questions programmatically so you can observe the
+full round-trip without wiring up a real UI.
+
+```bash
+git clone https://github.com/cubeplexai/cubepi && cd cubepi
+uv sync
+
+export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY [+ OPENAI_BASE_URL]
+uv run python examples/ask_user_form.py
+```
diff --git a/website/versioned_docs/version-0.8/recipes/multi-provider-failover.md b/website/versioned_docs/version-0.8/recipes/multi-provider-failover.md
index bc01a58..2c4d869 100644
--- a/website/versioned_docs/version-0.8/recipes/multi-provider-failover.md
+++ b/website/versioned_docs/version-0.8/recipes/multi-provider-failover.md
@@ -149,7 +149,7 @@ async def main():
api_key=os.environ["OPENAI_API_KEY"],
)
failover = FailoverProvider(
- anthropic.model("claude-sonnet-4-5-20250929"),
+ anthropic.model("claude-sonnet-4-6"),
openai.model("gpt-5"),
)
@@ -157,7 +157,7 @@ async def main():
# placeholder. We use the primary's so usage tracking labels match the
# happy path.
agent = Agent(
- model=failover.model("claude-sonnet-4-5-20250929"),
+ model=failover.model("claude-sonnet-4-6"),
system_prompt="You answer concisely.",
)
agent.subscribe(lambda e, s=None: None)
@@ -256,6 +256,21 @@ for that pattern.
halfway through a long response, the agent sees the error. Full
mid-stream replay would require buffering — out of scope here.
+## Run the example
+
+A self-contained, runnable version of this recipe is in the repository at
+[`examples/multi_provider_failover.py`](https://github.com/cubeplexai/cubepi/blob/main/examples/multi_provider_failover.py).
+It deliberately uses a bad key for the primary provider to trigger failover,
+then answers correctly via the fallback.
+
+```bash
+git clone https://github.com/cubeplexai/cubepi && cd cubepi
+uv sync
+
+export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY [+ OPENAI_BASE_URL]
+uv run python examples/multi_provider_failover.py
+```
+
## See also
- [Providers / Anthropic](../guides/providers/anthropic) and
diff --git a/website/versioned_docs/version-0.8/recipes/persistent-chat.md b/website/versioned_docs/version-0.8/recipes/persistent-chat.md
index b78842f..c828497 100644
--- a/website/versioned_docs/version-0.8/recipes/persistent-chat.md
+++ b/website/versioned_docs/version-0.8/recipes/persistent-chat.md
@@ -28,7 +28,7 @@ async def main(thread_id: str):
async with SQLiteCheckpointer("chat.db") as cp:
agent = Agent(
- model=provider.model("claude-sonnet-4-5-20250929"),
+ model=provider.model("claude-sonnet-4-6"),
system_prompt="You are a concise, friendly assistant.",
checkpointer=cp,
thread_id=thread_id,
@@ -165,6 +165,22 @@ concurrent users — see [Postgres + FastAPI](./postgres-fastapi).
- **`chat.db` in `/tmp`** — Some OSes wipe `/tmp` on reboot. Use
`~/.local/share/myapp/chat.db` or similar for user data.
+## Run the example
+
+A self-contained, runnable version of this recipe is in the repository at
+[`examples/persistent_chat.py`](https://github.com/cubeplexai/cubepi/blob/main/examples/persistent_chat.py).
+
+```bash
+git clone https://github.com/cubeplexai/cubepi && cd cubepi
+uv sync --extra sqlite
+
+export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY [+ OPENAI_BASE_URL]
+uv run python examples/persistent_chat.py alice
+# Ctrl-D to quit, then re-run — history is restored.
+uv run python examples/persistent_chat.py bob
+# Different thread_id → clean slate.
+```
+
## See also
- [Multi-turn Conversations](../guides/agents/multi-turn) — `steer`,
diff --git a/website/versioned_docs/version-0.8/recipes/postgres-fastapi.md b/website/versioned_docs/version-0.8/recipes/postgres-fastapi.md
index cce8650..0eaee6e 100644
--- a/website/versioned_docs/version-0.8/recipes/postgres-fastapi.md
+++ b/website/versioned_docs/version-0.8/recipes/postgres-fastapi.md
@@ -123,7 +123,7 @@ async def post_message(
async def event_generator() -> AsyncIterator[dict]:
agent = Agent(
- model=_provider.model("claude-sonnet-4-5-20250929"),
+ model=_provider.model("claude-sonnet-4-6"),
system_prompt="You are a helpful assistant.",
checkpointer=_checkpointer,
thread_id=thread_id,
@@ -246,6 +246,27 @@ If you need strict ordering, add an application-layer mutex
- **Long requests timing out** — Tool-heavy agents can run minutes.
Set generous proxy timeouts and uvicorn `--timeout-keep-alive 600`.
+## Run the example
+
+A self-contained service template for this recipe is in the repository at
+[`examples/postgres_fastapi.py`](https://github.com/cubeplexai/cubepi/blob/main/examples/postgres_fastapi.py).
+
+```bash
+git clone https://github.com/cubeplexai/cubepi && cd cubepi
+uv sync --extra postgres
+pip install fastapi "uvicorn[standard]" sse-starlette
+
+export DATABASE_URL=postgresql://user:pass@localhost/cubepi
+export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY [+ OPENAI_BASE_URL]
+
+uvicorn examples.postgres_fastapi:app --reload --port 8000
+
+# Test with curl:
+curl -N -X POST http://localhost:8000/chat/conv1/messages \
+ -H "content-type: application/json" \
+ -d '{"text":"hi"}'
+```
+
## See also
- [Postgres Checkpointing](../guides/checkpointing/postgres) — the
diff --git a/website/versioned_docs/version-0.8/recipes/resumable-tasks.md b/website/versioned_docs/version-0.8/recipes/resumable-tasks.md
index 49bb324..1192577 100644
--- a/website/versioned_docs/version-0.8/recipes/resumable-tasks.md
+++ b/website/versioned_docs/version-0.8/recipes/resumable-tasks.md
@@ -101,7 +101,7 @@ from tools import transcode_video # the @tool-decorated AgentTool from above
async def main(thread_id: str, initial_prompt: str | None):
async with SQLiteCheckpointer("jobs.db") as cp:
agent = Agent(
- model=AnthropicProvider(provider_id="anthropic", api_key=os.environ["ANTHROPIC_API_KEY"]).model("claude-sonnet-4-5-20250929"),
+ model=AnthropicProvider(provider_id="anthropic", api_key=os.environ["ANTHROPIC_API_KEY"]).model("claude-sonnet-4-6"),
system_prompt="You orchestrate video transcoding jobs.",
tools=[transcode_video],
checkpointer=cp,
@@ -126,6 +126,12 @@ async def main(thread_id: str, initial_prompt: str | None):
# Resume picks up from the last persisted message:
# ToolResultMessage / UserMessage → re-invokes the model
# AssistantMessage with no queued steer/follow_up → raises
+ last = agent.state.messages[-1]
+ if type(last).__name__ == "AssistantMessage":
+ # Job finished normally before the crash — nothing to resume.
+ # Ask the user for the next prompt instead.
+ print("Last run completed. Nothing to resume.")
+ return
await agent.resume()
@@ -208,6 +214,24 @@ tool args. That's what `transcode_video` above does with `JOB_DIR`.
`signal.is_set()` won't honour `abort`. Drop a check inside any
hot loop.
+## Run the example
+
+A self-contained, runnable version of this recipe is in the repository at
+[`examples/resumable_tasks.py`](https://github.com/cubeplexai/cubepi/blob/main/examples/resumable_tasks.py).
+
+```bash
+git clone https://github.com/cubeplexai/cubepi && cd cubepi
+uv sync --extra sqlite
+
+export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY [+ OPENAI_BASE_URL]
+
+# Start the job (kill mid-flight with Ctrl-C to test recovery):
+uv run python examples/resumable_tasks.py job-1 start
+
+# Resume from where it stopped — already-done items are skipped:
+uv run python examples/resumable_tasks.py job-1
+```
+
## See also
- [Multi-turn → `resume()`](../guides/agents/multi-turn#resume--continue-from-the-last-message)
diff --git a/website/versioned_docs/version-0.8/recipes/sandbox-confirm.md b/website/versioned_docs/version-0.8/recipes/sandbox-confirm.md
index 01cbb3e..9283e5b 100644
--- a/website/versioned_docs/version-0.8/recipes/sandbox-confirm.md
+++ b/website/versioned_docs/version-0.8/recipes/sandbox-confirm.md
@@ -138,3 +138,18 @@ This closes the conversation cleanly: synthetic deny tool_results are
appended for any unresolved tool calls, a terminal
`AssistantMessage(stop_reason="aborted")` is persisted, and
`AgentAbortedEvent` is emitted. The next `agent.prompt(...)` starts fresh.
+
+## Run the example
+
+A self-contained, runnable version of this recipe is in the repository at
+[`examples/sandbox_confirm.py`](https://github.com/cubeplexai/cubepi/blob/main/examples/sandbox_confirm.py).
+It wires up a simulated bash tool and a policy that auto-allows reads, denies
+destructive writes, and auto-approves everything else via the host loop.
+
+```bash
+git clone https://github.com/cubeplexai/cubepi && cd cubepi
+uv sync
+
+export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY [+ OPENAI_BASE_URL]
+uv run python examples/sandbox_confirm.py
+```
diff --git a/website/versioned_docs/version-0.8/recipes/weather-agent.md b/website/versioned_docs/version-0.8/recipes/weather-agent.md
index 46e0344..a293a46 100644
--- a/website/versioned_docs/version-0.8/recipes/weather-agent.md
+++ b/website/versioned_docs/version-0.8/recipes/weather-agent.md
@@ -77,7 +77,7 @@ async def get_weather(
async def main():
provider = AnthropicProvider(provider_id="anthropic", api_key=os.environ["ANTHROPIC_API_KEY"])
agent = Agent(
- model=provider.model("claude-sonnet-4-5-20250929"),
+ model=provider.model("claude-sonnet-4-6"),
system_prompt="You are a concise weather assistant. Always use the tool; don't guess.",
tools=[get_weather],
)
@@ -145,6 +145,19 @@ Tokyo is currently 18°C with a wind speed of 12 km/h. São Paulo is 25°C with
[`SQLiteCheckpointer`](../guides/checkpointing/sqlite) so follow-up
questions ("and in Osaka?") have history.
+## Run the example
+
+A self-contained, runnable version of this recipe is in the repository at
+[`examples/weather_agent.py`](https://github.com/cubeplexai/cubepi/blob/main/examples/weather_agent.py).
+
+```bash
+git clone https://github.com/cubeplexai/cubepi && cd cubepi
+uv sync
+
+export ANTHROPIC_API_KEY=sk-ant-... # or OPENAI_API_KEY [+ OPENAI_BASE_URL]
+uv run python examples/weather_agent.py
+```
+
## See also
- [Building Your First Agent](../guides/agents/first-agent) — the same