Metadata-Version: 2.4
Name: powerailabs-cassette
Version: 0.5.0
Summary: Test: record an agent run once, replay it forever — deterministic, offline, free. The vcrpy of the agent era.
Author: Raghav Mishra
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Requires-Python: >=3.11
Requires-Dist: powerailabs-core<0.2,>=0.1.9
Description-Content-Type: text/markdown

# powerailabs-cassette

Record an agent run once; replay it forever — deterministic, offline, and free. Unlike `vcrpy`
(HTTP-only), it captures the *whole* run: every LLM call and tool call, in order.

**Agent tests that run in 0.2s with no API key.**

![PyPI](https://img.shields.io/pypi/v/powerailabs-cassette) ![license](https://img.shields.io/badge/license-Apache_2.0-blue) · `pip install powerailabs-cassette`

```python
from powerailabs.core import instrument
from powerailabs import cassette

client = instrument(OpenAI())          # the same instrumented seam used in production

@cassette.use("triage_happy_path.json")   # record first run, replay after (auto mode)
def test_triage():
    result = my_agent.run("My card was charged twice")
    assert "refund" in result.tools_called
    assert cassette.semantic_match(result.answer, "offers a refund")
```

**Wrap-around, test-time only.** Records via core's bus, replays via a core interceptor keyed on a
normalized request hash — no second patch, no network. Secrets/PII are redacted in what's written,
but matching hashes the **un-redacted** request, so redaction never collapses two distinct calls
(tune it with `redact=True|False|callable`). Modes: `auto` / `record` / `replay` / **`rerecord`**
(run live, report `drift()` without overwriting). `promote()` turns a production trace into a
replayable cassette. Both matching seams are pluggable: `use(normalizer=...)` and
`semantic_match(scorer=...)` — the default `semantic_match` is recall-oriented (lexical), so bring
your own embeddings / LLM judge for negation-sensitive checks.

See [`docs/cassette.md`](https://github.com/PowerAI-Labs/powerailabs/blob/main/docs/cassette.md) · [CHANGELOG](https://github.com/PowerAI-Labs/powerailabs/blob/main/packages/powerailabs-cassette/CHANGELOG.md). *Part of the PowerAI Labs stack — [github.com/PowerAI-Labs/powerailabs](https://github.com/PowerAI-Labs/powerailabs). Apache-2.0; provided "as is", without warranty — use at your own risk (LICENSE §7–8).*
