Stepfork
Open-source behavioral regression testing for AI agents.
Record failed AI agent executions locally, replay instrumented dependencies, compare behavior, and export reproducible pytest regression tests.
PyPI · Documentation · CI · Issues
The problem
Unit tests often miss regressions in multi-step agent behavior. A recorded run can show what the agent called and returned, but replaying against live tools or models makes a regression test slow, costly, and nondeterministic.
Stepfork captures instrumented dependency calls in a local trace and replays their recorded responses. You can compare runs and export a pytest test with an explicit expectation for the corrected behavior.
How it works
Wrap the tool and LLM boundaries you want captured. Frozen replay strictly matches those boundaries and substitutes recorded responses, so the wrapped bodies are not run again. Calls outside instrumented boundaries are not intercepted.
- Record a failed or completed run into a local
.sftracebundle. - Inspect the events, integrity metadata, and failure details.
- Replay the entrypoint with instrumented dependencies frozen.
- Diff the recorded behavior against a corrected run.
- Export a pytest regression test with an explicit expectation.
- Test the buggy entrypoint and the fixed entrypoint with pytest.
Features
In v0.3.0
- Record completed and failed runs as local
.sftracebundles. - Inspect and validate traces; check bundle integrity.
- Replay instrumented tool and LLM calls with recorded responses.
- Compare traces and inspect behavior-level differences.
- Report coverage of observed instrumented calls. Calls outside instrumented boundaries are not measured.
- Save named local baselines and gate trace changes in CI (guide, runnable example).
- Export pytest regression tests with output and trajectory expectations.
- Minimize failing traces and fork traces at a selected step.
- Use optional OpenAI Python SDK and LangGraph adapters for supported non-streaming boundaries.
- Capture optional retrieval evidence and per-node context through LangGraph
traced_node,capture_retrieval, andrecord_assembled_context; see RAG evidence. - Best-effort redaction of common credential patterns when recording.
Streaming model calls are not supported by the adapters.
Stepfork is experimental. Redaction is not a guarantee against sensitive-data leaks, integrity hashes are not signatures, and replay is not a sandbox. See security notes.
Installation
Requires Python 3.11, 3.12, or 3.13.
Install the v0.3.0 release from PyPI:
pip install "stepfork==0.3.0"
For a contributor checkout or the latest development changes, install from source:
pip install "git+https://github.com/utsab345/stepfork.git@main"
See the development instructions for contributor setup.
Install an adapter only if needed:
pip install "stepfork[openai]"
pip install "stepfork[langgraph]"
Quick start
Save this as quickstart.py. The example records a shipped order that the
buggy agent fails to notify about.
from stepfork import record, trace_tool
@trace_tool
def order_status(order_id: str) -> dict[str, str]:
return {"order_id": order_id, "status": "shipped"}
def run_agent() -> dict[str, bool]:
order = order_status("ORD-1001")
return {"notify": order["status"] == "delivered"} # Bug: should notify on shipment
if __name__ == "__main__":
with record("order-agent", output="failure.sftrace") as session:
result = run_agent()
session.set_output(result)
print(result)
Run the CLI commands from the directory containing quickstart.py. The CLI
resolves --entrypoint from the current working directory; use PYTHONPATH if
the module lives elsewhere.
python -m pip install pytest
python quickstart.py
stepfork inspect failure.sftrace
stepfork replay failure.sftrace --entrypoint quickstart:run_agent --mode frozen
printf '{"notify": true}\n' > expected.json
stepfork export failure.sftrace \
--entrypoint quickstart:run_agent \
--expect-output expected.json \
--output test_order_regression.py
Change the condition in run_agent to check for "shipped", then run
python -m pytest -q test_order_regression.py. See the
five-minute quickstart for inspect, validate, diff,
and red-green pytest commands.
See the terminal demo.
Integrations
The core API is framework-independent. Optional adapters currently support:
- OpenAI Python SDK: sync and async, non-streaming
chat.completions.create. - LangGraph / LangChain: sync and async non-streaming chat-model generation and wrapped function tools. v0.3.0 also adds optional node and retrieval evidence. Streaming is not supported.
Offline GitHub Actions examples cover frozen replay and named baseline comparisons without provider credentials. Stepfork does not currently provide a reusable GitHub Action or an MCP adapter. See the integration details.
Contributing
Contributions are welcome. Read the contribution guide and development instructions, then open an issue or pull request. Please do not include credentials or unreviewed trace data in issues, tests, or commits.
License
Apache-2.0. See LICENSE.
Metadata
Release files for stepfork 0.3.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 |
|---|---|---|---|---|
| stepfork-0.3.0.tar.gz | 2.5 MB | With provenance | Details for stepfork-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stepfork-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for stepfork-0.3.0-py3-none-any.whl |
Total release size: 2.7 MB
Release files / stepfork-0.3.0.tar.gz
| Download URL | stepfork-0.3.0.tar.gz |
|---|---|
| Size | 2.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
036b02a4755d002b0be2259d7902590dc2cbfd7e3f7d8b782ba3b3ecf3cec2a4
|
|
BLAKE2b-256 checksum How to use checksums |
adb8f76b9968f179a5243a8ab8ec17fbe8efaf66467c8a5c4acab9788490c7fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 29, 2026.
Transparency logRelease files / stepfork-0.3.0-py3-none-any.whl
| Download URL | stepfork-0.3.0-py3-none-any.whl |
|---|---|
| Size | 150.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a546c6fd6423098fa8b10ef8afa7114eb2ecbb8a46fa57b66500044a3a79e05
|
|
BLAKE2b-256 checksum How to use checksums |
ad57ecaae4e43160a0f79cdb9df10d5fd47b87fa0329515df16f599f0295f6d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 29, 2026.
Transparency logSecurity for stepfork 0.3.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 stepfork-0.3.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 Nov 29, 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.