Skip to main content
A Claude Agent SDK agent runs on Rebuno with two seams. Model calls go through a Rebuno-aware gateway, which records each one as an llm_call step, and tools are served from an in-process MCP server that calls @tool functions, so every tool call is recorded as a tool_call step. On a re-dispatch the agent runs from the top and recorded steps replay instead of calling the model or the tool again.

Install

Model calls

The SDK runs the Claude Code CLI as a subprocess, and the CLI makes the model calls from its own process, so http_client() can’t be passed in. Instead, point the CLI at a gateway that implements the LLM call contract through its environment, and forward the dispatch in ANTHROPIC_CUSTOM_HEADERS so the gateway can record the call under it:
execution() reads the current dispatch, so build the environment inside the handler. examples/gateway/litellm_proxy.py is a LiteLLM proxy callback that implements the gateway.

Tools

The CLI’s built-in tools, such as Bash and Edit, run inside the CLI where the kernel can’t see them. Turn them off with tools=[], and serve your own tools from an SDK MCP server whose handlers call @tool functions:
The MCP server runs in your process, so the @tool call records against the current execution. Mark anything with a side effect, such as sending an email or creating a ticket, at_most_once. See idempotency.

The agent

setting_sources=[] keeps the CLI from loading settings files from the machine, so the tools and permissions are the ones set here.

What Rebuno adds

  • Policy. Every model and tool call is checked against policy before it runs. A denied tool returns the rule’s reason to the model as the tool result, so the agent can take a different path.
  • Approvals. A tool that requires approval parks the execution. Once it’s approved, the agent is dispatched again, the earlier steps replay, and the approved call runs.
  • Recovery. If the worker dies partway through, the next dispatch replays every completed step and continues from the first one that didn’t finish. Model calls that already ran are not paid for twice.

Full example

examples/frameworks/python/claude_agent_sdk_agent.py is a support agent that investigates a customer issue, creates a ticket, and emails a summary after approval.