Hi everyone!
I’ve been working on Stepfork, an open-source Python tool for recording AI agent executions, replaying failures offline, and generating pytest regression tests.
One challenge I’ve encountered while building LLM applications is reproducing failures consistently.
An agent might call an LLM, execute several tools, and combine the results using Python application logic. When something goes wrong, rerunning the agent can produce different model responses or tool outputs.
I wanted a way to freeze the instrumented dependencies while continuing to test the actual application logic.
What I built
Stepfork provides:
-
Recording of supported LLM and tool interactions into
.sftracebundles -
Frozen replay without additional model requests or execution of instrumented tool bodies
-
Strict detection of changes in tool-call order and arguments
-
Pytest regression-test generation with developer-defined expectations
-
Integrations for supported OpenAI and LangGraph workflows
Testing with a real Gemini model
I recently tested Stepfork with Gemini 2.5 Flash using a synthetic incident-triage agent.
The model correctly classified a critical checkout incident as P0. However, an intentionally introduced Python postprocessing bug changed the final result to P1 and disabled escalation.
I recorded the execution and generated a pytest regression test.
The results:
-
14 recorded trace events
-
5 instrumented tool calls and 1 real LLM call
-
The generated regression test failed with the buggy application
-
The same test passed after fixing the application logic
-
Frozen replay required zero additional LLM requests
The full experiment, including the recorded trace and offline tests, is reproducible without a Gemini API key.
Limitations
Stepfork is still an early alpha. Frozen replay only substitutes instrumented dependencies, not arbitrary side effects. It isn’t a sandbox, and developers must define their own expected outcomes.
I’d appreciate feedback
I’m particularly interested in how developers using Hugging Face models, Transformers, and agent frameworks approach reproducible testing.
Do you rely on mocks, recorded traces, live-model evaluations, or some combination?
Would a tool that turns recorded agent executions into pytest regression tests fit your workflow?
Documentation: Stepfork
Real Gemini case study: stepfork/examples/real-llm-case-study at main · utsab345/stepfork · GitHub
I’d appreciate feedback on the approach, especially which model providers and agent frameworks would be most useful to support next.