rewind-agent
Python SDK for Rewind — the time-travel debugger for AI agents.
Record every LLM call. See the exact context window. Fork, fix, replay from failure — without re-running.
Install
pip install rewind-agent
This installs both the Python SDK and the rewind CLI. The native binary is auto-downloaded on first use.
Quick Start
One line to start recording — no proxy, no setup:
import rewind_agent
import openai
rewind_agent.init() # patches OpenAI + Anthropic automatically
client = openai.OpenAI()
client.chat.completions.create(model="gpt-4o", messages=[...])
# Recorded to ~/.rewind/ — inspect with: rewind show latest
Or as a scoped session:
with rewind_agent.session("my-agent"):
client = openai.OpenAI()
client.chat.completions.create(model="gpt-4o", messages=[...])
Two Recording Modes
| Direct mode (default) | Proxy mode | |
|---|---|---|
| Setup | rewind_agent.init() |
rewind record in a second terminal |
| How | Monkey-patches SDK clients in-process | HTTP proxy intercepts LLM traffic |
| Best for | Python agents, quick iteration | Any language, polyglot teams |
# Direct mode (default — no proxy needed)
rewind_agent.init(mode="direct")
# Proxy mode (requires `rewind record` running)
rewind_agent.init(mode="proxy", proxy_url="http://127.0.0.1:8443")
Replay from Failure
Agent failed at step 5? Fix your code, then replay — steps 1-4 are cached (instant, free), step 5 re-runs live:
with rewind_agent.replay("latest", from_step=4):
result = my_agent.run("Research Tokyo population")
# Steps 1-4: instant cached responses (0ms, 0 tokens)
# Step 5+: live LLM calls, recorded to a new forked timeline
After the replay, diff the timelines: rewind diff <session> main replayed
Regression Testing
Turn any session into a baseline. After code changes, check for regressions:
from rewind_agent import Assertions
# Check the latest session against a known-good baseline
result = Assertions().check("booking-happy-path", "latest")
assert result.passed, f"Regression: {result.failed_checks} checks failed"
Checks step types, models, tool calls, error status, and token usage. Supports configurable tolerance:
result = Assertions().check("my-baseline", "latest", token_tolerance=0.15)
print(f"Passed: {result.passed_checks}/{result.total_checks}")
Agent Hooks
Enrich recordings with semantic labels:
@rewind_agent.step("search")
def search(query: str) -> str:
return client.chat.completions.create(...)
@rewind_agent.tool("calculator")
def calculate(a: float, b: float) -> float:
return a + b
with rewind_agent.trace("analysis"):
rewind_agent.annotate("confidence", 0.92)
result = search("Tokyo population")
Framework Support
Native (auto-detected on init()): OpenAI Agents SDK, Pydantic AI — zero config.
Wrapper (manual setup):
# LangGraph
graph = rewind_agent.wrap_langgraph(compiled_graph)
# CrewAI
crew = rewind_agent.wrap_crew(crew)
Any other framework works via the HTTP proxy — point OPENAI_BASE_URL at rewind record.
Learn More
Metadata
Release files for rewind-agent 0.17.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rewind_agent-0.17.1.tar.gz | 114.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rewind_agent-0.17.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 252.8 kB
Release files / rewind_agent-0.17.1.tar.gz
| Download URL | rewind_agent-0.17.1.tar.gz |
|---|---|
| Size | 114.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d20b6a5a9014b07842e7760fada8dc91a438cb8f753acf7fd55f74b8ed55ff07
|
|
BLAKE2b-256 checksum How to use checksums |
34c9a5f798b5c8fd7c439ed188353ca774a884d8d11c2716c133ca2f0faf7e7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / rewind_agent-0.17.1-py3-none-any.whl
| Download URL | rewind_agent-0.17.1-py3-none-any.whl |
|---|---|
| Size | 137.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8f0d5c427fcfd3601355189cc8713b5392132608c67ad3cd7ec4b48e6be4011
|
|
BLAKE2b-256 checksum How to use checksums |
73e3321e50f2e8c980fde9610e044a49dd527abd69ccf9c748136e7368794208
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|