evallabs-sdk 0.2.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.
- evallabs_sdk-0.2.0/CHANGELOG.md +15 -0
- evallabs_sdk-0.2.0/LICENSE +202 -0
- evallabs_sdk-0.2.0/MANIFEST.in +3 -0
- evallabs_sdk-0.2.0/NOTICE +6 -0
- evallabs_sdk-0.2.0/PKG-INFO +180 -0
- evallabs_sdk-0.2.0/README.md +150 -0
- evallabs_sdk-0.2.0/evallabs/__init__.py +81 -0
- evallabs_sdk-0.2.0/evallabs/_compat.py +18 -0
- evallabs_sdk-0.2.0/evallabs/_threads.py +56 -0
- evallabs_sdk-0.2.0/evallabs/actors.py +92 -0
- evallabs_sdk-0.2.0/evallabs/agent_logging.py +532 -0
- evallabs_sdk-0.2.0/evallabs/collector.py +92 -0
- evallabs_sdk-0.2.0/evallabs/context.py +25 -0
- evallabs_sdk-0.2.0/evallabs/contract.py +107 -0
- evallabs_sdk-0.2.0/evallabs/decorators.py +1456 -0
- evallabs_sdk-0.2.0/evallabs/describe.py +198 -0
- evallabs_sdk-0.2.0/evallabs/events.py +72 -0
- evallabs_sdk-0.2.0/evallabs/monitoring.py +326 -0
- evallabs_sdk-0.2.0/evallabs/payload_capture.py +458 -0
- evallabs_sdk-0.2.0/evallabs/py.typed +0 -0
- evallabs_sdk-0.2.0/evallabs/serialization.py +32 -0
- evallabs_sdk-0.2.0/evallabs/sinks.py +190 -0
- evallabs_sdk-0.2.0/evallabs/tracer.py +350 -0
- evallabs_sdk-0.2.0/evallabs/tracer_types.py +63 -0
- evallabs_sdk-0.2.0/evallabs_sdk.egg-info/PKG-INFO +180 -0
- evallabs_sdk-0.2.0/evallabs_sdk.egg-info/SOURCES.txt +29 -0
- evallabs_sdk-0.2.0/evallabs_sdk.egg-info/dependency_links.txt +1 -0
- evallabs_sdk-0.2.0/evallabs_sdk.egg-info/requires.txt +5 -0
- evallabs_sdk-0.2.0/evallabs_sdk.egg-info/top_level.txt +1 -0
- evallabs_sdk-0.2.0/pyproject.toml +50 -0
- evallabs_sdk-0.2.0/setup.cfg +4 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (first public release)
|
|
4
|
+
|
|
5
|
+
- Published on PyPI as `evallabs-sdk`; imported as `evallabs` (earlier private builds used `evals_sdk`).
|
|
6
|
+
- Open source under the Apache License 2.0.
|
|
7
|
+
- Python 3.10 to 3.14.
|
|
8
|
+
- A test's events are sent to Eval Labs in one request when the test's request finishes, instead of one request per event.
|
|
9
|
+
- A missing endpoint, a rejected key or an unreachable Eval Labs logs one warning starting with `Eval Labs tracing:`; the agent keeps working.
|
|
10
|
+
- Tool calls are recorded from threads (`ThreadPoolExecutor`, `threading.Thread`), streaming handlers (sync and async generators) and class methods.
|
|
11
|
+
- `@trace_eval_request` reads the test from FastAPI/Starlette, Flask and Django requests, Pydantic models, dataclasses and JSON text; `traced_request(...)` covers anything else.
|
|
12
|
+
- `@trace_tool` works on LangChain tools and OpenAI Agents `FunctionTool` objects.
|
|
13
|
+
- In tests, which use made-up data, personal fields (ids, emails, phone numbers) are kept so rules about them can be checked; production monitoring still hides them. Secrets are always hidden. `keep_keys` keeps a field that looks like a secret but isn't.
|
|
14
|
+
- Larger values are kept before summarising (64 KB per call, strings up to 2000 characters).
|
|
15
|
+
- `describe_agent` accepts rules written as plain sentences, and corrects or warns about unknown side effects.
|
|
@@ -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,6 @@
|
|
|
1
|
+
Eval Labs SDK (evallabs-sdk)
|
|
2
|
+
Copyright 2026 Eval Labs
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
"Eval Labs" is a name of Eval Labs; the licence grants no right to use it
|
|
6
|
+
except to describe where this software came from (Apache License 2.0, section 6).
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: evallabs-sdk
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Eval Labs SDK: record the tools an AI agent really calls, so Eval Labs can test and monitor it.
|
|
5
|
+
Author: Eval Labs
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Keywords: ai agents,llm,evaluation,testing,tracing,monitoring
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Topic :: Software Development :: Testing
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Requires-Dist: pydantic>=2.0
|
|
26
|
+
Provides-Extra: otel
|
|
27
|
+
Requires-Dist: opentelemetry-sdk>=1.25; extra == "otel"
|
|
28
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.25; extra == "otel"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# evallabs-sdk
|
|
32
|
+
|
|
33
|
+
Add this to your AI agent so Eval Labs sees the tools it really calls, with their inputs
|
|
34
|
+
and results. Eval Labs then tests your agent against your business rules, and can monitor it in production.
|
|
35
|
+
|
|
36
|
+
Without the SDK, Eval Labs only sees your agent's final answer. Tests that depend on what the agent
|
|
37
|
+
did, such as "it must check the date of birth before cancelling", then end up as "Needs review".
|
|
38
|
+
|
|
39
|
+
Python 3.10 or newer. The only dependency is `pydantic>=2`.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install evallabs-sdk
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The package installs as `evallabs`: `import evallabs; print(evallabs.__version__)`.
|
|
46
|
+
What changed in each version is in `CHANGELOG.md`, included in the source download.
|
|
47
|
+
|
|
48
|
+
## 1. Point it at Eval Labs
|
|
49
|
+
|
|
50
|
+
Set these where your agent runs:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
SDK_TRACE_ENDPOINT=https://<your Eval Labs address>/sdk/traces/events
|
|
54
|
+
SDK_API_KEY=<your SDK key>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
If one is missing or wrong, your agent keeps working and its log shows a warning starting with
|
|
58
|
+
`Eval Labs tracing:` that says what to fix.
|
|
59
|
+
|
|
60
|
+
## 2. Add the decorators
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from evallabs import trace_agent, trace_eval_request, trace_tool
|
|
64
|
+
|
|
65
|
+
@trace_eval_request # reads the test Eval Labs sends; ordinary requests are untouched
|
|
66
|
+
@trace_agent(name="support_agent")
|
|
67
|
+
def handle(request: dict) -> dict:
|
|
68
|
+
order = lookup_order(request["context"]["order_id"])
|
|
69
|
+
...
|
|
70
|
+
return {"final_answer": "..."}
|
|
71
|
+
|
|
72
|
+
@trace_tool(side_effect="read_only")
|
|
73
|
+
def lookup_order(order_id: str) -> dict:
|
|
74
|
+
"""Look up an order by ID."""
|
|
75
|
+
...
|
|
76
|
+
|
|
77
|
+
@trace_tool(side_effect="financial")
|
|
78
|
+
def refund_order(order_id: str, amount: float) -> dict:
|
|
79
|
+
"""Refund part or all of an order."""
|
|
80
|
+
...
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`side_effect` tells Eval Labs how risky a tool is. Use one of: `read_only`, `write`, `financial`,
|
|
84
|
+
`order_update`, `support_workflow`, `external_message`, `destructive`.
|
|
85
|
+
|
|
86
|
+
During a test, events are kept in memory and sent in one request when your handler returns, before
|
|
87
|
+
the reply goes out. Ordinary traffic sends nothing, unless you turn on monitoring (see below).
|
|
88
|
+
|
|
89
|
+
## Works with
|
|
90
|
+
|
|
91
|
+
| Your setup | What to do |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Sync or async functions | Nothing extra. |
|
|
94
|
+
| Methods (`def handle(self, request)`) | Nothing extra. `self` is not recorded. |
|
|
95
|
+
| FastAPI / Starlette | Put `@trace_eval_request` under `@app.post(...)`. The request can be a `dict`, a Pydantic model or a `Request` (the body is still readable in your handler). |
|
|
96
|
+
| Flask | `with traced_request(request.get_json()):` around the agent call, or `@trace_eval_request(request_getter=lambda: request.get_json())`. |
|
|
97
|
+
| Django | Pass the `HttpRequest`. Its JSON body is read. |
|
|
98
|
+
| Streaming answers (sync or async generators) | Nothing extra. Tools called between chunks are recorded, and the streamed text is recorded as the answer. |
|
|
99
|
+
| Tools run in threads (`ThreadPoolExecutor`, `run_in_executor`, `threading.Thread`, `asyncio.to_thread`) | Nothing extra. |
|
|
100
|
+
| Many tests at once (threads or asyncio) | Nothing extra. Each test's events stay separate. |
|
|
101
|
+
| LangChain tools | `@trace_tool` above or below `@tool`. |
|
|
102
|
+
| OpenAI Agents SDK | `@trace_tool` above `@function_tool`. |
|
|
103
|
+
| Other frameworks | Put `@trace_tool` on the plain function, below the framework's own decorator. |
|
|
104
|
+
|
|
105
|
+
## Describe your agent
|
|
106
|
+
|
|
107
|
+
`describe_agent()` lists every `@trace_tool` function (name, arguments, purpose, side effect) plus
|
|
108
|
+
your rules and sample data. Serve it from your agent, and Eval Labs reads it to write tests:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from evallabs import describe_agent
|
|
112
|
+
|
|
113
|
+
@app.get("/evallabs-config.json")
|
|
114
|
+
def config():
|
|
115
|
+
return describe_agent(
|
|
116
|
+
agent_id="support_agent",
|
|
117
|
+
description="Answers order questions and handles refunds.",
|
|
118
|
+
policies=[
|
|
119
|
+
"Refunds over $500 need a manager.",
|
|
120
|
+
{"id": "verify_identity", "description": "Confirm the customer's email before changing an order."},
|
|
121
|
+
],
|
|
122
|
+
sample_data={"orders": [{"order_id": "A-1001", "status": "delivered", "total": 120}]},
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## What is hidden
|
|
127
|
+
|
|
128
|
+
Secrets are never sent: keys whose last word is a secret word, such as `password`, `token`,
|
|
129
|
+
`api_key`, `authorization`, `cookie` or `secret` (so `access_token` is hidden, but `max_tokens` is not).
|
|
130
|
+
|
|
131
|
+
Personal identifiers (`email`, `phone`, `patient_id`, `ssn` and similar) are hidden in production
|
|
132
|
+
monitoring. In tests they are kept, because tests use made-up data, and a test can't check "the agent
|
|
133
|
+
looked up the right customer" if the ID is hidden.
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from evallabs import configure_tracing
|
|
137
|
+
|
|
138
|
+
configure_tracing(
|
|
139
|
+
redact_keys=["internal_note"], # hide more
|
|
140
|
+
keep_keys=["order_token"], # never hide these (for example an order number, not a secret)
|
|
141
|
+
redact_personal_data_in_tests=True, # hide personal data in tests too
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Production monitoring (optional)
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from evallabs import configure_monitoring, monitoring_session
|
|
149
|
+
|
|
150
|
+
configure_monitoring(endpoint="https://<your Eval Labs address>", agent_id="support_agent", agent_version="1.4.0", api_key="...")
|
|
151
|
+
|
|
152
|
+
with monitoring_session(conversation_id): # group one conversation's turns
|
|
153
|
+
handle(request)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Traces are sent in the background in batches. Monitoring never slows down or breaks your agent: if
|
|
157
|
+
Eval Labs is down, traces are dropped and counted.
|
|
158
|
+
|
|
159
|
+
## Settings
|
|
160
|
+
|
|
161
|
+
| Variable | Default | |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| `SDK_TRACE_ENDPOINT` | none | Where test events go. |
|
|
164
|
+
| `SDK_API_KEY` | none | Sent as `X-Evals-Sdk-Api-Key`. |
|
|
165
|
+
| `SDK_TRACE_TIMEOUT_SECONDS` | 2 | Per request. A test's events are sent within 10 seconds or dropped. |
|
|
166
|
+
| `EVALLABS_THREAD_CONTEXT` | on | Set to `0` to stop the SDK following tools into threads. |
|
|
167
|
+
|
|
168
|
+
## Troubleshooting
|
|
169
|
+
|
|
170
|
+
* **Every test says the agent called no tools.** Look for `Eval Labs tracing:` in your agent's log.
|
|
171
|
+
Check that `SDK_TRACE_ENDPOINT` is set in the agent's own environment (not just your shell), and that
|
|
172
|
+
the handler with `@trace_eval_request` receives the request Eval Labs sent.
|
|
173
|
+
* **A field shows as hidden in Eval Labs.** It looked like a secret. Add it to `keep_keys`.
|
|
174
|
+
* **`@trace_tool can't reach the code of ...`**: put `@trace_tool` directly on the function, below
|
|
175
|
+
the framework's decorator.
|
|
176
|
+
|
|
177
|
+
## Licence
|
|
178
|
+
|
|
179
|
+
Apache License 2.0. Copyright 2026 Eval Labs. See `LICENSE` and `NOTICE`.
|
|
180
|
+
The licence covers this SDK only; the Eval Labs service it reports to is a separate product.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# evallabs-sdk
|
|
2
|
+
|
|
3
|
+
Add this to your AI agent so Eval Labs sees the tools it really calls, with their inputs
|
|
4
|
+
and results. Eval Labs then tests your agent against your business rules, and can monitor it in production.
|
|
5
|
+
|
|
6
|
+
Without the SDK, Eval Labs only sees your agent's final answer. Tests that depend on what the agent
|
|
7
|
+
did, such as "it must check the date of birth before cancelling", then end up as "Needs review".
|
|
8
|
+
|
|
9
|
+
Python 3.10 or newer. The only dependency is `pydantic>=2`.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install evallabs-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The package installs as `evallabs`: `import evallabs; print(evallabs.__version__)`.
|
|
16
|
+
What changed in each version is in `CHANGELOG.md`, included in the source download.
|
|
17
|
+
|
|
18
|
+
## 1. Point it at Eval Labs
|
|
19
|
+
|
|
20
|
+
Set these where your agent runs:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
SDK_TRACE_ENDPOINT=https://<your Eval Labs address>/sdk/traces/events
|
|
24
|
+
SDK_API_KEY=<your SDK key>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
If one is missing or wrong, your agent keeps working and its log shows a warning starting with
|
|
28
|
+
`Eval Labs tracing:` that says what to fix.
|
|
29
|
+
|
|
30
|
+
## 2. Add the decorators
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from evallabs import trace_agent, trace_eval_request, trace_tool
|
|
34
|
+
|
|
35
|
+
@trace_eval_request # reads the test Eval Labs sends; ordinary requests are untouched
|
|
36
|
+
@trace_agent(name="support_agent")
|
|
37
|
+
def handle(request: dict) -> dict:
|
|
38
|
+
order = lookup_order(request["context"]["order_id"])
|
|
39
|
+
...
|
|
40
|
+
return {"final_answer": "..."}
|
|
41
|
+
|
|
42
|
+
@trace_tool(side_effect="read_only")
|
|
43
|
+
def lookup_order(order_id: str) -> dict:
|
|
44
|
+
"""Look up an order by ID."""
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
@trace_tool(side_effect="financial")
|
|
48
|
+
def refund_order(order_id: str, amount: float) -> dict:
|
|
49
|
+
"""Refund part or all of an order."""
|
|
50
|
+
...
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`side_effect` tells Eval Labs how risky a tool is. Use one of: `read_only`, `write`, `financial`,
|
|
54
|
+
`order_update`, `support_workflow`, `external_message`, `destructive`.
|
|
55
|
+
|
|
56
|
+
During a test, events are kept in memory and sent in one request when your handler returns, before
|
|
57
|
+
the reply goes out. Ordinary traffic sends nothing, unless you turn on monitoring (see below).
|
|
58
|
+
|
|
59
|
+
## Works with
|
|
60
|
+
|
|
61
|
+
| Your setup | What to do |
|
|
62
|
+
|---|---|
|
|
63
|
+
| Sync or async functions | Nothing extra. |
|
|
64
|
+
| Methods (`def handle(self, request)`) | Nothing extra. `self` is not recorded. |
|
|
65
|
+
| FastAPI / Starlette | Put `@trace_eval_request` under `@app.post(...)`. The request can be a `dict`, a Pydantic model or a `Request` (the body is still readable in your handler). |
|
|
66
|
+
| Flask | `with traced_request(request.get_json()):` around the agent call, or `@trace_eval_request(request_getter=lambda: request.get_json())`. |
|
|
67
|
+
| Django | Pass the `HttpRequest`. Its JSON body is read. |
|
|
68
|
+
| Streaming answers (sync or async generators) | Nothing extra. Tools called between chunks are recorded, and the streamed text is recorded as the answer. |
|
|
69
|
+
| Tools run in threads (`ThreadPoolExecutor`, `run_in_executor`, `threading.Thread`, `asyncio.to_thread`) | Nothing extra. |
|
|
70
|
+
| Many tests at once (threads or asyncio) | Nothing extra. Each test's events stay separate. |
|
|
71
|
+
| LangChain tools | `@trace_tool` above or below `@tool`. |
|
|
72
|
+
| OpenAI Agents SDK | `@trace_tool` above `@function_tool`. |
|
|
73
|
+
| Other frameworks | Put `@trace_tool` on the plain function, below the framework's own decorator. |
|
|
74
|
+
|
|
75
|
+
## Describe your agent
|
|
76
|
+
|
|
77
|
+
`describe_agent()` lists every `@trace_tool` function (name, arguments, purpose, side effect) plus
|
|
78
|
+
your rules and sample data. Serve it from your agent, and Eval Labs reads it to write tests:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from evallabs import describe_agent
|
|
82
|
+
|
|
83
|
+
@app.get("/evallabs-config.json")
|
|
84
|
+
def config():
|
|
85
|
+
return describe_agent(
|
|
86
|
+
agent_id="support_agent",
|
|
87
|
+
description="Answers order questions and handles refunds.",
|
|
88
|
+
policies=[
|
|
89
|
+
"Refunds over $500 need a manager.",
|
|
90
|
+
{"id": "verify_identity", "description": "Confirm the customer's email before changing an order."},
|
|
91
|
+
],
|
|
92
|
+
sample_data={"orders": [{"order_id": "A-1001", "status": "delivered", "total": 120}]},
|
|
93
|
+
)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## What is hidden
|
|
97
|
+
|
|
98
|
+
Secrets are never sent: keys whose last word is a secret word, such as `password`, `token`,
|
|
99
|
+
`api_key`, `authorization`, `cookie` or `secret` (so `access_token` is hidden, but `max_tokens` is not).
|
|
100
|
+
|
|
101
|
+
Personal identifiers (`email`, `phone`, `patient_id`, `ssn` and similar) are hidden in production
|
|
102
|
+
monitoring. In tests they are kept, because tests use made-up data, and a test can't check "the agent
|
|
103
|
+
looked up the right customer" if the ID is hidden.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from evallabs import configure_tracing
|
|
107
|
+
|
|
108
|
+
configure_tracing(
|
|
109
|
+
redact_keys=["internal_note"], # hide more
|
|
110
|
+
keep_keys=["order_token"], # never hide these (for example an order number, not a secret)
|
|
111
|
+
redact_personal_data_in_tests=True, # hide personal data in tests too
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Production monitoring (optional)
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from evallabs import configure_monitoring, monitoring_session
|
|
119
|
+
|
|
120
|
+
configure_monitoring(endpoint="https://<your Eval Labs address>", agent_id="support_agent", agent_version="1.4.0", api_key="...")
|
|
121
|
+
|
|
122
|
+
with monitoring_session(conversation_id): # group one conversation's turns
|
|
123
|
+
handle(request)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Traces are sent in the background in batches. Monitoring never slows down or breaks your agent: if
|
|
127
|
+
Eval Labs is down, traces are dropped and counted.
|
|
128
|
+
|
|
129
|
+
## Settings
|
|
130
|
+
|
|
131
|
+
| Variable | Default | |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| `SDK_TRACE_ENDPOINT` | none | Where test events go. |
|
|
134
|
+
| `SDK_API_KEY` | none | Sent as `X-Evals-Sdk-Api-Key`. |
|
|
135
|
+
| `SDK_TRACE_TIMEOUT_SECONDS` | 2 | Per request. A test's events are sent within 10 seconds or dropped. |
|
|
136
|
+
| `EVALLABS_THREAD_CONTEXT` | on | Set to `0` to stop the SDK following tools into threads. |
|
|
137
|
+
|
|
138
|
+
## Troubleshooting
|
|
139
|
+
|
|
140
|
+
* **Every test says the agent called no tools.** Look for `Eval Labs tracing:` in your agent's log.
|
|
141
|
+
Check that `SDK_TRACE_ENDPOINT` is set in the agent's own environment (not just your shell), and that
|
|
142
|
+
the handler with `@trace_eval_request` receives the request Eval Labs sent.
|
|
143
|
+
* **A field shows as hidden in Eval Labs.** It looked like a secret. Add it to `keep_keys`.
|
|
144
|
+
* **`@trace_tool can't reach the code of ...`**: put `@trace_tool` directly on the function, below
|
|
145
|
+
the framework's decorator.
|
|
146
|
+
|
|
147
|
+
## Licence
|
|
148
|
+
|
|
149
|
+
Apache License 2.0. Copyright 2026 Eval Labs. See `LICENSE` and `NOTICE`.
|
|
150
|
+
The licence covers this SDK only; the Eval Labs service it reports to is a separate product.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Eval Labs SDK: records the tools an AI agent really calls, so Eval Labs can test and monitor it.
|
|
2
|
+
|
|
3
|
+
Published on PyPI as ``evallabs-sdk``; imported as ``evallabs``.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "0.2.0"
|
|
7
|
+
|
|
8
|
+
from evallabs.agent_logging import (
|
|
9
|
+
AgentLogConfig,
|
|
10
|
+
AgentLogContext,
|
|
11
|
+
AgentLogEmitter,
|
|
12
|
+
agent_log_context_from_eval_request,
|
|
13
|
+
configure_agent_logging,
|
|
14
|
+
emit_agent_log,
|
|
15
|
+
flush_agent_logs,
|
|
16
|
+
get_agent_log_context,
|
|
17
|
+
get_agent_log_emitter,
|
|
18
|
+
use_agent_log_context,
|
|
19
|
+
)
|
|
20
|
+
from evallabs.actors import current_actor, record_answer, record_handoff, subagent, trace_subagent
|
|
21
|
+
from evallabs.describe import describe_agent, registered_tools
|
|
22
|
+
from evallabs.decorators import trace_agent, trace_eval_request, trace_span, trace_step, trace_tool, traced_request
|
|
23
|
+
from evallabs.events import record_custom_event, record_policy_check
|
|
24
|
+
from evallabs.monitoring import (
|
|
25
|
+
configure_monitoring,
|
|
26
|
+
configure_monitoring_from_env,
|
|
27
|
+
current_trace_id,
|
|
28
|
+
disable_monitoring,
|
|
29
|
+
flush_monitoring,
|
|
30
|
+
monitoring_session,
|
|
31
|
+
record_feedback,
|
|
32
|
+
)
|
|
33
|
+
from evallabs.payload_capture import configure_tracing
|
|
34
|
+
from evallabs.sinks import HTTPTraceSink, InMemoryTraceSink, JsonlTraceSink, load_jsonl_trace_events
|
|
35
|
+
from evallabs.tracer import EvalsTracer
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"__version__",
|
|
39
|
+
"AgentLogConfig",
|
|
40
|
+
"AgentLogContext",
|
|
41
|
+
"AgentLogEmitter",
|
|
42
|
+
"EvalsTracer",
|
|
43
|
+
"HTTPTraceSink",
|
|
44
|
+
"InMemoryTraceSink",
|
|
45
|
+
"JsonlTraceSink",
|
|
46
|
+
"agent_log_context_from_eval_request",
|
|
47
|
+
"configure_agent_logging",
|
|
48
|
+
"configure_monitoring",
|
|
49
|
+
"configure_monitoring_from_env",
|
|
50
|
+
"current_actor",
|
|
51
|
+
"current_trace_id",
|
|
52
|
+
"describe_agent",
|
|
53
|
+
"disable_monitoring",
|
|
54
|
+
"flush_monitoring",
|
|
55
|
+
"monitoring_session",
|
|
56
|
+
"record_feedback",
|
|
57
|
+
"configure_tracing",
|
|
58
|
+
"emit_agent_log",
|
|
59
|
+
"flush_agent_logs",
|
|
60
|
+
"get_agent_log_context",
|
|
61
|
+
"get_agent_log_emitter",
|
|
62
|
+
"load_jsonl_trace_events",
|
|
63
|
+
"record_custom_event",
|
|
64
|
+
"record_answer",
|
|
65
|
+
"record_handoff",
|
|
66
|
+
"record_policy_check",
|
|
67
|
+
"registered_tools",
|
|
68
|
+
"trace_agent",
|
|
69
|
+
"trace_eval_request",
|
|
70
|
+
"trace_span",
|
|
71
|
+
"trace_step",
|
|
72
|
+
"subagent",
|
|
73
|
+
"trace_subagent",
|
|
74
|
+
"trace_tool",
|
|
75
|
+
"traced_request",
|
|
76
|
+
"use_agent_log_context",
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
from evallabs._threads import install as _install_thread_context
|
|
80
|
+
|
|
81
|
+
_install_thread_context()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Small stand-ins so the SDK runs on Python 3.10 as well as 3.11+."""
|
|
2
|
+
|
|
3
|
+
from datetime import timezone
|
|
4
|
+
from enum import Enum
|
|
5
|
+
|
|
6
|
+
UTC = timezone.utc
|
|
7
|
+
|
|
8
|
+
try: # Python 3.11+
|
|
9
|
+
from enum import StrEnum
|
|
10
|
+
except ImportError: # Python 3.10
|
|
11
|
+
|
|
12
|
+
class StrEnum(str, Enum): # type: ignore[no-redef]
|
|
13
|
+
"""An Enum whose members are also strings, like enum.StrEnum."""
|
|
14
|
+
|
|
15
|
+
def __str__(self) -> str:
|
|
16
|
+
return str(self.value)
|
|
17
|
+
|
|
18
|
+
__all__ = ["UTC", "StrEnum"]
|