Skip to main content

runback-sdk (Python)

Capture for Runback — the AI-agent audit/observability platform. First-party capture for the OpenAI and Anthropic clients, LangChain/LangGraph and the OpenAI Agents SDK, plus OpenTelemetry recipes for frameworks that already emit OTel spans.

Install

pip install "runback-sdk[openai]"     # or [anthropic], [langgraph], [openai-agents], [otel]

Configure with the RUNBACK_API_KEY environment variable, or pass api_key= explicitly. A runback.dev key (rb_cloud_…) sends to runback.dev with nothing else set. Any other key (self-hosted rb_live_…) defaults to http://localhost:3000, so a self-hosted deployment's data never leaves its network by accident: set RUNBACK_INGEST_URL (or ingest_url=) to your own origin. Redaction (standard tier) is on by default, in-process, before anything is sent.

To have Runback decide each tool call before it runs (server-side policy enforcement), pass decide= to Collector, for example Collector(run_name="support-bot", decide={"fail_mode": "closed"}), then call run.decide_tool_call(tool, args) before the tool executes.

What is tested

Every row below has a test in tests/capture/ that drives the real, pinned library against a local scripted model provider (no API keys, no network). What each integration sends is then stored through Runback's real ingest path (storeEvents) and checked: the right llm and tool steps, the tokens, redaction of a secret placed in the input, and a stored digest. The pins are in capture-requirements.txt; CI (.github/workflows/capture-matrix.yml) runs them on every push and the newest releases weekly.

Integration Module Tested against
OpenAI client: chat.completions, responses; streaming and not; sync and async runback.openai.wrap_openai openai 2.54.0
Anthropic client: messages.create, messages.stream; sync and async runback.anthropic.wrap_anthropic anthropic 1.12.1
LangChain / LangGraph runback.RunbackCallbackHandler langchain-core 1.6.9, langgraph 1.2.14
OpenAI Agents SDK runback.openai_agents.RunbackTracingProcessor openai-agents 0.20.0
CrewAI, LlamaIndex, Pydantic AI, Google ADK (OTel recipes) the stock OTLP exporter, or runback.otel.RunbackOTLPJsonExporter see below

OpenAI and Anthropic clients

import openai, anthropic
from runback import Collector
from runback.openai import wrap_openai
from runback.anthropic import wrap_anthropic

run = Collector(run_name="support-agent", input=task)
client = wrap_openai(openai.OpenAI(), run)            # or openai.AsyncOpenAI()
# claude = wrap_anthropic(anthropic.Anthropic(), run)  # or anthropic.AsyncAnthropic()
... # your calls, unchanged
run.finish(output=answer)

Captured per model call: messages, system prompt, tool definitions, parameters, response text, tool calls, finish/stop reason, token usage, latency, and errors (recorded, then re-raised). Tool results you send back in the next request become tool steps paired to the model's call id. For OpenAI streams, pass stream_options={"include_usage": True} or the stream carries no token counts. If capture itself fails, your call still returns.

LangChain / LangGraph

from runback import RunbackCallbackHandler

handler = RunbackCallbackHandler(run_name="my-graph")
result = graph.invoke(inputs, config={"callbacks": [handler]})
handler.finish()

Captured: each chat-model call (messages, system prompt, the bound tools, streamed chunk count and time to first token, tokens, latency, metadata.graph_node), each tool call with its full output and the model's call id, and each graph node as a step. Values are kept whole — there is no character or item cap on anything that is JSON. Not captured: routing rationale for conditional edges (why an edge fired, not just which node ran), and checkpoint/interrupt (pause, resume).

OpenAI Agents SDK

from agents import set_trace_processors
from runback.openai_agents import RunbackTracingProcessor

set_trace_processors([RunbackTracingProcessor()])   # replaces the SDK's default exporter

One Runback run per Agents SDK trace. Model calls become llm steps attributed to their agent, function tools become tool steps, and handoffs and guardrails become steps of their own ([handoff] A → B, [guardrail] name: passed|triggered); a tripped guardrail marks the run error. Keyword arguments are passed to each run's Collector. The processor observes only: it cannot block a tool call.

OTel recipes: CrewAI, LlamaIndex, Pydantic AI, Google ADK

These frameworks reach Runback through its OTLP endpoint (/api/otel/v1/traces), which accepts protobuf or JSON, gzipped or not. The stock exporter works at its defaults: set OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://<host>/api/otel/v1/traces and OTEL_EXPORTER_OTLP_TRACES_HEADERS=authorization=Bearer <RUNBACK_API_KEY>. A trace exported in several batches is still one run: the server buffers its spans and writes the run once the trace goes quiet.

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

tp = TracerProvider()
tp.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(tp)

Optional: runback.otel.RunbackOTLPJsonExporter (the otel extra) sends OTLP as JSON and holds each trace until its root span ends, sending it in one request; it reads RUNBACK_API_KEY and RUNBACK_INGEST_URL. The capture tests drive the recipes through it. You need it only against a self-hosted Runback without sql/add_otel_trace_buffer.sql and sql/create_jobs.sql applied, where each request is stored as its own run.

Then instrument the framework. Each line below is the setup the test uses:

Framework Instrumentation Tested against What the stored run is missing today
Pydantic AI Agent.instrument_all(InstrumentationSettings(tracer_provider=tp)) pydantic-ai-slim 2.31.1 —
LlamaIndex OpenInference LlamaIndexInstrumentor().instrument(tracer_provider=tp); pass additional_kwargs={"stream_options": {"include_usage": True}} to the OpenAI LLM or tokens are zero llama-index-core 0.14.25, openinference-instrumentation-llama-index 4.5.4 Two llm steps per model call: one complete, with tokens and tool calls; the duplicate has no tokens or tools, and its response text is the instrumentor's repr of the messages
CrewAI OpenInference CrewAIInstrumentor and OpenAIInstrumentor, both with tracer_provider=tp. Needs crewai ≥ 1.10.1: below it the instrumentor silently records nothing crewai 1.15.26, openinference-instrumentation-crewai 1.1.20 —
Google ADK OpenInference GoogleADKInstrumentor().instrument(tracer_provider=tp). Needs google-adk ≥ 2.10. Without the instrumentor, ADK's own spans make tool calls show up as model calls google-adk 2.11.0, openinference-instrumentation-google-adk 1.0.3 (model via LiteLLM) Provider shows as gcp.vertex.agent, not the model's vendor

In all four, every model call arrives as an llm step with its model id, messages, system prompt, tool definitions, response text, tool calls and tokens, and every tool call as a tool step. The remaining gaps are asserted as current behaviour in packages/sdk/test/capture/pythonFixtures.test.ts, so the tests fail, and are updated, the day the mapping changes.

Redaction on this path happens server-side: spans leave your process unredacted and Runback redacts them before storing. If that is not acceptable, use one of the first-party integrations above, which redact in-process. The same spans exported twice with one key are stored once: the server's trace buffer keeps one copy per span id (without the buffer migration, each request is its own run).

Digest

SDK-captured runs carry a real cassette_digest, computed with the same oracle-chain hashing as the TypeScript SDK and the server, so a digest computed here matches the one ingest computes from the same stored events.

Metadata

Release files for runback-sdk 0.1.1

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

Source distribution (sdist)

Source distribution for runback-sdk 0.1.1
File Size Uploaded Provenance Actions
runback_sdk-0.1.1.tar.gz 246.7 kB With provenance Details for runback_sdk-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for runback-sdk 0.1.1
File Interpreter ABI Platform Actions
runback_sdk-0.1.1-py3-none-any.whl Python 3 none any Details for runback_sdk-0.1.1-py3-none-any.whl

Total release size: 302.1 kB

Release files / runback_sdk-0.1.1.tar.gz

Download URL runback_sdk-0.1.1.tar.gz
Size 246.7 kB
Tags Source
SHA-256 checksum
How to use checksums
330c6d3c45193ff18d19f1858e5af17a947c5bd8fe191b5be1fa798791e20514
BLAKE2b-256 checksum
How to use checksums
de7e429075edf7e85c23bbf1e84dd470ad1af08599d376885e2ff9689fefd2b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / runback_sdk-0.1.1-py3-none-any.whl

Download URL runback_sdk-0.1.1-py3-none-any.whl
Size 55.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1730cf6c8846e103e5ffa7729e8648aaf0c418f6a7145655d188892b1f39a6a0
BLAKE2b-256 checksum
How to use checksums
3e383150b1e92991efcc4d8701f7c6b49cea1e3fc73e65d022399ec675a7096c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for runback-sdk 0.1.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for runback_sdk-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

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.1.1 This release

2 release files Full 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