agent-tracedown-server 0.3.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.
- agent_tracedown_server-0.3.0.dist-info/METADATA +67 -0
- agent_tracedown_server-0.3.0.dist-info/RECORD +40 -0
- agent_tracedown_server-0.3.0.dist-info/WHEEL +5 -0
- agent_tracedown_server-0.3.0.dist-info/entry_points.txt +4 -0
- agent_tracedown_server-0.3.0.dist-info/licenses/LICENSE +202 -0
- agent_tracedown_server-0.3.0.dist-info/top_level.txt +1 -0
- tracedown_server/__init__.py +2 -0
- tracedown_server/__main__.py +47 -0
- tracedown_server/analytics.py +222 -0
- tracedown_server/api/__init__.py +668 -0
- tracedown_server/api/views.py +91 -0
- tracedown_server/cache.py +260 -0
- tracedown_server/claims/__init__.py +327 -0
- tracedown_server/drift/__init__.py +330 -0
- tracedown_server/enterprise/__init__.py +57 -0
- tracedown_server/enterprise/audit.py +99 -0
- tracedown_server/enterprise/clickhouse.py +285 -0
- tracedown_server/enterprise/pii.py +168 -0
- tracedown_server/enterprise/queue.py +275 -0
- tracedown_server/enterprise/rbac.py +251 -0
- tracedown_server/enterprise/sso.py +164 -0
- tracedown_server/importers/__init__.py +6 -0
- tracedown_server/importers/cli.py +140 -0
- tracedown_server/importers/common.py +225 -0
- tracedown_server/importers/langfuse.py +222 -0
- tracedown_server/importers/otel.py +282 -0
- tracedown_server/incidents/__init__.py +249 -0
- tracedown_server/incidents/hooks.py +264 -0
- tracedown_server/otlp.py +81 -0
- tracedown_server/pipeline.py +166 -0
- tracedown_server/pricing.py +340 -0
- tracedown_server/rca/__init__.py +6 -0
- tracedown_server/rca/detectors.py +413 -0
- tracedown_server/rca/engine.py +284 -0
- tracedown_server/rca/fault.py +169 -0
- tracedown_server/rca/judge.py +157 -0
- tracedown_server/replay/__init__.py +90 -0
- tracedown_server/static/index.html +427 -0
- tracedown_server/storage/__init__.py +294 -0
- tracedown_server/storage/postgres.py +517 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-tracedown-server
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Tracedown server and CLI: root-cause analysis for AI agent runs, importers for Langfuse and OpenTelemetry, replay planning and a web viewer.
|
|
5
|
+
Author: Naveen Nair
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/nbn07/agent-tracedown
|
|
8
|
+
Project-URL: Source, https://github.com/nbn07/agent-tracedown
|
|
9
|
+
Project-URL: Issues, https://github.com/nbn07/agent-tracedown/issues
|
|
10
|
+
Keywords: ai-agents,llm,observability,debugging,root-cause-analysis,opentelemetry,tracing,langfuse
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: System :: Monitoring
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: agent-tracedown<0.4,>=0.3.0
|
|
22
|
+
Requires-Dist: fastapi>=0.110
|
|
23
|
+
Requires-Dist: uvicorn>=0.29
|
|
24
|
+
Requires-Dist: pydantic>=2
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
27
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
28
|
+
Requires-Dist: chdb>=2; extra == "dev"
|
|
29
|
+
Requires-Dist: pyjwt[crypto]>=2.8; extra == "dev"
|
|
30
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "dev"
|
|
31
|
+
Requires-Dist: psycopg-pool>=3.2; extra == "dev"
|
|
32
|
+
Requires-Dist: redis>=5; extra == "dev"
|
|
33
|
+
Provides-Extra: sso
|
|
34
|
+
Requires-Dist: pyjwt[crypto]>=2.8; extra == "sso"
|
|
35
|
+
Provides-Extra: postgres
|
|
36
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
|
|
37
|
+
Requires-Dist: psycopg-pool>=3.2; extra == "postgres"
|
|
38
|
+
Provides-Extra: redis
|
|
39
|
+
Requires-Dist: redis>=5; extra == "redis"
|
|
40
|
+
Provides-Extra: clickhouse
|
|
41
|
+
Provides-Extra: kafka
|
|
42
|
+
Requires-Dist: confluent-kafka>=2.3; extra == "kafka"
|
|
43
|
+
Provides-Extra: enterprise
|
|
44
|
+
Requires-Dist: pyjwt[crypto]>=2.8; extra == "enterprise"
|
|
45
|
+
Requires-Dist: confluent-kafka>=2.3; extra == "enterprise"
|
|
46
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "enterprise"
|
|
47
|
+
Requires-Dist: psycopg-pool>=3.2; extra == "enterprise"
|
|
48
|
+
Requires-Dist: redis>=5; extra == "enterprise"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# agent-tracedown-server
|
|
52
|
+
|
|
53
|
+
The analysis side of [Tracedown](https://github.com/nbn07/agent-tracedown), the flight recorder for AI agents:
|
|
54
|
+
|
|
55
|
+
- **Root-cause analysis.** AI stack traces that name the step that caused a failure, with an optional LLM judge.
|
|
56
|
+
- **A "who is at fault" verdict** for every failed run: the agent, the user, or nobody yet.
|
|
57
|
+
- **`tracedown-import`.** Diagnose runs you already record in Langfuse, Arize Phoenix or any OpenTelemetry exporter, with no code changes.
|
|
58
|
+
- **`tracedown-server`.** Ingest API, web viewer, incidents, drift reports, analytics and replay diffs.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install agent-tracedown-server
|
|
62
|
+
tracedown-import langfuse --errors-since 24h # uses LANGFUSE_PUBLIC_KEY / LANGFUSE_SECRET_KEY
|
|
63
|
+
tracedown-import otlp traces.json --failed
|
|
64
|
+
tracedown-server --db tracedown.db # http://localhost:7070
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Benchmarks, including the cases where Tracedown loses to simple baselines, are in the [repository](https://github.com/nbn07/agent-tracedown#how-well-does-it-work). Licensed under Apache-2.0.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
agent_tracedown_server-0.3.0.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
2
|
+
tracedown_server/__init__.py,sha256=KAb9rBSUUpJRSEK8Ufl0JT-6Nw_ScnL6d1L0QqStmpA,46
|
|
3
|
+
tracedown_server/__main__.py,sha256=sow1hZbMzp1uHUPkhCuh4WmFO6VJDY8su3oFUFytOhs,2359
|
|
4
|
+
tracedown_server/analytics.py,sha256=HVdNl2NmgYKpVwx2GQmWHJgnVgziUFdzig41diqJ-6M,11129
|
|
5
|
+
tracedown_server/cache.py,sha256=ycaV4_gYQACatZ8rEVz7L9xh7q9f3ISYzkHEAKRMI_g,11355
|
|
6
|
+
tracedown_server/otlp.py,sha256=mtZY_7dxY6zoLWkSCDK6Wzof_O1Ws832bYlmRh2OwNQ,3757
|
|
7
|
+
tracedown_server/pipeline.py,sha256=eXPBPozIiDNwcK8nKjlLoC_XUKZaWxXSVrEu5a-h5ck,7866
|
|
8
|
+
tracedown_server/pricing.py,sha256=SuajeBx56WTPP2uyoPcOQaIDGXK9W19Zs-AgxwLVrNQ,16634
|
|
9
|
+
tracedown_server/api/__init__.py,sha256=JibMOrtPxJ1A48o1eZDb8-EjJelYlqhOIzJVLoXNwQs,33397
|
|
10
|
+
tracedown_server/api/views.py,sha256=B9OIbcbO3WM5252UAkNy43hGFdIDOco2-pdVuvOi9f8,4407
|
|
11
|
+
tracedown_server/claims/__init__.py,sha256=hFcf9PLY7lkCEsUonK--s-TUGYd27DE9aW4GTU5Vjt8,15252
|
|
12
|
+
tracedown_server/drift/__init__.py,sha256=azul5u2laHHNSkaoTXH8RRWrPcgrj3VY8A73yqTaeGU,15975
|
|
13
|
+
tracedown_server/enterprise/__init__.py,sha256=_NbSijRAhxSI-jgRMJttfAxkAbWBTML6lWadMzVbufU,2310
|
|
14
|
+
tracedown_server/enterprise/audit.py,sha256=XcKLLLflgqlOItry_iUlaWlCCngb2TzoFw2pUnjDQrM,4538
|
|
15
|
+
tracedown_server/enterprise/clickhouse.py,sha256=FLRUQdLrBrGDK5fg8_u3bhQq_r7Rh_67HsDrjSIo-eU,13517
|
|
16
|
+
tracedown_server/enterprise/pii.py,sha256=EJr_mm7Ne6O7FHPc8RXIpYDmLIvMGnyUn2y8D_9HN98,7173
|
|
17
|
+
tracedown_server/enterprise/queue.py,sha256=9f2QhAXjLsrH147pmF4B1Op7SO6ybCoGYGo65C9pLig,12497
|
|
18
|
+
tracedown_server/enterprise/rbac.py,sha256=QtOgGXCDV7tTylq2Rzz_0EPXCCuXZlZqQvKpUFKI85o,11949
|
|
19
|
+
tracedown_server/enterprise/sso.py,sha256=neBIMYNe0zB-0UK86G9mVZtsdM1lCtcn-n-tq1_WboQ,8443
|
|
20
|
+
tracedown_server/importers/__init__.py,sha256=MGzl8wjMfzlXFFyWc2B9FAxRoBIoc7U1L0ycHaFsx3I,276
|
|
21
|
+
tracedown_server/importers/cli.py,sha256=cyrNqs4oRIEFGsJzu8eFCOMTFrxhSXMq5WxsnsbYD6E,6676
|
|
22
|
+
tracedown_server/importers/common.py,sha256=7RrUer1kHjimGluRYdi6AuZVXkKbjFYvOiKZUb0df3Q,9766
|
|
23
|
+
tracedown_server/importers/langfuse.py,sha256=-xjMxIExm7VzkKk7m_0d4OfNfVaJVSpAgKhXheuKlE8,11358
|
|
24
|
+
tracedown_server/importers/otel.py,sha256=Rfvjf0eWjV3zIttPW0HKmP-JCNRlozb0BRjoF1UbBAE,13747
|
|
25
|
+
tracedown_server/incidents/__init__.py,sha256=EAf7RjEmXEm7cJIiiZ-RpXNc3LqsYT1Cx29WoNjVj0U,12454
|
|
26
|
+
tracedown_server/incidents/hooks.py,sha256=gD7dlOl3RL5dMhTLIMzNebDg5jw1g_EPdpoVJEKlXI8,12467
|
|
27
|
+
tracedown_server/rca/__init__.py,sha256=k86-9vIqdpUbK6LQ6TOpSdHlgpwJEB_qOTjIAmDPz2I,370
|
|
28
|
+
tracedown_server/rca/detectors.py,sha256=_7G10EGrgM0pp71INlkxPsNb2cz0Hpj_Y9OQSI6psV8,20350
|
|
29
|
+
tracedown_server/rca/engine.py,sha256=mor5mPUvgxWKcT8II912HiCQMHIdCPVu-oeMK7lDXg0,14319
|
|
30
|
+
tracedown_server/rca/fault.py,sha256=7I4RK9F3U-703bCjqb33d_B1Nruov22Fo7rqXSmisic,9000
|
|
31
|
+
tracedown_server/rca/judge.py,sha256=KwuFVU73bAlZ-A87jqS2D8QcGn2u6nhJUv_wUMLThDM,7243
|
|
32
|
+
tracedown_server/replay/__init__.py,sha256=av5UEIVJNV-VrxgxdoR4GY-u-lIINzzx8ZK0NsIZbv4,4199
|
|
33
|
+
tracedown_server/static/index.html,sha256=mQ6ueigxtdOgGNQM4lRpioynx1FAER9YRXDlHIU_fCQ,35683
|
|
34
|
+
tracedown_server/storage/__init__.py,sha256=fPJNMztIqhdq86LJXXsm3PdKR0eRoddimNpT7JsrxP0,13719
|
|
35
|
+
tracedown_server/storage/postgres.py,sha256=Y37J5ImEx7WqrMfZeU2gSCFFC6d6KXJ-M26d0I0pFfg,23359
|
|
36
|
+
agent_tracedown_server-0.3.0.dist-info/METADATA,sha256=iAuuDvcK9lnoAR1PQhBmnaWLhVTk6A4Lg0Znbsx4hYc,3208
|
|
37
|
+
agent_tracedown_server-0.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
38
|
+
agent_tracedown_server-0.3.0.dist-info/entry_points.txt,sha256=B9LeAn421uFAKY1sciQqidbi-AL0Dd7-TxFog5TJphY,181
|
|
39
|
+
agent_tracedown_server-0.3.0.dist-info/top_level.txt,sha256=o97qBD5naLup63kOZtm3FEExDvp7pzxx0T0XPwnCTNM,17
|
|
40
|
+
agent_tracedown_server-0.3.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tracedown_server
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""``python -m tracedown_server`` / ``tracedown-server``.
|
|
2
|
+
|
|
3
|
+
Dev profile: one process, SQLite (``--db``). Production profile: ``--database-url`` (Postgres),
|
|
4
|
+
``--redis-url`` (shared cache and live feed) and ``--workers N``; any number of replicas behind
|
|
5
|
+
a load balancer then behave as one server.
|
|
6
|
+
"""
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main() -> None:
|
|
12
|
+
p = argparse.ArgumentParser(prog="tracedown-server", description="Tracedown server")
|
|
13
|
+
p.add_argument("--host", default=os.environ.get("TDN_HOST", "127.0.0.1"))
|
|
14
|
+
p.add_argument("--port", type=int, default=int(os.environ.get("TDN_PORT", "7070")))
|
|
15
|
+
p.add_argument("--db", default=os.environ.get("TDN_DB", "agent_tracedown.db"),
|
|
16
|
+
help="SQLite file (dev profile); ':memory:' for ephemeral")
|
|
17
|
+
p.add_argument("--database-url", default=os.environ.get("TDN_DATABASE_URL"),
|
|
18
|
+
help="postgresql://user:pass@host:5432/db (production metadata store)")
|
|
19
|
+
p.add_argument("--redis-url", default=os.environ.get("TDN_REDIS_URL"),
|
|
20
|
+
help="redis://host:6379/0 (shared cache, live feed and rate limits across replicas)")
|
|
21
|
+
p.add_argument("--workers", type=int, default=int(os.environ.get("TDN_WORKERS", "1")),
|
|
22
|
+
help="server processes; more than 1 needs --database-url and --redis-url")
|
|
23
|
+
args = p.parse_args()
|
|
24
|
+
os.environ["TDN_DB"] = args.db
|
|
25
|
+
if args.database_url:
|
|
26
|
+
os.environ["TDN_DATABASE_URL"] = args.database_url
|
|
27
|
+
if args.redis_url:
|
|
28
|
+
os.environ["TDN_REDIS_URL"] = args.redis_url
|
|
29
|
+
if args.workers > 1 and not (args.database_url and args.redis_url):
|
|
30
|
+
p.error("--workers > 1 needs --database-url (Postgres) and --redis-url: SQLite and the in-process "
|
|
31
|
+
"live feed are per process")
|
|
32
|
+
|
|
33
|
+
import uvicorn
|
|
34
|
+
|
|
35
|
+
store = "Postgres" if args.database_url else f"SQLite {args.db}"
|
|
36
|
+
extra = ", Redis" if args.redis_url else ""
|
|
37
|
+
print(f"Tracedown listening on http://{args.host}:{args.port} ({store}{extra}, {args.workers} worker(s))")
|
|
38
|
+
if args.workers > 1:
|
|
39
|
+
uvicorn.run("tracedown_server.api:create_app", factory=True, host=args.host, port=args.port,
|
|
40
|
+
workers=args.workers, log_level="warning")
|
|
41
|
+
else:
|
|
42
|
+
from .api import create_app
|
|
43
|
+
uvicorn.run(create_app(), host=args.host, port=args.port, log_level="warning")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
main()
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"""Agent performance analytics and Prometheus metrics.
|
|
2
|
+
|
|
3
|
+
Computed from run profiles (written by the pipeline when a run finishes) and the
|
|
4
|
+
span table:
|
|
5
|
+
|
|
6
|
+
* success and failure rate, latency p50/p95, steps per run;
|
|
7
|
+
* tokens and cost per task (and per *successful* task);
|
|
8
|
+
* hallucination rate and response quality (share of answer claims that sources support);
|
|
9
|
+
* tool reliability: calls, error rate, latency per tool;
|
|
10
|
+
* retrieval effectiveness: empty and low-score rates, stale-chunk rate, and how often a
|
|
11
|
+
retrieval actually reached the final answer;
|
|
12
|
+
* user feedback score when the SDK reports one (``run.feedback(score)``);
|
|
13
|
+
* daily time series.
|
|
14
|
+
|
|
15
|
+
Cost: see ``pricing``. A reported ``tdn.llm.cost_usd`` wins; otherwise tokens × the
|
|
16
|
+
built-in price table for current Anthropic, OpenAI and Google models, overridden by
|
|
17
|
+
``TDN_PRICES`` and ``PUT /api/v1/settings/prices``. Runs that used a model with no known
|
|
18
|
+
price report their cost as unknown rather than zero.
|
|
19
|
+
"""
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import json
|
|
23
|
+
import os
|
|
24
|
+
import time
|
|
25
|
+
from collections import Counter, defaultdict
|
|
26
|
+
from typing import Any, Dict, List, Optional
|
|
27
|
+
|
|
28
|
+
from . import pricing
|
|
29
|
+
|
|
30
|
+
SCHEMA = """
|
|
31
|
+
CREATE TABLE IF NOT EXISTS settings (
|
|
32
|
+
key TEXT PRIMARY KEY,
|
|
33
|
+
value TEXT NOT NULL
|
|
34
|
+
);
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def user_prices(store) -> Dict[str, Dict[str, Any]]:
|
|
39
|
+
"""Prices saved through the API (they override the built-in table and ``TDN_PRICES``)."""
|
|
40
|
+
try:
|
|
41
|
+
rows = store.query("SELECT value FROM settings WHERE key='prices'")
|
|
42
|
+
except Exception: # noqa: BLE001 - a bare store without the settings table
|
|
43
|
+
return {}
|
|
44
|
+
return json.loads(rows[0]["value"]) if rows else {}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_prices(store) -> Dict[str, Dict[str, Any]]:
|
|
48
|
+
"""Effective price table: built-in, then ``TDN_PRICES``, then saved prices."""
|
|
49
|
+
return pricing.merged(user_prices(store))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def set_prices(store, prices: Dict[str, Dict[str, Any]]) -> Dict[str, Dict[str, Any]]:
|
|
53
|
+
"""Save price overrides (merged over the built-in table; an empty object clears them)."""
|
|
54
|
+
pricing.validate(prices)
|
|
55
|
+
store.execute("INSERT INTO settings(key, value) VALUES ('prices', ?) "
|
|
56
|
+
"ON CONFLICT(key) DO UPDATE SET value=excluded.value", (json.dumps(prices),))
|
|
57
|
+
return prices
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _price_for(prices: Dict[str, Dict[str, Any]], model: Optional[str]) -> Optional[Dict[str, Any]]:
|
|
61
|
+
return pricing.price_for(prices, model)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def run_cost(profile: Dict[str, Any], prices: Dict[str, Dict[str, Any]],
|
|
65
|
+
at_ns: Optional[int] = None) -> Optional[float]:
|
|
66
|
+
"""Cost of a run in USD, or None when any model call in it has no known price."""
|
|
67
|
+
c = pricing.run_cost_from_profile(profile, prices, at_ns)
|
|
68
|
+
return c["cost_usd"] if c["cost_complete"] else None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _pct(xs: List[float], q: float) -> Optional[float]:
|
|
72
|
+
if not xs:
|
|
73
|
+
return None
|
|
74
|
+
xs = sorted(xs)
|
|
75
|
+
k = (len(xs) - 1) * q
|
|
76
|
+
lo, hi = int(k), min(int(k) + 1, len(xs) - 1)
|
|
77
|
+
return round(xs[lo] + (xs[hi] - xs[lo]) * (k - lo), 2)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def overview(store, project: Optional[str] = None, agent: Optional[str] = None,
|
|
81
|
+
days: int = 7) -> Dict[str, Any]:
|
|
82
|
+
since = time.time_ns() - days * 86400 * 10 ** 9
|
|
83
|
+
runs = store.run_profiles(agent=agent, project=project, since_ns=since)
|
|
84
|
+
prices = get_prices(store)
|
|
85
|
+
|
|
86
|
+
by_agent: Dict[str, List[Dict[str, Any]]] = defaultdict(list)
|
|
87
|
+
for r in runs:
|
|
88
|
+
by_agent[r["agent_name"]].append(r)
|
|
89
|
+
|
|
90
|
+
def summarize(rs: List[Dict[str, Any]]) -> Dict[str, Any]:
|
|
91
|
+
f = [r["profile"]["features"] for r in rs]
|
|
92
|
+
n = len(f)
|
|
93
|
+
ok = sum(x["outcome"] == "success" for x in f)
|
|
94
|
+
costs = [run_cost(r["profile"], prices, r["started_at"]) for r in rs]
|
|
95
|
+
known = [c for c in costs if c is not None]
|
|
96
|
+
answered = [x["claims"] for x in f if x.get("claims") and x["claims"]["claims"] > 0
|
|
97
|
+
and x["claims"]["evidence_units"] > 1]
|
|
98
|
+
halluc = sum(1 for c in answered if c["unsupported"] + c["contradicted"] > 0)
|
|
99
|
+
quality = [c["supported"] / c["claims"] for c in answered]
|
|
100
|
+
fb = [x["feedback"] for x in f if isinstance(x.get("feedback"), (int, float))]
|
|
101
|
+
return {
|
|
102
|
+
"runs": n, "successes": ok, "failures": n - ok,
|
|
103
|
+
"success_rate": round(ok / n, 4) if n else None,
|
|
104
|
+
"failure_rate": round(1 - ok / n, 4) if n else None,
|
|
105
|
+
"latency_ms": {"p50": _pct([x["duration_ms"] for x in f], 0.5), "p95": _pct([x["duration_ms"] for x in f], 0.95)},
|
|
106
|
+
"steps_per_run": round(sum(x["steps"] for x in f) / n, 2) if n else None,
|
|
107
|
+
"tokens": {"total": sum(x["tokens"] for x in f), "per_run": round(sum(x["tokens"] for x in f) / n, 1) if n else None},
|
|
108
|
+
"cost_usd": {
|
|
109
|
+
"total": round(sum(known), 6) if known else None,
|
|
110
|
+
"per_task": round(sum(known) / len(known), 6) if known else None,
|
|
111
|
+
"per_successful_task": round(sum(known) / ok, 6) if known and ok and len(known) == n else None,
|
|
112
|
+
"runs_without_price": n - len(known),
|
|
113
|
+
},
|
|
114
|
+
"hallucination_rate": round(halluc / len(answered), 4) if answered else None,
|
|
115
|
+
"response_quality": round(sum(quality) / len(quality), 4) if quality else None,
|
|
116
|
+
"feedback_score": round(sum(fb) / len(fb), 3) if fb else None,
|
|
117
|
+
"top_root_causes": Counter(x["root_cause"] for x in f if x.get("root_cause")).most_common(5),
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# Retrieval effectiveness, per retriever source.
|
|
121
|
+
retr: Dict[str, Dict[str, Any]] = defaultdict(lambda: {"queries": 0, "empty": 0, "low_score": 0,
|
|
122
|
+
"stale_hits": 0, "used": 0, "used_known": 0, "scores": []})
|
|
123
|
+
for r in runs:
|
|
124
|
+
for x in r["profile"]["features"].get("retrieval", []):
|
|
125
|
+
e = retr[x["source"]]
|
|
126
|
+
e["queries"] += 1
|
|
127
|
+
e["empty"] += x["chunks"] == 0
|
|
128
|
+
if isinstance(x.get("max_score"), (int, float)):
|
|
129
|
+
e["scores"].append(x["max_score"])
|
|
130
|
+
e["low_score"] += x["max_score"] < 0.5
|
|
131
|
+
e["stale_hits"] += x["stale"] > 0
|
|
132
|
+
if x.get("used") is not None:
|
|
133
|
+
e["used_known"] += 1
|
|
134
|
+
e["used"] += bool(x["used"])
|
|
135
|
+
retrieval = [{
|
|
136
|
+
"source": src, "queries": e["queries"],
|
|
137
|
+
"empty_rate": round(e["empty"] / e["queries"], 4), "low_score_rate": round(e["low_score"] / e["queries"], 4),
|
|
138
|
+
"stale_rate": round(e["stale_hits"] / e["queries"], 4),
|
|
139
|
+
"avg_max_score": round(sum(e["scores"]) / len(e["scores"]), 3) if e["scores"] else None,
|
|
140
|
+
"reached_answer_rate": round(e["used"] / e["used_known"], 4) if e["used_known"] else None,
|
|
141
|
+
} for src, e in sorted(retr.items())]
|
|
142
|
+
|
|
143
|
+
daily: Dict[str, Dict[str, Any]] = defaultdict(lambda: {"runs": 0, "failures": 0, "cost_usd": 0.0,
|
|
144
|
+
"cost_by_agent": defaultdict(float)})
|
|
145
|
+
for r in runs:
|
|
146
|
+
day = time.strftime("%Y-%m-%d", time.gmtime(r["started_at"] / 1e9))
|
|
147
|
+
d = daily[day]
|
|
148
|
+
d["runs"] += 1
|
|
149
|
+
d["failures"] += r["profile"]["features"]["outcome"] == "failure"
|
|
150
|
+
# priced steps count even when another step in the run has no price
|
|
151
|
+
c = pricing.run_cost_from_profile(r["profile"], prices, r["started_at"])["cost_usd"] or 0
|
|
152
|
+
d["cost_usd"] = round(d["cost_usd"] + c, 6)
|
|
153
|
+
d["cost_by_agent"][r["agent_name"]] += c
|
|
154
|
+
for d in daily.values():
|
|
155
|
+
d["cost_by_agent"] = {a: round(v, 6) for a, v in sorted(d["cost_by_agent"].items())}
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
"window_days": days, "project": project, "agent": agent,
|
|
159
|
+
"overall": summarize(runs),
|
|
160
|
+
"agents": {a: summarize(rs) for a, rs in sorted(by_agent.items())},
|
|
161
|
+
"tools": store.tool_stats(project, since),
|
|
162
|
+
"retrieval": retrieval,
|
|
163
|
+
"daily": [{"day": k, **v} for k, v in sorted(daily.items())],
|
|
164
|
+
"models": pricing.by_model(runs, prices),
|
|
165
|
+
"prices_configured": sorted(prices),
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# ----------------------------------------------------------------------------- Prometheus
|
|
170
|
+
|
|
171
|
+
def _esc(v: Any) -> str:
|
|
172
|
+
return str(v).replace("\\", "\\\\").replace('"', '\\"').replace("\n", " ")
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def prometheus(store, project: Optional[str] = None) -> str:
|
|
176
|
+
"""Prometheus text exposition (cumulative over retained data)."""
|
|
177
|
+
runs = store.run_profiles(project=project)
|
|
178
|
+
prices = get_prices(store)
|
|
179
|
+
lines: List[str] = []
|
|
180
|
+
|
|
181
|
+
def metric(name, kind, help_, samples):
|
|
182
|
+
lines.append(f"# HELP {name} {help_}")
|
|
183
|
+
lines.append(f"# TYPE {name} {kind}")
|
|
184
|
+
for labels, value in samples:
|
|
185
|
+
lab = ",".join(f'{k}="{_esc(v)}"' for k, v in labels.items())
|
|
186
|
+
lines.append(f"{name}{{{lab}}} {value}" if lab else f"{name} {value}")
|
|
187
|
+
|
|
188
|
+
c_runs, c_tok, c_cost, c_hall, c_rc = Counter(), Counter(), Counter(), Counter(), Counter()
|
|
189
|
+
for r in runs:
|
|
190
|
+
f = r["profile"]["features"]
|
|
191
|
+
c_runs[(r["project"], r["agent_name"], f["outcome"])] += 1
|
|
192
|
+
for call in f.get("llm", []):
|
|
193
|
+
c_tok[(call.get("model") or "unknown", "input")] += call["input_tokens"]
|
|
194
|
+
c_tok[(call.get("model") or "unknown", "output")] += call["output_tokens"]
|
|
195
|
+
usd, _ = pricing.call_cost(call, prices, call.get("at_ns") or r.get("started_at"))
|
|
196
|
+
if usd is not None:
|
|
197
|
+
c_cost[call.get("model") or "unknown"] += usd
|
|
198
|
+
cl = f.get("claims")
|
|
199
|
+
if cl and cl["unsupported"] + cl["contradicted"] > 0:
|
|
200
|
+
c_hall[(r["project"], r["agent_name"])] += 1
|
|
201
|
+
for cat in f.get("categories", []):
|
|
202
|
+
c_rc[(r["agent_name"], cat)] += 1
|
|
203
|
+
metric("tdn_runs_total", "counter", "Agent runs by outcome.",
|
|
204
|
+
[({"project": p, "agent": a, "outcome": o}, n) for (p, a, o), n in sorted(c_runs.items())])
|
|
205
|
+
metric("tdn_llm_tokens_total", "counter", "LLM tokens by model and direction.",
|
|
206
|
+
[({"model": m, "direction": d}, n) for (m, d), n in sorted(c_tok.items())])
|
|
207
|
+
metric("tdn_llm_cost_usd_total", "counter", "LLM cost in USD (priced models only).",
|
|
208
|
+
[({"model": m}, round(v, 6)) for m, v in sorted(c_cost.items())])
|
|
209
|
+
metric("tdn_hallucination_runs_total", "counter", "Runs with at least one unsupported or contradicted claim.",
|
|
210
|
+
[({"project": p, "agent": a}, n) for (p, a), n in sorted(c_hall.items())])
|
|
211
|
+
metric("tdn_rca_findings_total", "counter", "Runs with a finding of each root-cause category.",
|
|
212
|
+
[({"agent": a, "category": c}, n) for (a, c), n in sorted(c_rc.items())])
|
|
213
|
+
tools = store.tool_stats(project, None)
|
|
214
|
+
metric("tdn_tool_calls_total", "counter", "Tool calls.", [({"tool": t["tool"]}, t["calls"]) for t in tools])
|
|
215
|
+
metric("tdn_tool_errors_total", "counter", "Tool calls that failed.", [({"tool": t["tool"]}, t["errors"]) for t in tools])
|
|
216
|
+
try:
|
|
217
|
+
open_inc = store.query("SELECT severity, COUNT(*) n FROM incidents WHERE status != 'resolved' GROUP BY severity")
|
|
218
|
+
except Exception: # noqa: BLE001 - incidents table may not exist on a bare store
|
|
219
|
+
open_inc = []
|
|
220
|
+
metric("tdn_incidents_open", "gauge", "Open incidents by severity.",
|
|
221
|
+
[({"severity": r["severity"]}, r["n"]) for r in open_inc])
|
|
222
|
+
return "\n".join(lines) + "\n"
|