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 defineTool tools, 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 rebunoFetch 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 defineTool tools:
The MCP server runs in your process, so the defineTool 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.

Stopping on approval

When a tool is held for approval, it throws. The CLI passes a tool error back to the model and keeps retrying the model call, and every retry is refused. Abort the run on the first tool error instead: catch it in the MCP handler, abort the AbortController passed as abortController, and rethrow halt.signal.reason from around the loop so the original error reaches the handler boundary. The agent below does this.

The agent

settingSources: [] 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/typescript/claude_agent_sdk_agent.ts is a support agent that investigates a customer issue, creates a ticket, and emails a summary after approval.