Skip to content

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

docs(recipes): add 'Run the example' section linking to examples/

xf gong190bbc7646df
diff --git a/website/docs/recipes/ask-user-form.md b/website/docs/recipes/ask-user-form.md
index 2da7bbf..58fd089 100644
--- a/website/docs/recipes/ask-user-form.md
+++ b/website/docs/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/docs/recipes/multi-provider-failover.md b/website/docs/recipes/multi-provider-failover.md
index 711d7d5..2c4d869 100644
--- a/website/docs/recipes/multi-provider-failover.md
+++ b/website/docs/recipes/multi-provider-failover.md
@@ -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/docs/recipes/persistent-chat.md b/website/docs/recipes/persistent-chat.md
index ff8d82f..c828497 100644
--- a/website/docs/recipes/persistent-chat.md
+++ b/website/docs/recipes/persistent-chat.md
@@ -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/docs/recipes/postgres-fastapi.md b/website/docs/recipes/postgres-fastapi.md
index d2cf30f..0eaee6e 100644
--- a/website/docs/recipes/postgres-fastapi.md
+++ b/website/docs/recipes/postgres-fastapi.md
@@ -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/docs/recipes/resumable-tasks.md b/website/docs/recipes/resumable-tasks.md
index 95bce3e..d9deb4f 100644
--- a/website/docs/recipes/resumable-tasks.md
+++ b/website/docs/recipes/resumable-tasks.md
@@ -208,6 +208,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/docs/recipes/sandbox-confirm.md b/website/docs/recipes/sandbox-confirm.md
index 01cbb3e..9283e5b 100644
--- a/website/docs/recipes/sandbox-confirm.md
+++ b/website/docs/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/docs/recipes/weather-agent.md b/website/docs/recipes/weather-agent.md
index 6daa214..a293a46 100644
--- a/website/docs/recipes/weather-agent.md
+++ b/website/docs/recipes/weather-agent.md
@@ -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