Skip to main content

Rebuno Python SDK

Rebuno gives your agents durable execution (crash and resume without re-running side effects), an event-sourced record of everything they did, and optional governance over what they're allowed to do.

Durability works by recording every non-deterministic effect your handler produces, so a resumed run replays the recorded result instead of doing the work again. The SDK gives you three ways to record an effect:

  • @rebuno.tool — mark an async function as a durable tool call
  • rebuno.http_client() — an httpx client that records LLM calls as durable steps (drop it into your OpenAI/Anthropic client)
  • rebuno.step() — record non-deterministic local work (time, randomness, ids) so it replays identically

Installation

pip install rebuno

Building an agent

from rebuno import Agent, tool


@tool
async def search(query: str) -> list[str]:
    return [f"result for {query}"]


async def process(prompt: str) -> dict:
    hits = await search(prompt)
    return {"answer": hits}


agent = Agent("dev-agent", secret="dev-secret", base_url="http://localhost:8080")
agent.run(process, port=5000)

The handler's signature is the input schema: process(prompt: str) makes prompt a required input field. A single pydantic.BaseModel parameter gets validated input; a single input: dict (or input: Any) parameter receives the raw input unchanged.

agent.run(...) binds process and serves the webhook endpoint with uvicorn (this call blocks). The kernel calls that webhook to dispatch each execution; the agent runs process and records every tool call durably, so crashes and pending approvals resume transparently on the next dispatch — your handler code doesn't need to know the difference.

If you want to mount the agent into an existing service, or serve it with your own uvicorn/gunicorn process, use agent.app (a FastAPI app) instead of agent.run(...).

Tools

from rebuno import tool


@tool
async def search(query: str, limit: int = 10) -> list[str]:
    ...

Tools are plain async functions — hand them to your framework as a list:

agent = create_agent(llm, [search, ...])

Use @tool("custom_id") to set an explicit tool id, and @tool(idempotency="at_most_once") for destructive operations that must not be retried automatically (e.g. sending an email or charging a card).

If a tool does blocking or CPU-bound work, offload it so it doesn't block the event loop:

@tool
async def render(doc: str) -> bytes:
    return await asyncio.to_thread(render_sync, doc)

Durable LLM calls

LLM calls are the most expensive and least deterministic thing an agent does, so Rebuno records them too — without you rewriting how you call the model. http_client() returns an httpx.AsyncClient you hand to your provider's async client:

from openai import AsyncOpenAI
import rebuno

llm = AsyncOpenAI(http_client=rebuno.http_client())

It works as an httpx transport that sits under the provider SDK: on the first run it forwards the request to the provider and records the response as a durable step (kind=llm_call, the same machinery as tool calls); on resume it replays the recorded response instead of calling — and paying for — the model again. The request's model field is used as the step target; pass model_field=... if your provider names it differently. Extra kwargs (e.g. timeout) are forwarded to httpx.AsyncClient.

Recording only happens inside an execution — outside one, the client is a plain passthrough. Two current limits: streaming responses (stream=True) are passed through un-recorded (you'll get a warning), and non-JSON request bodies aren't recognized as LLM calls.

Durable local work

Wrap non-deterministic local computation — the current time, random choices, fresh ids — so its result is recorded once and replays identically on resume:

from rebuno import step

chosen = await step("pick_winner", random.choice, args={"candidates": candidates})

Building a client

Clients are used to create executions and inspect what they did. It talks to the kernel's client/admin routes with Bearer auth.

from rebuno import Client

client = Client(base_url="http://localhost:8080", api_key="...")

base_url and api_key fall back to the REBUNO_URL and REBUNO_API_KEY environment variables when omitted; base_url is required one way or the other. Pass timeout= to override the default 35s. Client is an async context manager, so it closes its connection pool for you:

async with Client() as client:
    execution = await client.create("dev-agent", input={"prompt": "hello"})
    ...

Otherwise call await client.close() when you're done.

What you can do with it:

# executions
execution = await client.create("dev-agent", input={"prompt": "hello"})
execution = await client.get(execution.id)
await client.cancel(execution.id)

# what an execution did (event log and steps)
events = await client.events(execution.id, after_seq=0, limit=100)
steps = await client.list_steps(execution.id, status="pending")
step = await client.get_step(execution.id, step_id)

Failed requests raise typed errors (NotFoundError, UnauthorizedError, PolicyError, NetworkError, …) — all subclasses of rebuno.RebunoError.

Human-in-the-loop / approvals

Approvals are inspected and resolved through Client:

pending = await client.list_approvals()
await client.grant_approval(pending[0].id, decided_by="alice")

License

MIT

Metadata

Release files for rebuno 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rebuno 0.6.0
File Size Uploaded Provenance Actions
rebuno-0.6.0.tar.gz 70.9 kB Without provenance Details for rebuno-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rebuno 0.6.0
File Interpreter ABI Platform Actions
rebuno-0.6.0-py3-none-any.whl Python 3 none any Details for rebuno-0.6.0-py3-none-any.whl

Total release size: 95.8 kB

Release files / rebuno-0.6.0.tar.gz

Download URL rebuno-0.6.0.tar.gz
Size 70.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cf7637a01f4f8f747a3cb978c73623c77bc6040203d198448e55410e81ea5409
BLAKE2b-256 checksum
How to use checksums
7195ab0f449367adf6713ae5f59e4fb43e55bf806eee7f1830aab311ad381223
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rebuno-0.6.0-py3-none-any.whl

Download URL rebuno-0.6.0-py3-none-any.whl
Size 24.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc7e00246071e7712ab57eace1c5bd31ff2debda924427d81921ce47534f22ea
BLAKE2b-256 checksum
How to use checksums
d95b7b7f2f7673aceb75445afa6445156994fe0a83e9cfe1044a43b7d4bc4223
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for rebuno 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page