agentsense-ai 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.
- agentsense_ai-0.1.0/.github/workflows/ci.yml +29 -0
- agentsense_ai-0.1.0/.github/workflows/release.yml +28 -0
- agentsense_ai-0.1.0/.gitignore +11 -0
- agentsense_ai-0.1.0/CONTRIBUTING.md +49 -0
- agentsense_ai-0.1.0/LICENSE +202 -0
- agentsense_ai-0.1.0/PKG-INFO +210 -0
- agentsense_ai-0.1.0/README.md +184 -0
- agentsense_ai-0.1.0/docs/img/compare.png +0 -0
- agentsense_ai-0.1.0/docs/img/explorer.png +0 -0
- agentsense_ai-0.1.0/docs/img/live-replay.png +0 -0
- agentsense_ai-0.1.0/examples/capture_then_replay.py +50 -0
- agentsense_ai-0.1.0/examples/replay_bedrock.py +57 -0
- agentsense_ai-0.1.0/examples/replay_scripted.py +51 -0
- agentsense_ai-0.1.0/examples/sdk_capture.py +40 -0
- agentsense_ai-0.1.0/logs/.gitkeep +0 -0
- agentsense_ai-0.1.0/pyproject.toml +77 -0
- agentsense_ai-0.1.0/src/agentsense/__init__.py +7 -0
- agentsense_ai-0.1.0/src/agentsense/cli.py +100 -0
- agentsense_ai-0.1.0/src/agentsense/model/__init__.py +4 -0
- agentsense_ai-0.1.0/src/agentsense/model/jsonrpc.py +64 -0
- agentsense_ai-0.1.0/src/agentsense/model/spans.py +80 -0
- agentsense_ai-0.1.0/src/agentsense/proxy/__init__.py +4 -0
- agentsense_ai-0.1.0/src/agentsense/proxy/stdio.py +75 -0
- agentsense_ai-0.1.0/src/agentsense/proxy/tap.py +100 -0
- agentsense_ai-0.1.0/src/agentsense/redaction/__init__.py +3 -0
- agentsense_ai-0.1.0/src/agentsense/redaction/detectors.py +18 -0
- agentsense_ai-0.1.0/src/agentsense/redaction/redactor.py +76 -0
- agentsense_ai-0.1.0/src/agentsense/replay/__init__.py +47 -0
- agentsense_ai-0.1.0/src/agentsense/replay/adapters/__init__.py +9 -0
- agentsense_ai-0.1.0/src/agentsense/replay/adapters/base.py +30 -0
- agentsense_ai-0.1.0/src/agentsense/replay/adapters/bedrock.py +111 -0
- agentsense_ai-0.1.0/src/agentsense/replay/adapters/openai_compat.py +104 -0
- agentsense_ai-0.1.0/src/agentsense/replay/adapters/scripted.py +31 -0
- agentsense_ai-0.1.0/src/agentsense/replay/capture.py +45 -0
- agentsense_ai-0.1.0/src/agentsense/replay/diff.py +68 -0
- agentsense_ai-0.1.0/src/agentsense/replay/engine.py +87 -0
- agentsense_ai-0.1.0/src/agentsense/replay/recording.py +159 -0
- agentsense_ai-0.1.0/src/agentsense/replay/trajectory.py +53 -0
- agentsense_ai-0.1.0/src/agentsense/replay/types.py +77 -0
- agentsense_ai-0.1.0/src/agentsense/sdk/__init__.py +18 -0
- agentsense_ai-0.1.0/src/agentsense/sdk/conventions.py +70 -0
- agentsense_ai-0.1.0/src/agentsense/sdk/tracer.py +151 -0
- agentsense_ai-0.1.0/src/agentsense/store/__init__.py +3 -0
- agentsense_ai-0.1.0/src/agentsense/store/sqlite.py +184 -0
- agentsense_ai-0.1.0/src/agentsense/ui/__init__.py +1 -0
- agentsense_ai-0.1.0/src/agentsense/ui/app.py +168 -0
- agentsense_ai-0.1.0/src/agentsense/ui/static/index.html +259 -0
- agentsense_ai-0.1.0/tests/__init__.py +0 -0
- agentsense_ai-0.1.0/tests/test_adapter_translation.py +101 -0
- agentsense_ai-0.1.0/tests/test_capture_replay_bridge.py +109 -0
- agentsense_ai-0.1.0/tests/test_proxy_transparency.py +58 -0
- agentsense_ai-0.1.0/tests/test_recording_from_store.py +48 -0
- agentsense_ai-0.1.0/tests/test_redaction.py +45 -0
- agentsense_ai-0.1.0/tests/test_replay_engine.py +87 -0
- agentsense_ai-0.1.0/tests/test_sdk_capture.py +61 -0
- agentsense_ai-0.1.0/tests/test_sdk_conventions.py +45 -0
- agentsense_ai-0.1.0/tests/test_sdk_redaction.py +44 -0
- agentsense_ai-0.1.0/tests/test_store_roundtrip.py +73 -0
- agentsense_ai-0.1.0/tests/test_tap_correlation.py +89 -0
- agentsense_ai-0.1.0/tests/test_trajectory_diff.py +71 -0
- agentsense_ai-0.1.0/tests/test_ui_api.py +65 -0
- agentsense_ai-0.1.0/tests/test_ui_diff.py +56 -0
- agentsense_ai-0.1.0/tests/test_ui_replay.py +81 -0
- agentsense_ai-0.1.0/uv.lock +1073 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v5
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
uses: astral-sh/setup-uv@v6
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
|
|
22
|
+
- name: Sync (dev + ui + replay)
|
|
23
|
+
run: uv sync --group dev --extra ui --extra replay
|
|
24
|
+
|
|
25
|
+
- name: Lint
|
|
26
|
+
run: uv run ruff check .
|
|
27
|
+
|
|
28
|
+
- name: Test
|
|
29
|
+
run: uv run pytest -q
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI when a GitHub Release is published, using PyPI Trusted
|
|
4
|
+
# Publishing (OIDC) — no API tokens stored anywhere.
|
|
5
|
+
on:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment: pypi
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write # required for Trusted Publishing (OIDC)
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v5
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v6
|
|
20
|
+
|
|
21
|
+
- name: Build
|
|
22
|
+
run: uv build
|
|
23
|
+
|
|
24
|
+
- name: Check metadata
|
|
25
|
+
run: uvx twine check dist/*
|
|
26
|
+
|
|
27
|
+
- name: Publish
|
|
28
|
+
run: uv publish --trusted-publishing always
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributing to agentsense
|
|
2
|
+
|
|
3
|
+
Thanks for your interest! agentsense is an early-stage, local-first tool for making sense
|
|
4
|
+
of what AI agents did. Contributions of all kinds are welcome.
|
|
5
|
+
|
|
6
|
+
## Development setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# Install uv: https://docs.astral.sh/uv/
|
|
10
|
+
uv sync --group dev --extra ui --extra replay
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The core (proxy + store + redaction + SDK) has no model or network dependency. The `ui`
|
|
14
|
+
extra adds FastAPI/uvicorn; the `replay` extra adds boto3/openai for live model calls.
|
|
15
|
+
|
|
16
|
+
## Running checks
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv run pytest # full suite, runs entirely offline
|
|
20
|
+
uv run ruff check . # lint
|
|
21
|
+
uv run ruff format . # format (if you use it)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`tests/test_proxy_transparency.py` drives a real MCP server through the proxy and
|
|
25
|
+
self-skips when `npx` is unavailable. Live model calls (Bedrock/OpenAI) are used only in
|
|
26
|
+
the `examples/`, never in the test suite.
|
|
27
|
+
|
|
28
|
+
## Design rules (please preserve)
|
|
29
|
+
|
|
30
|
+
These are load-bearing invariants proven during validation — keep them intact:
|
|
31
|
+
|
|
32
|
+
- **The proxy forwards raw bytes unchanged**; only a *copy* is parsed for tracing. Never
|
|
33
|
+
re-serialize a message onto the wire.
|
|
34
|
+
- **Nothing but JSON-RPC goes to stdout.** All logs go to stderr / a file.
|
|
35
|
+
- **The trace store keeps whole objects** — no field whitelist, so vendor/unknown fields
|
|
36
|
+
survive.
|
|
37
|
+
- **Redaction is deterministic** (hash-derived tokens) and runs on the write path, so a
|
|
38
|
+
redacted trace still aligns with its replay. There is one shared redaction module.
|
|
39
|
+
- **The replay model client stays pluggable** behind `ModelAdapter`; the engine speaks
|
|
40
|
+
only provider-neutral types.
|
|
41
|
+
|
|
42
|
+
## Pull requests
|
|
43
|
+
|
|
44
|
+
1. Add or update tests for your change (they should pass offline).
|
|
45
|
+
2. Run `ruff check .` and the test suite.
|
|
46
|
+
3. Keep changes focused; describe the "why" in the PR.
|
|
47
|
+
|
|
48
|
+
By contributing, you agree that your contributions are licensed under the Apache 2.0
|
|
49
|
+
License.
|
|
@@ -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 2026 Rahul Rajeev
|
|
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,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentsense-ai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Make sense of what your AI agents did — local-first, MCP-native observability, trace replay & trajectory diff.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Rahul06x1/agentsense
|
|
6
|
+
Project-URL: Repository, https://github.com/Rahul06x1/agentsense
|
|
7
|
+
Project-URL: Issues, https://github.com/Rahul06x1/agentsense/issues
|
|
8
|
+
Author-email: Rahul Rajeev <rahulrajeev2k1@gmail.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,ai,debugging,llm,mcp,model-context-protocol,observability,replay,tracing
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
16
|
+
Classifier: Topic :: System :: Monitoring
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Requires-Dist: pydantic>=2.7
|
|
19
|
+
Provides-Extra: replay
|
|
20
|
+
Requires-Dist: boto3>=1.43; extra == 'replay'
|
|
21
|
+
Requires-Dist: openai>=2.0; extra == 'replay'
|
|
22
|
+
Provides-Extra: ui
|
|
23
|
+
Requires-Dist: fastapi>=0.110; extra == 'ui'
|
|
24
|
+
Requires-Dist: uvicorn>=0.29; extra == 'ui'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# agentsense
|
|
28
|
+
|
|
29
|
+
**Make sense of what your AI agents did.** A local-first, MCP-native observability &
|
|
30
|
+
debugging tool: a transparent MCP proxy traces every protocol message with **zero code
|
|
31
|
+
change to the agent**, PII is redacted deterministically on the write path, and traces
|
|
32
|
+
are stored whole (no field whitelist) in local SQLite — then **replayed and diffed** to
|
|
33
|
+
see how a different model would have decided.
|
|
34
|
+
|
|
35
|
+
*Apache-2.0 · local-first · no cloud signup*
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
> *Compare view — the same run replayed against two models; the first point where their decisions diverge is highlighted.*
|
|
40
|
+
|
|
41
|
+
## Aim
|
|
42
|
+
|
|
43
|
+
Ship an open-source, MCP-native agent observability & debugging tool that combines four
|
|
44
|
+
properties no existing tool has together: **local-first**, **MCP-native** (instruments
|
|
45
|
+
inside the Model Context Protocol, not wrapped via OpenTelemetry), **true trace replay +
|
|
46
|
+
trajectory diff**, and **open source**. The goal is a public release with a working demo
|
|
47
|
+
and documented architecture — a debugger for AI agents that runs entirely on your machine.
|
|
48
|
+
|
|
49
|
+
## Why it's useful
|
|
50
|
+
|
|
51
|
+
When an AI agent misbehaves — wrong tool, bad decision, runaway cost — you are usually
|
|
52
|
+
guessing. agentsense gives you ground truth:
|
|
53
|
+
|
|
54
|
+
- **Protocol-level tracing with zero code change.** Point the agent's MCP config at the
|
|
55
|
+
proxy and every tool call, input/output, latency, and cost is captured — even for
|
|
56
|
+
agents you can't instrument.
|
|
57
|
+
- **"Would a different model fix this?"** Replay a recorded trace against another
|
|
58
|
+
model/prompt, feeding back stored tool results, and diff the trajectory to see exactly
|
|
59
|
+
where behaviour diverges — no live tool calls, no API cost, no side effects.
|
|
60
|
+
- **Compliance-ready audit trails.** PII is redacted deterministically *before* it is
|
|
61
|
+
ever stored, and the redaction itself is logged — the audit-trail story for EU AI Act
|
|
62
|
+
enforcement (from August 2026).
|
|
63
|
+
- **Local-first.** No cloud signup, fully self-hostable.
|
|
64
|
+
|
|
65
|
+
## What's here (v0)
|
|
66
|
+
|
|
67
|
+
| Component | Module | Status |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| MCP proxy (stdio, transparent) | `proxy/` | ✅ built first |
|
|
70
|
+
| Deterministic PII redaction | `redaction/` | ✅ write-path |
|
|
71
|
+
| SQLite trace store (whole objects) | `store/` | ✅ |
|
|
72
|
+
| Mocked replay + trajectory diff | `replay/` | ✅ pluggable model client |
|
|
73
|
+
| Python capture SDK | `sdk/` | ✅ OTel GenAI conventions |
|
|
74
|
+
| Local trace-explorer UI | `ui/` | ✅ read-only, FastAPI |
|
|
75
|
+
|
|
76
|
+
## Design rules (proven in Phase 0, enforced here)
|
|
77
|
+
|
|
78
|
+
- Proxy forwards raw bytes **unchanged**; only a *copy* is parsed for tracing.
|
|
79
|
+
- Logs go to **stderr / file, never stdout** (stdout is the JSON-RPC channel).
|
|
80
|
+
- Trace store preserves **unknown/vendor fields** — whole objects, no whitelist.
|
|
81
|
+
- Redaction is **deterministic** (hash-derived tokens) so replay aligns.
|
|
82
|
+
|
|
83
|
+
## Install
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install agentsense-ai # distribution name; the CLI and import are `agentsense`
|
|
87
|
+
# extras: pip install "agentsense-ai[ui,replay]" # web UI + live-replay model clients
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The install/import names differ (like `scikit-learn` → `sklearn`): the package is
|
|
91
|
+
`agentsense-ai`, but you run `agentsense …` and `import agentsense`.
|
|
92
|
+
|
|
93
|
+
## Quick start
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
uv sync --group dev
|
|
97
|
+
|
|
98
|
+
# Point your MCP client's server config at this command instead of the real server.
|
|
99
|
+
# The proxy forwards transparently and traces to SQLite.
|
|
100
|
+
uv run agentsense proxy --db traces.db -- \
|
|
101
|
+
npx -y @modelcontextprotocol/server-filesystem /tmp
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Tests
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
uv run pytest # unit tests run offline; the proxy has no model dependency
|
|
108
|
+
uv run ruff check .
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`test_proxy_transparency.py` is an integration test that drives `server-filesystem`
|
|
112
|
+
through the proxy with a real MCP client; it self-skips if `npx` is unavailable.
|
|
113
|
+
|
|
114
|
+
## UI (local trace explorer)
|
|
115
|
+
|
|
116
|
+
A read-only web app over the trace store — no build step, no Node. It serves a JSON
|
|
117
|
+
API and a single static page (trace list → span tree + timeline + redaction badges).
|
|
118
|
+
|
|
119
|
+

|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
uv sync --extra ui
|
|
123
|
+
uv run agentsense ui --db traces.db # opens http://127.0.0.1:8000
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The **Compare** tab renders the side-by-side trajectory diff: pick two captured traces
|
|
127
|
+
and see their decision sequences aligned, with the first point of divergence highlighted.
|
|
128
|
+
|
|
129
|
+
**Live replay** — on any captured trace, pick a model and re-run it right there: agentsense
|
|
130
|
+
rebuilds the recording, replays it against your chosen model (OpenAI-compatible/Ollama or
|
|
131
|
+
AWS Bedrock), and diffs the result against what the agent actually did. Ephemeral — no
|
|
132
|
+
store writes.
|
|
133
|
+
|
|
134
|
+

|
|
135
|
+
|
|
136
|
+
Endpoints: `GET /api/traces`, `GET /api/traces/{id}/spans`, `GET /api/diff?a=&b=`,
|
|
137
|
+
`POST /api/replay`. The frontend is plain HTML/JS in `ui/static/` — swappable for React
|
|
138
|
+
later behind the same API.
|
|
139
|
+
|
|
140
|
+
## Capture SDK
|
|
141
|
+
|
|
142
|
+
For agents you *can* instrument, the SDK records reasoning-level detail the proxy can't
|
|
143
|
+
see. It writes through the same store — and therefore the same redaction path — as the
|
|
144
|
+
proxy, using OpenTelemetry GenAI attribute naming (`gen_ai.*`) for interop.
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from agentsense.sdk import Tracer
|
|
148
|
+
from agentsense.store import SpanStore
|
|
149
|
+
|
|
150
|
+
tracer = Tracer(SpanStore("traces.db"))
|
|
151
|
+
with tracer.session("booking-agent") as s:
|
|
152
|
+
s.step("plan", reasoning=..., model="claude-opus-4-8")
|
|
153
|
+
s.llm_call("claude-opus-4-8", messages=[...], response={...},
|
|
154
|
+
usage={"input_tokens": 1200, "output_tokens": 80})
|
|
155
|
+
s.tool_call("search_flights", args={...}, result={...}, cost=0.002)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Spans form a shallow tree (session → steps). `llm_call` stores the whole conversation
|
|
159
|
+
(messages, tools, response) so a captured run can be reconstructed into a replayable
|
|
160
|
+
`Recording`. Demo: `uv run python examples/sdk_capture.py`.
|
|
161
|
+
|
|
162
|
+
## Replay + trajectory diff
|
|
163
|
+
|
|
164
|
+
Re-drive an agent run against a different model, **injecting recorded tool results**
|
|
165
|
+
(the engine cannot call a live tool — the guarantee holds by construction), then diff
|
|
166
|
+
the two decision trajectories to find the first point of divergence.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Offline, no creds — two scripted "models" over the same recorded results:
|
|
170
|
+
uv run python examples/replay_scripted.py
|
|
171
|
+
# → diverge at decision 0: haiku-4.5 → call get_weather(...) | opus-4.8 → call get_forecast(...)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The model client is **pluggable behind one adapter** (`replay/adapters/`): `ScriptedAdapter`
|
|
175
|
+
(offline/tests), `BedrockAdapter` (Converse, dev), `OpenAICompatAdapter` (OSS release). The
|
|
176
|
+
engine speaks only provider-neutral types — swapping providers never touches it. Recorded
|
|
177
|
+
tool results can be supplied directly or pulled from a captured proxy trace via
|
|
178
|
+
`Recording.from_trace_store(...)`.
|
|
179
|
+
|
|
180
|
+
### Capture → replay (the full loop)
|
|
181
|
+
|
|
182
|
+
An SDK-captured run replays end-to-end: `Recording.from_sdk_trace(store, trace_id)`
|
|
183
|
+
reconstructs the question, tools, model, and recorded tool results, and
|
|
184
|
+
`captured_trajectory(store, trace_id)` reconstructs what the agent *actually did*. Diff
|
|
185
|
+
the two to answer "would a different model have decided differently than my agent did?"
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
uv run python examples/capture_then_replay.py
|
|
189
|
+
# → diverge at decision 0: claude-haiku-4-5 → call get_weather(...) | rushed-model → final answer
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Model access (live replay only — not needed for the proxy)
|
|
193
|
+
|
|
194
|
+
Live replay uses AWS Bedrock (Converse API) for dev, OpenAI-compatible for the OSS
|
|
195
|
+
release. Before running the Bedrock example:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
aws sso login --profile <your-aws-profile> # temporary SSO creds
|
|
199
|
+
export AWS_PROFILE=<your-aws-profile> AWS_REGION=eu-west-1
|
|
200
|
+
uv run --extra replay python examples/replay_bedrock.py
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
Issues and PRs welcome — see [CONTRIBUTING.md](./CONTRIBUTING.md). All tests run offline
|
|
206
|
+
(`uv run pytest`); the proxy has no model dependency.
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
[Apache License 2.0](./LICENSE) — includes an explicit patent grant.
|