◀◀ rewyn

Rewyn

Build. Run. Replay. Improve AI.

Agents fail in ways tests do not catch. They worked yesterday, they answer differently today, and the run that proves it is gone.

Rewyn is a flight recorder for AI agents. Every run is recorded locally, so a failure you cannot reproduce can be replayed exactly — offline, with no provider call — then diffed against a working run and turned into a regression test.

Keep the framework you already use. It does not need to know Rewyn exists.

$ pip install rewyn View source ↗
Apache‑2.0 Python 3.11–3.14 Works with your framework No account, no API key
run run_01M2SG0RJYWGRPGA77KAEM6D40 succeeded
Events17
Model calls3
Tool calls2
Cost$0.000085
    17/17
    The problem

    A passing test suite says nothing about what your agent did in production.

    The failure modes that matter are the ones a unit test cannot express, because they depend on a model, a prompt, a retrieved document and a tool result that all existed at one moment and were never written down.

    It changed and nobody knows why

    A provider ships a new checkpoint, a prompt gets edited, a retrieved document changes upstream. The behaviour moves and your diff is empty.

    You cannot reproduce it

    The bug report is a screenshot. The run is gone, the context that produced it is gone, and running it again gives you a different answer.

    Fixing one thing breaks another

    You improve the prompt for one case and silently regress nine others, with no suite that would have caught it.

    How it works

    Four things you do with a run

    Recording is not a mode you switch on for debugging — it is how a run executes, whether the agent is yours or someone else’s. Everything below reads the .rewyn/ directory your normal runs already wrote.

    01Record

    Start where you are.

    You already have an agent. Keep it. instrument wraps any callable so each invocation becomes a recorded run. Your framework does not need to know Rewyn exists, and Rewyn does not import it.

    That records the boundary — input, output, duration, failure, and the version of what ran. Rewyn sees the edges of a foreign agent, not its internals, and does not pretend otherwise.

    You are building one. Then every primitive is recorded and the detail is complete: swap the model string for "openai:gpt-5" and nothing else changes.

    Keep your stack
    from rewyn.integrations.frameworks import instrument
    
    # A LangChain, LlamaIndex, CrewAI or plain-SDK agent.
    agent = instrument(langgraph_app.invoke,
                       framework="langgraph", version="3")
    
    answer = agent(question)   # now a recorded run
    Or build it in Rewyn
    from rewyn import Agent, tool
    
    @tool(risk_level="low")
    def ev_market_share(region: str) -> dict[str, float]:
        """EV share of new car sales, by region."""
        return {"region": {"europe": 24.5}.get(region.lower(), 0.0)}
    
    agent = Agent(model="anthropic:claude-opus-5",
                  tools=[ev_market_share])
    result = agent.run("Compare EV adoption in Europe and China")
    02Inspect

    Read back exactly what happened.

    Every event in order, with its timing, its payload and the version of every dependency the run touched — which agent, which model, which tool, at which version. Cost is attributed per call, not just totalled.

    $ rewyn inspect run_01M2SG0R…
    run       run_01M2SG0RJYWGRPGA77KAEM6D40
    name      ev-researcher
    status    succeeded
    usage     27 in / 29 out tokens, 3 model calls, 2 tool calls
    cost      0.000085 USD
    
    dependencies
      - agent: ev-researcher (v1)
      - model: anthropic:claude-opus-5
      - tool:  ev_market_share (v1)
    
    events
       1 RUN_STARTED            input: Compare EV adoption…
       2 AGENT_LOOP_STARTED     strategy: react
       3 MODEL_CALLED           
       5 TOOL_CALLED            ev_market_share(region="europe")
       6 TOOL_RETURNED          {"region": 24.5}
    03Replay

    Run it again without calling the provider.

    Replay reconstructs the run from its recording: the recorded responses are served back in order, so you can step through a production failure on a plane, with no key and no spend.

    It tells you whether the reconstruction was faithful, rather than quietly diverging — and diffing a replay against a live run is how you see what a provider changed underneath you.

    $ rewyn replay run_01M2SG0R…
    replay    run_01M2SFSB5BAMW6HZPMCWJJ6XH4
    of        run_01M2SG0RJYWGRPGA77KAEM6D40
    mode      reconstruct
    model     recorded   tools recorded
    identical True   faithful True
    swapped   5 recorded response(s)
    04Improve

    Turn the production run into a regression test.

    The run that broke becomes a case in a dataset. Change the prompt, the model or the tool, re-run the set, and get a report of what moved — with the old behaviour on record to compare against.

    This is the loop the whole SDK exists for: the incident you fixed last month cannot come back without a test failing.

    from rewyn.evaluation.dataset import Dataset
    from rewyn.evaluation.metrics import exact_match
    from rewyn.evaluation.regression import run_regression
    
    # A production run becomes a regression case.
    dataset = Dataset(name="critical")
    dataset.add_run(result.run_id)
    
    report = run_regression(dataset, agent,
                            evaluators=[exact_match()])
    print(report.render())
    The console

    An execution debugger for your own runs

    rewyn ui opens a local console on the .rewyn/ you already have. No account, no upload, no network.

    Timeline

    Everything the agent did, in order, with timing and payloads — the run expanded rather than summarised.

    Execution graph

    The shape of the run: loops, branches, subagents and handoffs as a graph you can walk.

    Context inspector

    Which item entered the prompt, from where, at which version, and how much of the budget it spent.

    Compare

    Two runs side by side, down to the event — what changed, and at which step it diverged.

    Drift

    Behaviour moving over time against a recorded manifest, so a provider change surfaces as a signal.

    Same screens, hosted

    The optional cloud serves the identical console over a team’s runs. The SDK is complete without it.

    Design rules

    What the SDK guarantees

    Everything is an event

    Model calls, retrieval, memory, tools, MCP, skills, loops, handoffs, checkpoints, approvals and guardrails all emit structured events. That is what makes replay and diff possible at all.

    Provider agnostic

    No module outside the provider adapter imports a provider SDK or assumes its message format. Provider-specific features are an explicit provider_options={} escape hatch, never hidden.

    Local first

    pip install rewyn is fully usable with no account, no cloud and no Rewyn key. State lives in .rewyn/ and stays on your machine.

    Never breaks the host app

    Telemetry is async, batched, buffered and fails open. If the recording layer throws, your agent keeps running.

    Secrets never persist

    Keys, tokens and private keys are redacted before anything is written or uploaded. Untrusted context cannot override trusted policy.

    Versioned for provenance

    Prompts, skills, tools, agents, graphs, context and datasets are versioned, so a historical run can be reconstructed exactly — not approximately.

    Install

    Core is provider agnostic. Add only what you use.

    $ pip install rewyn
    
    # see it work, offline, in a minute
    $ rewyn quickstart
    $ rewyn runs
    $ rewyn inspect <run-id>
    $ rewyn replay  <run-id>

    The CLI also carries diff, eval, test, datasets, manifest, drift, export and doctor.

    rewyn[anthropic]Anthropic adapter
    rewyn[openai]OpenAI adapter
    rewyn[google]Google Gemini adapter
    rewyn[mcp]Model Context Protocol client and server
    rewyn[ui]The local console
    rewyn[redis]Shared memory and checkpoints
    rewyn[s3]S3-compatible object storage
    rewyn[search]Elasticsearch / OpenSearch retrieval
    rewyn[all]Everything