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
runback-sdk is not on PyPI. Install it from a checkout of this repository:
pip install -e "packages/sdk-python[langgraph]" # or [openai], [anthropic], [openai-agents], [otel]
Configure with the RUNBACK_API_KEY / RUNBACK_INGEST_URL environment variables, or pass api_key= / ingest_url= explicitly. Redaction (standard tier) is on by default, in-process, before anything is sent.
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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| runback_sdk-0.1.0.tar.gz | 246.6 kB | With provenance | Details for runback_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| runback_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for runback_sdk-0.1.0-py3-none-any.whl |
Total release size: 301.7 kB
Release files / runback_sdk-0.1.0.tar.gz
| Download URL | runback_sdk-0.1.0.tar.gz |
|---|---|
| Size | 246.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
672d95502b0ea83baeada2c70539b418b3f79f046d0948f2eb3a3523cfaaaf16
|
|
BLAKE2b-256 checksum How to use checksums |
1c0935a72194b57ca5268435ff43f40347ed283702c5d0927f6a5277f4e54046
|
| 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 logRelease files / runback_sdk-0.1.0-py3-none-any.whl
| Download URL | runback_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 55.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5cbcf7288b45c6936b782c5f1502274616ef344f6d59f38b6efb6ed9e16c14c
|
|
BLAKE2b-256 checksum How to use checksums |
97b0e6c408100cbd39962f24aa19016634f9492ea1f59686078af04b062305d3
|
| 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 logSecurity for runback-sdk 0.1.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for runback_sdk-0.1.0.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 logA 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.