Metadata-Version: 2.4
Name: rewind-agent
Version: 0.14.4
Summary: Chrome DevTools for AI agents — record, inspect, fork, replay, diff.
Project-URL: Homepage, https://github.com/agentoptics/rewind
Project-URL: Repository, https://github.com/agentoptics/rewind
Project-URL: Issues, https://github.com/agentoptics/rewind/issues
Project-URL: Changelog, https://github.com/agentoptics/rewind/blob/master/CHANGELOG.md
Author: Rewind Contributors
License-Expression: MIT
Keywords: agents,ai,anthropic,crewai,debugging,langgraph,llm,observability,openai,time-travel
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Provides-Extra: agents
Requires-Dist: openai-agents>=0.0.7; extra == 'agents'
Provides-Extra: all
Requires-Dist: anthropic>=0.18; extra == 'all'
Requires-Dist: openai-agents>=0.0.7; extra == 'all'
Requires-Dist: openai>=1.0; extra == 'all'
Requires-Dist: opentelemetry-api<2,>=1.41.0; extra == 'all'
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.41.0; extra == 'all'
Requires-Dist: opentelemetry-sdk<2,>=1.41.0; extra == 'all'
Requires-Dist: opentelemetry-semantic-conventions>=0.62b0; extra == 'all'
Requires-Dist: pydantic-ai>=1.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.18; extra == 'anthropic'
Provides-Extra: openai
Requires-Dist: openai>=1.0; extra == 'openai'
Provides-Extra: otel
Requires-Dist: opentelemetry-api<2,>=1.41.0; extra == 'otel'
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.41.0; extra == 'otel'
Requires-Dist: opentelemetry-sdk<2,>=1.41.0; extra == 'otel'
Requires-Dist: opentelemetry-semantic-conventions>=0.62b0; extra == 'otel'
Provides-Extra: pydantic
Requires-Dist: pydantic-ai>=1.0; extra == 'pydantic'
Description-Content-Type: text/markdown

# rewind-agent

**Python SDK for [Rewind](https://github.com/agentoptics/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

```bash
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:

```python
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:

```python
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 |

```python
# 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:

```python
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:

```python
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:

```python
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:

```python
@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):

```python
# 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

- [GitHub](https://github.com/agentoptics/rewind)
- [Changelog](https://github.com/agentoptics/rewind/blob/master/CHANGELOG.md)
