replaygate 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. replaygate-0.1.0/LICENSE +21 -0
  2. replaygate-0.1.0/PKG-INFO +208 -0
  3. replaygate-0.1.0/README.md +180 -0
  4. replaygate-0.1.0/pyproject.toml +48 -0
  5. replaygate-0.1.0/setup.cfg +4 -0
  6. replaygate-0.1.0/src/replaygate/__init__.py +3 -0
  7. replaygate-0.1.0/src/replaygate/_seed.py +16 -0
  8. replaygate-0.1.0/src/replaygate/adapters/__init__.py +1 -0
  9. replaygate-0.1.0/src/replaygate/adapters/crewai.py +74 -0
  10. replaygate-0.1.0/src/replaygate/adapters/langgraph.py +131 -0
  11. replaygate-0.1.0/src/replaygate/adapters/mlflow.py +51 -0
  12. replaygate-0.1.0/src/replaygate/adapters/spans.py +70 -0
  13. replaygate-0.1.0/src/replaygate/attribute/__init__.py +0 -0
  14. replaygate-0.1.0/src/replaygate/attribute/causal.py +27 -0
  15. replaygate-0.1.0/src/replaygate/backends/__init__.py +0 -0
  16. replaygate-0.1.0/src/replaygate/backends/base.py +51 -0
  17. replaygate-0.1.0/src/replaygate/backends/cloud.py +123 -0
  18. replaygate-0.1.0/src/replaygate/backends/fixture.py +48 -0
  19. replaygate-0.1.0/src/replaygate/backends/ollama.py +66 -0
  20. replaygate-0.1.0/src/replaygate/cli.py +220 -0
  21. replaygate-0.1.0/src/replaygate/evaluate/__init__.py +0 -0
  22. replaygate-0.1.0/src/replaygate/evaluate/judge.py +51 -0
  23. replaygate-0.1.0/src/replaygate/evaluate/population.py +42 -0
  24. replaygate-0.1.0/src/replaygate/evaluate/quality.py +40 -0
  25. replaygate-0.1.0/src/replaygate/graph/__init__.py +0 -0
  26. replaygate-0.1.0/src/replaygate/graph/dag.py +35 -0
  27. replaygate-0.1.0/src/replaygate/instrument.py +146 -0
  28. replaygate-0.1.0/src/replaygate/intervene/__init__.py +0 -0
  29. replaygate-0.1.0/src/replaygate/intervene/apply.py +12 -0
  30. replaygate-0.1.0/src/replaygate/models.py +147 -0
  31. replaygate-0.1.0/src/replaygate/replay/__init__.py +0 -0
  32. replaygate-0.1.0/src/replaygate/replay/engine.py +115 -0
  33. replaygate-0.1.0/src/replaygate/replay/validity.py +39 -0
  34. replaygate-0.1.0/src/replaygate/report/__init__.py +0 -0
  35. replaygate-0.1.0/src/replaygate/report/diff.py +125 -0
  36. replaygate-0.1.0/src/replaygate/report/verdict.py +128 -0
  37. replaygate-0.1.0/src/replaygate/soundness/__init__.py +0 -0
  38. replaygate-0.1.0/src/replaygate/soundness/ledger.py +34 -0
  39. replaygate-0.1.0/src/replaygate/store/__init__.py +0 -0
  40. replaygate-0.1.0/src/replaygate/store/db.py +145 -0
  41. replaygate-0.1.0/src/replaygate/store/validate.py +47 -0
  42. replaygate-0.1.0/src/replaygate.egg-info/PKG-INFO +208 -0
  43. replaygate-0.1.0/src/replaygate.egg-info/SOURCES.txt +45 -0
  44. replaygate-0.1.0/src/replaygate.egg-info/dependency_links.txt +1 -0
  45. replaygate-0.1.0/src/replaygate.egg-info/entry_points.txt +2 -0
  46. replaygate-0.1.0/src/replaygate.egg-info/requires.txt +9 -0
  47. replaygate-0.1.0/src/replaygate.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 surajjunni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.4
2
+ Name: replaygate
3
+ Version: 0.1.0
4
+ Summary: Catch quality regressions from prompt and model changes by selectively replaying your agent's real past runs
5
+ Author: surajjunni
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/surajjunni/replaygate
8
+ Project-URL: Repository, https://github.com/surajjunni/replaygate
9
+ Project-URL: Issues, https://github.com/surajjunni/replaygate/issues
10
+ Keywords: llm,agent,regression-testing,prompt-testing,model-swap,llm-evaluation,llmops,ci,selective-replay,langgraph
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development :: Testing
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.12
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: networkx>=3.0
21
+ Requires-Dist: numpy>=1.26
22
+ Provides-Extra: langgraph
23
+ Requires-Dist: langgraph>=0.2; extra == "langgraph"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8.0; extra == "dev"
26
+ Requires-Dist: langgraph>=0.2; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # ReplayGate
30
+
31
+ [![CI](https://github.com/surajjunni/replaygate/actions/workflows/ci.yml/badge.svg)](https://github.com/surajjunni/replaygate/actions/workflows/ci.yml)
32
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
33
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](pyproject.toml)
34
+
35
+ **Did a change to your AI app make it worse? Check before you ship it.**
36
+
37
+ You change a prompt or swap the model behind your AI app to improve it, and your tests pass. But a
38
+ small change can quietly make the answers *worse*, and ordinary tests often miss it because the AI
39
+ doesn't answer the same way every time.
40
+
41
+ **ReplayGate catches it.** You give it the change you're about to make, and it checks that change
42
+ against your app's **real past runs**. Then it tells you one of three things: safe, worse, or not sure.
43
+
44
+ 📝 **Launch post:** [Your agent's prompt change passed CI. Did it actually get *worse*?](https://surajjyothiunni1.substack.com/p/your-agents-prompt-change-passed)
45
+
46
+ ## How it works
47
+
48
+ 1. You record some real runs of your agent (you do this once).
49
+ 2. You make a change: a new prompt, or a new model.
50
+ 3. ReplayGate replays those recorded runs with your change and answers:
51
+ - **PASS** — safe to ship.
52
+ - **FAIL** — it got worse.
53
+ - **NOT SURE** — it won't guess, so it stops the change.
54
+
55
+ It's fast because it only re-runs the steps your change can actually affect.
56
+
57
+ ## Install
58
+
59
+ ```bash
60
+ uv venv && uv pip install -e ".[dev]" # or: pip install -e ".[dev]"
61
+ ```
62
+
63
+ This installs ReplayGate. You need Python 3.12 or newer.
64
+
65
+ ## Try it
66
+
67
+ It's two commands:
68
+
69
+ ```bash
70
+ replaygate ingest trajectories.json
71
+ replaygate diff --workflow support-bot --intervention change.json --backend ollama
72
+ ```
73
+
74
+ Here's what every part means:
75
+
76
+ - **`trajectories.json`** — the recording of your agent's past runs. You make this once (see
77
+ *Record your runs* below). *(A "trajectory" is just one run of the agent from start to finish.)*
78
+ - **`replaygate ingest`** — loads that recording so ReplayGate can use it.
79
+ - **`replaygate diff`** — the main command. It asks: *is this change safe?*
80
+ - **`--workflow support-bot`** — the name of your agent (whatever you called it when recording).
81
+ - **`--intervention change.json`** — a small file that describes the change you want to test (which
82
+ step's prompt or model you're changing, and the new value). Example below.
83
+ - **`--backend ollama`** — which AI actually re-runs the changed steps. `ollama` runs a model on
84
+ your own computer. You can also use `openai` or `anthropic` (put your API key in an environment
85
+ variable; if it's missing, ReplayGate says NOT SURE instead of guessing).
86
+
87
+ You'll get a short report:
88
+
89
+ ```text
90
+ ReplayGate — change risk report [support-bot]
91
+
92
+ ✗ FAIL — quality regresses
93
+ → Don't ship: quality regresses — the 95% CI is entirely past the margin.
94
+
95
+ change: responder
96
+ impact: -0.675 mean quality (95% CI [-0.850, -0.500], margin -0.000) — candidate scores 0.675 lower on average
97
+ cost: selective made 4 model call(s); full re-execution ≈ 12 (saved ~8, 67%)
98
+ reuse: exposure 0.75 — fraction of nodes reused, not a miss probability
99
+ exit: 1 (0 PASS / 1 FAIL / 2 INCONCLUSIVE)
100
+ ```
101
+
102
+ The last line is an **exit code** you can use in automation: `0` safe, `1` worse, `2` not sure.
103
+
104
+ **What `change.json` looks like:**
105
+
106
+ ```json
107
+ {
108
+ "targets": { "responder": { "prompt_id": "respond.v2" } },
109
+ "prompts": { "respond.v2": "Answer in a single short sentence." }
110
+ }
111
+ ```
112
+
113
+ This says: *change the `responder` step's prompt to this new text, and test it.*
114
+
115
+ Other handy options: `--margin` (how big a drop counts as "worse"), `--format markdown` (a version
116
+ you can paste into a GitHub pull request), `--json` (for scripts).
117
+
118
+ ## Record your runs
119
+
120
+ ReplayGate needs a recording of your agent running. You add one small thing: for each step, say
121
+ what it needs. Everything else is recorded for you.
122
+
123
+ ```python
124
+ from replaygate.instrument import InstrumentedAgent
125
+
126
+ agent = InstrumentedAgent("support-bot")
127
+
128
+ # deps=[...] lists what each step needs. "planner" needs the question;
129
+ # "responder" needs the planner's output.
130
+ @agent.node("planner", deps=["question"], prompt_id="plan.v1", prompt="Plan how to answer.")
131
+ def planner(question): ...
132
+
133
+ @agent.node("responder", deps=["planner"], prompt_id="respond.v1", prompt="Answer using the plan.")
134
+ def responder(planner): ...
135
+
136
+ for i, q in enumerate(questions):
137
+ with agent.trajectory(f"t{i}") as run:
138
+ run.set("question", q) # a starting input
139
+ run.run_all() # runs the steps in order and records each one
140
+
141
+ agent.save("trajectories.json") # this is the file you pass to `replaygate ingest`
142
+ ```
143
+
144
+ **Using LangGraph?** You can record straight from your graph, with almost no extra code:
145
+
146
+ ```python
147
+ from replaygate.adapters.langgraph import trace_from_langgraph
148
+
149
+ app = graph.compile()
150
+ trace = trace_from_langgraph(app, inputs=[{"q": q} for q in questions])
151
+ # -> save to JSON for `replaygate ingest`
152
+ ```
153
+
154
+ One honest note for LangGraph: its steps share data, so a recording can miss some links between
155
+ steps. ReplayGate notices, marks that recording "unverified", and will **not** give you a confident
156
+ PASS from it (it says NOT SURE) unless you add `--accept-unverified-deps`. Add the missing links, or
157
+ use the setup above, for a fully checked run. See `examples/langgraph_agent.py`.
158
+
159
+ ## Works with
160
+
161
+ | Framework | How to record | Example |
162
+ |---|---|---|
163
+ | **LangGraph** | `adapters.langgraph.trace_from_langgraph(app, inputs)` | `examples/langgraph_agent.py` |
164
+ | **MLflow Tracing** | `adapters.mlflow.trace_from_mlflow(traces)` | `examples/mlflow_agent.py` |
165
+ | **CrewAI** | `adapters.crewai.trace_from_crewai(tasks, crew.kickoff())` | `examples/crewai_agent.py` |
166
+ | **OpenAI Agents SDK / LlamaIndex / OpenTelemetry** | turn spans into `{name, parent, output}` and call `adapters.spans.trace_from_spans(traces)` | span recipe below |
167
+
168
+ Every example runs with **no framework installed** (stand-ins mirror the real shape), so you can
169
+ see how recording works first, then swap in your real app.
170
+
171
+ ```python
172
+ from replaygate.adapters.spans import trace_from_spans
173
+ # each run is a list of spans; a span is {"name", "parent": <parent name or None>, "output"}
174
+ trace = trace_from_spans([[{"name": "retrieve", "parent": None, "output": docs},
175
+ {"name": "answer", "parent": "retrieve", "output": ans}]])
176
+ ```
177
+
178
+ ## It tells you when it might be wrong
179
+
180
+ ReplayGate is fast because it reuses old results for the steps your change can't touch. That's only
181
+ safe if it knows how the steps connect. If a connection is missing, it could reuse an old result and
182
+ miss a real problem.
183
+
184
+ ReplayGate is upfront about this:
185
+
186
+ - It **measures how often it misses**, on a test with known answers: `replaygate benchmark`.
187
+ - When it isn't sure a step is safe to reuse, it **re-runs the step** instead of guessing.
188
+ - You can always do a **full re-run** with `--mode full`: slower, but always correct.
189
+
190
+ ## Compared to other tools
191
+
192
+ - Some tools replay recorded outputs to catch wiring bugs, but they can't test a prompt or model
193
+ *change* (the recording is the very thing the change would alter). ReplayGate tests the change.
194
+ - Tools like DeepEval and promptfoo compare prompts on hand-written examples. ReplayGate uses your
195
+ real past runs instead.
196
+
197
+ ## What it supports
198
+
199
+ Agents whose steps run in a simple one-way order (no loops), where you've said how the steps
200
+ connect. Loops and hidden-state agents are turned away, not guessed at. The guiding rules are in
201
+ `.specify/memory/constitution.md`.
202
+
203
+ ---
204
+
205
+ **Keywords:** LLM agent regression testing · prompt regression testing · model-swap testing for AI
206
+ agents · LLM evaluation · LLMOps · CI gate for prompt and model changes · selective replay ·
207
+ false-negative rate · LangGraph · MLflow · CrewAI · OpenAI Agents SDK · OpenTelemetry · Ollama ·
208
+ OpenAI · Anthropic · Python.
@@ -0,0 +1,180 @@
1
+ # ReplayGate
2
+
3
+ [![CI](https://github.com/surajjunni/replaygate/actions/workflows/ci.yml/badge.svg)](https://github.com/surajjunni/replaygate/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](pyproject.toml)
6
+
7
+ **Did a change to your AI app make it worse? Check before you ship it.**
8
+
9
+ You change a prompt or swap the model behind your AI app to improve it, and your tests pass. But a
10
+ small change can quietly make the answers *worse*, and ordinary tests often miss it because the AI
11
+ doesn't answer the same way every time.
12
+
13
+ **ReplayGate catches it.** You give it the change you're about to make, and it checks that change
14
+ against your app's **real past runs**. Then it tells you one of three things: safe, worse, or not sure.
15
+
16
+ 📝 **Launch post:** [Your agent's prompt change passed CI. Did it actually get *worse*?](https://surajjyothiunni1.substack.com/p/your-agents-prompt-change-passed)
17
+
18
+ ## How it works
19
+
20
+ 1. You record some real runs of your agent (you do this once).
21
+ 2. You make a change: a new prompt, or a new model.
22
+ 3. ReplayGate replays those recorded runs with your change and answers:
23
+ - **PASS** — safe to ship.
24
+ - **FAIL** — it got worse.
25
+ - **NOT SURE** — it won't guess, so it stops the change.
26
+
27
+ It's fast because it only re-runs the steps your change can actually affect.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ uv venv && uv pip install -e ".[dev]" # or: pip install -e ".[dev]"
33
+ ```
34
+
35
+ This installs ReplayGate. You need Python 3.12 or newer.
36
+
37
+ ## Try it
38
+
39
+ It's two commands:
40
+
41
+ ```bash
42
+ replaygate ingest trajectories.json
43
+ replaygate diff --workflow support-bot --intervention change.json --backend ollama
44
+ ```
45
+
46
+ Here's what every part means:
47
+
48
+ - **`trajectories.json`** — the recording of your agent's past runs. You make this once (see
49
+ *Record your runs* below). *(A "trajectory" is just one run of the agent from start to finish.)*
50
+ - **`replaygate ingest`** — loads that recording so ReplayGate can use it.
51
+ - **`replaygate diff`** — the main command. It asks: *is this change safe?*
52
+ - **`--workflow support-bot`** — the name of your agent (whatever you called it when recording).
53
+ - **`--intervention change.json`** — a small file that describes the change you want to test (which
54
+ step's prompt or model you're changing, and the new value). Example below.
55
+ - **`--backend ollama`** — which AI actually re-runs the changed steps. `ollama` runs a model on
56
+ your own computer. You can also use `openai` or `anthropic` (put your API key in an environment
57
+ variable; if it's missing, ReplayGate says NOT SURE instead of guessing).
58
+
59
+ You'll get a short report:
60
+
61
+ ```text
62
+ ReplayGate — change risk report [support-bot]
63
+
64
+ ✗ FAIL — quality regresses
65
+ → Don't ship: quality regresses — the 95% CI is entirely past the margin.
66
+
67
+ change: responder
68
+ impact: -0.675 mean quality (95% CI [-0.850, -0.500], margin -0.000) — candidate scores 0.675 lower on average
69
+ cost: selective made 4 model call(s); full re-execution ≈ 12 (saved ~8, 67%)
70
+ reuse: exposure 0.75 — fraction of nodes reused, not a miss probability
71
+ exit: 1 (0 PASS / 1 FAIL / 2 INCONCLUSIVE)
72
+ ```
73
+
74
+ The last line is an **exit code** you can use in automation: `0` safe, `1` worse, `2` not sure.
75
+
76
+ **What `change.json` looks like:**
77
+
78
+ ```json
79
+ {
80
+ "targets": { "responder": { "prompt_id": "respond.v2" } },
81
+ "prompts": { "respond.v2": "Answer in a single short sentence." }
82
+ }
83
+ ```
84
+
85
+ This says: *change the `responder` step's prompt to this new text, and test it.*
86
+
87
+ Other handy options: `--margin` (how big a drop counts as "worse"), `--format markdown` (a version
88
+ you can paste into a GitHub pull request), `--json` (for scripts).
89
+
90
+ ## Record your runs
91
+
92
+ ReplayGate needs a recording of your agent running. You add one small thing: for each step, say
93
+ what it needs. Everything else is recorded for you.
94
+
95
+ ```python
96
+ from replaygate.instrument import InstrumentedAgent
97
+
98
+ agent = InstrumentedAgent("support-bot")
99
+
100
+ # deps=[...] lists what each step needs. "planner" needs the question;
101
+ # "responder" needs the planner's output.
102
+ @agent.node("planner", deps=["question"], prompt_id="plan.v1", prompt="Plan how to answer.")
103
+ def planner(question): ...
104
+
105
+ @agent.node("responder", deps=["planner"], prompt_id="respond.v1", prompt="Answer using the plan.")
106
+ def responder(planner): ...
107
+
108
+ for i, q in enumerate(questions):
109
+ with agent.trajectory(f"t{i}") as run:
110
+ run.set("question", q) # a starting input
111
+ run.run_all() # runs the steps in order and records each one
112
+
113
+ agent.save("trajectories.json") # this is the file you pass to `replaygate ingest`
114
+ ```
115
+
116
+ **Using LangGraph?** You can record straight from your graph, with almost no extra code:
117
+
118
+ ```python
119
+ from replaygate.adapters.langgraph import trace_from_langgraph
120
+
121
+ app = graph.compile()
122
+ trace = trace_from_langgraph(app, inputs=[{"q": q} for q in questions])
123
+ # -> save to JSON for `replaygate ingest`
124
+ ```
125
+
126
+ One honest note for LangGraph: its steps share data, so a recording can miss some links between
127
+ steps. ReplayGate notices, marks that recording "unverified", and will **not** give you a confident
128
+ PASS from it (it says NOT SURE) unless you add `--accept-unverified-deps`. Add the missing links, or
129
+ use the setup above, for a fully checked run. See `examples/langgraph_agent.py`.
130
+
131
+ ## Works with
132
+
133
+ | Framework | How to record | Example |
134
+ |---|---|---|
135
+ | **LangGraph** | `adapters.langgraph.trace_from_langgraph(app, inputs)` | `examples/langgraph_agent.py` |
136
+ | **MLflow Tracing** | `adapters.mlflow.trace_from_mlflow(traces)` | `examples/mlflow_agent.py` |
137
+ | **CrewAI** | `adapters.crewai.trace_from_crewai(tasks, crew.kickoff())` | `examples/crewai_agent.py` |
138
+ | **OpenAI Agents SDK / LlamaIndex / OpenTelemetry** | turn spans into `{name, parent, output}` and call `adapters.spans.trace_from_spans(traces)` | span recipe below |
139
+
140
+ Every example runs with **no framework installed** (stand-ins mirror the real shape), so you can
141
+ see how recording works first, then swap in your real app.
142
+
143
+ ```python
144
+ from replaygate.adapters.spans import trace_from_spans
145
+ # each run is a list of spans; a span is {"name", "parent": <parent name or None>, "output"}
146
+ trace = trace_from_spans([[{"name": "retrieve", "parent": None, "output": docs},
147
+ {"name": "answer", "parent": "retrieve", "output": ans}]])
148
+ ```
149
+
150
+ ## It tells you when it might be wrong
151
+
152
+ ReplayGate is fast because it reuses old results for the steps your change can't touch. That's only
153
+ safe if it knows how the steps connect. If a connection is missing, it could reuse an old result and
154
+ miss a real problem.
155
+
156
+ ReplayGate is upfront about this:
157
+
158
+ - It **measures how often it misses**, on a test with known answers: `replaygate benchmark`.
159
+ - When it isn't sure a step is safe to reuse, it **re-runs the step** instead of guessing.
160
+ - You can always do a **full re-run** with `--mode full`: slower, but always correct.
161
+
162
+ ## Compared to other tools
163
+
164
+ - Some tools replay recorded outputs to catch wiring bugs, but they can't test a prompt or model
165
+ *change* (the recording is the very thing the change would alter). ReplayGate tests the change.
166
+ - Tools like DeepEval and promptfoo compare prompts on hand-written examples. ReplayGate uses your
167
+ real past runs instead.
168
+
169
+ ## What it supports
170
+
171
+ Agents whose steps run in a simple one-way order (no loops), where you've said how the steps
172
+ connect. Loops and hidden-state agents are turned away, not guessed at. The guiding rules are in
173
+ `.specify/memory/constitution.md`.
174
+
175
+ ---
176
+
177
+ **Keywords:** LLM agent regression testing · prompt regression testing · model-swap testing for AI
178
+ agents · LLM evaluation · LLMOps · CI gate for prompt and model changes · selective replay ·
179
+ false-negative rate · LangGraph · MLflow · CrewAI · OpenAI Agents SDK · OpenTelemetry · Ollama ·
180
+ OpenAI · Anthropic · Python.
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "replaygate"
7
+ version = "0.1.0"
8
+ description = "Catch quality regressions from prompt and model changes by selectively replaying your agent's real past runs"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "surajjunni" }]
14
+ keywords = [
15
+ "llm", "agent", "regression-testing", "prompt-testing", "model-swap",
16
+ "llm-evaluation", "llmops", "ci", "selective-replay", "langgraph",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Intended Audience :: Developers",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Software Development :: Testing",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+ dependencies = [
27
+ "networkx>=3.0",
28
+ "numpy>=1.26",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/surajjunni/replaygate"
33
+ Repository = "https://github.com/surajjunni/replaygate"
34
+ Issues = "https://github.com/surajjunni/replaygate/issues"
35
+
36
+ [project.optional-dependencies]
37
+ langgraph = ["langgraph>=0.2"]
38
+ dev = ["pytest>=8.0", "langgraph>=0.2"]
39
+
40
+ [project.scripts]
41
+ replaygate = "replaygate.cli:main"
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
45
+
46
+ [tool.pytest.ini_options]
47
+ testpaths = ["tests"]
48
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """ReplayGate — causal regression testing for model/prompt changes in LLM-agent pipelines."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,16 @@
1
+ """Global seeding so benchmarks and bootstrap CIs are reproducible."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import random
6
+
7
+ import numpy as np
8
+
9
+ DEFAULT_SEED = 1729
10
+
11
+
12
+ def seed_all(seed: int = DEFAULT_SEED) -> np.random.Generator:
13
+ """Seed stdlib + numpy and return a dedicated numpy Generator."""
14
+ random.seed(seed)
15
+ np.random.seed(seed)
16
+ return np.random.default_rng(seed)
@@ -0,0 +1 @@
1
+ """Framework adapters that capture ReplayGate traces with minimal user code."""
@@ -0,0 +1,74 @@
1
+ """CrewAI → ReplayGate trace.
2
+
3
+ CrewAI is task-based: a Task may declare `context=[other_task, ...]`, which is an
4
+ EXPLICIT data dependency (unlike control-flow spans), so CrewAI maps unusually
5
+ cleanly — those context links become the declared dependency edges.
6
+
7
+ trace = trace_from_crewai(tasks=[t1, t2, t3], crew_output=crew.kickoff())
8
+
9
+ `tasks` is the ordered list of CrewAI Task objects; `crew_output` is the
10
+ CrewOutput returned by `crew.kickoff()` (its `.tasks_output[i].raw` aligns with
11
+ `tasks[i]`). Produces a single-trajectory trace; call once per run and merge, or
12
+ pass several runs via `extra_runs`. Validated against CrewAI's documented Task/
13
+ CrewOutput shape — confirm against your CrewAI version. DAG-only (task context
14
+ must be acyclic)."""
15
+
16
+ from __future__ import annotations
17
+
18
+ from replaygate.adapters.spans import _as_str, _attr
19
+ from replaygate.replay.validity import fingerprint
20
+
21
+
22
+ def _task_name(task, idx: int) -> str:
23
+ name = _attr(task, "name")
24
+ if name:
25
+ return str(name)
26
+ desc = _attr(task, "description")
27
+ return (str(desc)[:40] if desc else f"task_{idx}")
28
+
29
+
30
+ def _run_outputs(tasks, crew_output) -> dict[str, str]:
31
+ outs = _attr(crew_output, "tasks_output") or []
32
+ result = {}
33
+ for i, task in enumerate(tasks):
34
+ name = _task_name(task, i)
35
+ to = outs[i] if i < len(outs) else None
36
+ result[name] = _as_str(_attr(to, "raw") if to is not None else "")
37
+ return result
38
+
39
+
40
+ def trace_from_crewai(tasks, crew_output, workflow_id: str = "crewai",
41
+ extra_runs=None, model_id: str = "task",
42
+ prompt_id: str = "default") -> dict:
43
+ names = [_task_name(t, i) for i, t in enumerate(tasks)]
44
+ name_set = set(names)
45
+ edges = set()
46
+ for i, t in enumerate(tasks):
47
+ for c in (_attr(t, "context") or []):
48
+ cn = _task_name(c, -1)
49
+ if cn in name_set:
50
+ edges.add((cn, names[i]))
51
+ preds = {n: [s for s, d in edges if d == n] for n in names}
52
+
53
+ runs = [crew_output] + list(extra_runs or [])
54
+ trajectories = []
55
+ for ri, out in enumerate(runs):
56
+ outputs = _run_outputs(tasks, out)
57
+ steps = []
58
+ for i, name in enumerate(names):
59
+ p = {d: outputs[d] for d in preds[name] if d in outputs}
60
+ o = outputs.get(name, "")
61
+ steps.append({
62
+ "step_index": i, "node_name": name,
63
+ "input_fingerprint": fingerprint(name, model_id, prompt_id, p),
64
+ "output": o, "model_id": model_id, "prompt_id": prompt_id,
65
+ "cost": {"tokens": max(1, len(o) // 4), "latency_ms": 0.0},
66
+ })
67
+ trajectories.append({"trajectory_id": f"{workflow_id}-t{ri}", "steps": steps})
68
+
69
+ return {
70
+ "workflow_id": workflow_id,
71
+ "graph": {"nodes": names, "edges": [list(e) for e in sorted(edges)]},
72
+ "prompts": {},
73
+ "trajectories": trajectories,
74
+ }