agent-trajectory-diff 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.5
2
+ Name: agent-trajectory-diff
3
+ Version: 0.1.0
4
+ Summary: A developer-first package to evaluate and find regressions in agent trajectories
5
+ Project-URL: Homepage, https://github.com/lostmartian/agentdiff
6
+ Project-URL: Repository, https://github.com/lostmartian/agentdiff
7
+ Author-email: Sahil Gangurde <sahilgangurde08@gmail.com>
8
+ License: Apache-2.0 OR MIT
9
+ License-File: LICENSE
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: networkx>=3.0
16
+ Requires-Dist: pydantic>=2.0
17
+ Requires-Dist: rich>=13.0
18
+ Requires-Dist: typer>=0.9
19
+ Description-Content-Type: text/markdown
20
+
21
+ # AgentDiff
22
+
23
+ [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](LICENSE)
24
+ [![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
25
+
26
+ **AgentDiff** is a developer-first Python library and CLI designed to solve the hardest problem in agent engineering: **regression testing multi-turn, tool-using AI agents by comparing execution paths (trajectories) head-to-head.**
27
+
28
+ ## What AgentDiff Is
29
+
30
+ * **A Trajectory Diff Engine:** Compares Run A (Baseline) against Run B (Candidate) across their execution Directed Acyclic Graphs (DAGs).
31
+ * **A Local-First CI/CD Gate:** Runs locally in your terminal or inside `pytest` and GitHub Actions, raising errors or exit codes on regression violations.
32
+ * **A Universal Comparator:** Ingests telemetry run files from **DeepEval**, OpenInference/OTel, Langfuse, or raw/custom JSON.
33
+
34
+ ## Installation
35
+
36
+ Install via pip:
37
+ ```bash
38
+ pip install agentdiff
39
+ ```
40
+
41
+ Or using `uv`:
42
+ ```bash
43
+ uv add agentdiff
44
+ ```
45
+
46
+ ## Quickstart
47
+
48
+ ### 1. CLI Usage
49
+
50
+ Compare two trajectory JSON traces from your terminal:
51
+ ```bash
52
+ agentdiff diff baseline_run.json candidate_run.json --fail-on-regression --max-divergence 0.25
53
+ ```
54
+
55
+ Options:
56
+ - `--adapter`: Telemetry parser to use (`auto`, `generic`, `deepeval`, `openinference`, `langfuse`).
57
+ - `--format`: Format for the output (`terminal`, `json`, `markdown`).
58
+ - `--fail-on-regression`: Return exit code `1` if thresholds are violated.
59
+ - `--max-loops`: Maximum loops allowed.
60
+ - `--max-divergence`: Maximum Trajectory Divergence Index (TDI) allowed.
61
+ - `--max-cost-delta`: Maximum cost increase percentage allowed.
62
+
63
+ ### 2. Python SDK & Pytest Integration
64
+
65
+ Catch agent loop regressions or token cost spikes in your test suites:
66
+
67
+ ```python
68
+ import pytest
69
+ from agentdiff import load_trace, compare
70
+ from agentdiff.testing import assert_no_regressions
71
+
72
+ def test_agent_refactor_efficiency():
73
+ # Load traces from disk (auto-detects formats like DeepEval)
74
+ baseline = load_trace("tests/traces/baseline.json")
75
+ candidate = load_trace("tests/traces/candidate.json")
76
+
77
+ # Run the comparison
78
+ report = compare(baseline, candidate)
79
+
80
+ # Expressive assertion helper that raises detailed error messages on regression
81
+ assert_no_regressions(
82
+ report,
83
+ max_divergence=0.25, # TDI threshold [0.0 - 1.0]
84
+ max_cost_increase_pct=5.0, # Max cost increase allowed
85
+ allow_loops=False, # Reject if tool loops are detected
86
+ max_wasted_effort=0.10 # Max Wasted Effort Index (WEI) allowed
87
+ )
88
+ ```
89
+
90
+ ## Core Metrics
91
+
92
+ | Metric | Target / Range | Algorithmic Definition |
93
+ | --- | --- | --- |
94
+ | **Trajectory Divergence Index (TDI)** | `0.0` (Identical) to `1.0` (Divergent) | $$1.0 - \frac{2 \times \vert{}\text{LCS}(\text{Steps}_A, \text{Steps}_B)\vert{}}{\vert{}\text{Steps}_A\vert{} + \vert{}\text{Steps}_B\vert{}}$$ |
95
+ | **Wasted Effort Index (WEI)** | `0.0` (Optimal) to `1.0` (Total Waste) | $$\frac{\text{Count}(\text{Steps with status} \in \{\text{ERROR, RETRY, ABANDONED}\})}{\text{Total Execution Steps}}$$ |
96
+ | **Loop Buster Index (LBI)** | Integer ($\ge 0$) | Detects consecutive repeating sequences of tools with stagnant state changes. |
97
+ | **Resource Deltas ($\Delta\text{Res}$)** | Percentage ($\pm\%$) | Standard deltas for $\Delta\text{Tokens}$, $\Delta\text{Cost}$, and $\Delta\text{Latency}$. |
98
+
99
+ ## Development & Operations
100
+
101
+ This project utilizes `uv` to manage environments and dependencies. Automation tasks are defined in the **[`Makefile`](file:///Users/lostmartian/Desktop/interview/agentdiff/Makefile)**:
102
+
103
+ - `make lint` / `make format`: Run Ruff linter checks and formatter.
104
+ - `make test`: Run pytest suite (including style & formatting assertions).
105
+ - `make build`: Package the library into source and wheel distributions in `dist/`.
106
+ - `make website-dev`: Start the Next.js landing and documentation site local server.
107
+ - `make website-build`: Build the Next.js static output in `website/out/`.
108
+
109
+ ### Repository Layout
110
+ - `src/`: Python source code package modules.
111
+ - `tests/`: Quality assurance unit tests.
112
+ - `website/`: Next.js web application and documentation pages.
@@ -0,0 +1,30 @@
1
+ agentdiff/__init__.py,sha256=0d3OUOWD9xwXV-k5cwHZLxp72AE1We5L0lUwnNy8WV0,806
2
+ agentdiff/__main__.py,sha256=wERtgHjw9RwcjnkFniQX3n3fDaxvB3pkIvQBaWLQW_Y,70
3
+ agentdiff/cli.py,sha256=qXZwAG7n2pWXRsGYTGjL38mHTJMHb9OaiQkHcce5-Rw,3943
4
+ agentdiff/loader.py,sha256=sP2dEhSXYCxyYPCK4_Sj3t3AIG9bezZ22T4PWhvooHw,2397
5
+ agentdiff/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ agentdiff/adapters/__init__.py,sha256=wMgseGPcrqZQiHDCkNW4YTTmIOhKNr0mTeZGn475C3E,410
7
+ agentdiff/adapters/base.py,sha256=mUCJsPvWqahLBVcoi2EyRXoJBfnjwF_ViHr0pBeqX3c,592
8
+ agentdiff/adapters/deepeval.py,sha256=klH0dEZPLOsObeRe0gR1R_Oq9_wB6fbApQzY0qxYFQM,4955
9
+ agentdiff/adapters/generic.py,sha256=jGtOoSmriu2O-j8Xp5IcsQv7X4Hx-o-zynPykh1Pb50,360
10
+ agentdiff/adapters/langfuse.py,sha256=a4JQkvZH3hASq8MS5piH0XTs5-yTnzRaslwOhv2XGQc,5499
11
+ agentdiff/adapters/openinference.py,sha256=kJmh7Bv0fniFlOFyRbD-vCihTjuh7MHGFX_HfiQkgP0,7640
12
+ agentdiff/engine/__init__.py,sha256=XekhvPZ2egXkMiflC3ksiW-fVQHvGs2mzUnlR_m2rTs,419
13
+ agentdiff/engine/aligner.py,sha256=E21gUwWfeY4VWzDFrU-6BCDc3nNYjMnsDCOJDg2qLAg,4841
14
+ agentdiff/engine/comparator.py,sha256=qd5aIYYgJueyu7fQT3dQF3taJvacjElCBoxoh2wYJuA,2211
15
+ agentdiff/engine/loop_detector.py,sha256=YE1mglbvTDSsehQn3D_KIjVvjBTC8mWDVsPGz1OcDkE,3641
16
+ agentdiff/engine/metrics.py,sha256=vnnkbjbZThu541a_od8z3BjeWI9txt6jTxrMWTb2iTU,1195
17
+ agentdiff/models/__init__.py,sha256=y6BF8dYbQegRGThiXmKYtK_dHx55uMUG1ZYw7A-r4CA,355
18
+ agentdiff/models/report.py,sha256=0xdbV7ysf6dYjlclGghwzCbs6nPeAE7IKTfx1w2Xe18,2725
19
+ agentdiff/models/step.py,sha256=_A7HC7kZFOk4oXiyWuy2nJ0EBdTKNtHhqicX4ag7e5Y,1018
20
+ agentdiff/models/trace.py,sha256=vmUKe0CZCCPucIrS_jbWofFaLyZ4mjaizvI7HNaQm00,1027
21
+ agentdiff/reporters/__init__.py,sha256=YwtvOQc6Ve5h4bt5tF9UILtzXyU2vRqWcO8eKwC7VrY,173
22
+ agentdiff/reporters/markdown.py,sha256=PFxH5vvpQ5pYGlYUo6m0qxaDL9H2S5xD2IP0EZ_rpHA,3069
23
+ agentdiff/reporters/terminal.py,sha256=_oAXSpfJVjRPXxrUGTZGQLbqsPQqn3Ggho5eajSfkXw,3970
24
+ agentdiff/testing/__init__.py,sha256=6p1gTQZQ5FRms1xaxz0p_1ux_Mh1g6xOHSloYecvIno,107
25
+ agentdiff/testing/assertions.py,sha256=VU18k3tFsv-MDL-6flAeUXjXJv8cddPuMf9pm9NCmLI,1683
26
+ agent_trajectory_diff-0.1.0.dist-info/METADATA,sha256=SsnSoI9ntP8fu1K1Oy9tOBJ7h-0PPQvD-CeXXDpLng4,4903
27
+ agent_trajectory_diff-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
28
+ agent_trajectory_diff-0.1.0.dist-info/entry_points.txt,sha256=luBTTNObngXBLmRV9tAIh_60187ZdDQzJoafiGdxauw,49
29
+ agent_trajectory_diff-0.1.0.dist-info/licenses/LICENSE,sha256=12M7e1w-moSeyf8kDiSSOpywWMfmjsZGqnmfE8tvguk,32488
30
+ agent_trajectory_diff-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agentdiff = agentdiff.cli:main