agentx-python 0.6.14__tar.gz → 0.6.16__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.
- {agentx_python-0.6.14/agentx_python.egg-info → agentx_python-0.6.16}/PKG-INFO +71 -38
- {agentx_python-0.6.14 → agentx_python-0.6.16}/README.md +70 -37
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/agentx.py +6 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/cli.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/_term.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/adapters/http_endpoint.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/adapters/precomputed.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/client.py +4 -4
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/datasets.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/evaluation_settings.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/models.py +10 -10
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/prompts.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/results.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/runner.py +12 -12
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/_traced_call.py +12 -4
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/anthropic.py +27 -12
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/autogen.py +5 -5
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/crewai.py +6 -6
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/google_adk.py +9 -9
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/google_genai.py +17 -5
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/langchain.py +10 -10
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/litellm.py +14 -7
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/llamaindex.py +6 -6
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/openai.py +20 -11
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/openai_agents.py +10 -10
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/monitor/client.py +1 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/monitor/models.py +11 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/monitor/online_evaluators.py +15 -2
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/monitor/patterns.py +3 -3
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/monitor/profile.py +8 -2
- agentx_python-0.6.16/agentx/outcomes.py +84 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/tracing/ingest_client.py +3 -3
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/tracing/tracer.py +157 -49
- agentx_python-0.6.16/agentx/version.py +1 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16/agentx_python.egg-info}/PKG-INFO +71 -38
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx_python.egg-info/SOURCES.txt +1 -0
- agentx_python-0.6.14/agentx/version.py +0 -1
- {agentx_python-0.6.14 → agentx_python-0.6.16}/LICENSE +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/__init__.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/__init__.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/adapters/__init__.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/adapters/raw.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/redaction.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/reporting.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/evaluations/tracing.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/exceptions.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/integrations/__init__.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/monitor/__init__.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/monitor/signals.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/py.typed +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/resources/__init__.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/resources/agent.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/resources/conversation.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/resources/workforce.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/tracing/__init__.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/tracing/ci_types.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx/util.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx_python.egg-info/dependency_links.txt +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx_python.egg-info/entry_points.txt +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx_python.egg-info/not-zip-safe +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx_python.egg-info/requires.txt +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/agentx_python.egg-info/top_level.txt +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/setup.cfg +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/setup.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/tests/test_integration.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/tests/test_integrations.py +0 -0
- {agentx_python-0.6.14 → agentx_python-0.6.16}/tests/test_span_tree.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentx-python
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.16
|
|
4
4
|
Summary: Official Python SDK for AgentX (https://www.agentx.so/)
|
|
5
5
|
Home-page: https://github.com/AgentX-ai/AgentX-python
|
|
6
6
|
Author: Robin Wang and AgentX Team
|
|
@@ -66,7 +66,7 @@ Dynamic: summary
|
|
|
66
66
|
[](https://pypi.org/project/agentx-python/)
|
|
67
67
|
[](LICENSE)
|
|
68
68
|
|
|
69
|
-
The official Python SDK for **[AgentX](https://app.agentx.so/)**
|
|
69
|
+
The official Python SDK for **[AgentX](https://app.agentx.so/)** - an evaluation, tracing, and monitoring framework for AI agents, plus a client for AgentX's own hosted agents.
|
|
70
70
|
|
|
71
71
|
Also see [SDK Developer Docs](https://developers.agentx.so), [API Reference Docs](https://docs.agentx.so/reference)
|
|
72
72
|
|
|
@@ -78,24 +78,24 @@ Also see [SDK Developer Docs](https://developers.agentx.so), [API Reference Docs
|
|
|
78
78
|
- [Installation](#installation)
|
|
79
79
|
- [Authentication](#authentication)
|
|
80
80
|
- [Quick start](#quick-start)
|
|
81
|
-
- [Custom agent evaluations](#custom-agent-evaluations)
|
|
82
|
-
- [Production tracing](#production-tracing)
|
|
83
|
-
- [Monitor](#monitor)
|
|
84
|
-
- [Self-host](#self-host)
|
|
85
|
-
- [Agents & conversations](#agents--conversations)
|
|
81
|
+
- [Custom agent evaluations](#custom-agent-evaluations) - LLM-as-a-judge, cosine / Jaccard similarity, any framework
|
|
82
|
+
- [Production tracing](#production-tracing) - record live agent runs from any framework
|
|
83
|
+
- [Monitor](#monitor) - automatic production monitoring, patterns and signals
|
|
84
|
+
- [Self-host](#self-host) - run Trace/Evaluate/Monitor on your own machine instead of the hosted dashboard
|
|
85
|
+
- [Agents & conversations](#agents--conversations) - chat with and orchestrate AgentX's own hosted agents
|
|
86
86
|
- [Links](#links)
|
|
87
87
|
|
|
88
88
|
---
|
|
89
89
|
|
|
90
90
|
## Why AgentX
|
|
91
91
|
|
|
92
|
-
- **Agent Evaluations**
|
|
93
|
-
- **Production tracing**
|
|
94
|
-
- **Monitor**
|
|
95
|
-
- **Prompt registry**
|
|
96
|
-
- **Self-host**
|
|
97
|
-
- **Bring any LLM**
|
|
98
|
-
- **AgentX's own hosted agents**
|
|
92
|
+
- **Agent Evaluations** - score **any** agent (LangChain, CrewAI, AutoGen, LlamaIndex, OpenAI, Anthropic, HTTP, or plain Python) against a dataset with LLM-as-a-judge ratings plus optional cosine, Jaccard, and BLEU/ROUGE similarity metrics. Configurable judge prompt/model, per-question judge guidelines, smoke testing for phrasing robustness, and a durable multi-judge analysis pass for a qualitative report.
|
|
93
|
+
- **Production tracing** - one decorator or context manager records every agent run (input, output, latency, tool calls, token usage, and a real span tree) into your workspace, for any framework.
|
|
94
|
+
- **Monitor** - check live traces against detection patterns or a sampled LLM judge, and read back triage-ready signals, no dashboard setup required.
|
|
95
|
+
- **Prompt registry** - make AgentX the source of truth for your own agent's prompts: pull a version at runtime, tag eval runs and live traces with it, let a judge propose a rewrite from your worst-rated results.
|
|
96
|
+
- **Self-host** - run the whole Trace/Evaluate/Monitor stack locally, bring your own LLM keys, no account required.
|
|
97
|
+
- **Bring any LLM** - works across major open and closed-source vendors, for evaluation, tracing, and AgentX's own hosted agents alike.
|
|
98
|
+
- **AgentX's own hosted agents** - a simple `Agent → Conversation → Message` mental model, chain-of-thought built in, multi-agent workforces, MCP support, and A2A publishing, for when you want AgentX to run the agent too, not just evaluate/trace/monitor it.
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
@@ -114,11 +114,11 @@ Requires Python 3.9 or newer.
|
|
|
114
114
|
Get your API key at [app.agentx.so](https://app.agentx.so), then either pass it inline or expose it as an environment variable.
|
|
115
115
|
|
|
116
116
|
```python
|
|
117
|
-
# Option A
|
|
117
|
+
# Option A - pass the key inline
|
|
118
118
|
from agentx import AgentX
|
|
119
119
|
client = AgentX(api_key="your-api-key-here")
|
|
120
120
|
|
|
121
|
-
# Option B
|
|
121
|
+
# Option B - set AGENTX_API_KEY in your environment, then:
|
|
122
122
|
client = AgentX.from_env()
|
|
123
123
|
```
|
|
124
124
|
|
|
@@ -126,7 +126,7 @@ client = AgentX.from_env()
|
|
|
126
126
|
|
|
127
127
|
## Quick start
|
|
128
128
|
|
|
129
|
-
Evaluate your own agent
|
|
129
|
+
Evaluate your own agent - any framework, or plain Python - against a dataset:
|
|
130
130
|
|
|
131
131
|
```python
|
|
132
132
|
from agentx import AgentX
|
|
@@ -154,7 +154,7 @@ That's it. The rest of this section covers building the dataset, framework adapt
|
|
|
154
154
|
|
|
155
155
|
## Custom agent evaluations
|
|
156
156
|
|
|
157
|
-
Evaluate **any** AI agent
|
|
157
|
+
Evaluate **any** AI agent - LangChain, CrewAI, AutoGen, LlamaIndex, OpenAI, Anthropic, HTTP endpoints, or plain Python - using AgentX as the scoring and reporting backend. Includes optional **cosine**, **Jaccard**, and **BLEU/ROUGE** similarity metrics alongside LLM-graded ratings.
|
|
158
158
|
|
|
159
159
|
```python
|
|
160
160
|
report = (
|
|
@@ -177,7 +177,7 @@ print(report.recommendations) # list of prioritized, actionable fixes
|
|
|
177
177
|
|
|
178
178
|
Ask a case's question several extra ways each run, LLM-paraphrased server-side, to catch agents that break on phrasing rather than substance, and override the judge's prompt/model per config, see [Smoke testing](EVALUATIONS.md#smoke-testing-phrasing-robustness) and [Configuring the judge](EVALUATIONS.md#configuring-the-judge) in the full guide.
|
|
179
179
|
|
|
180
|
-
Since AgentX doesn't own your agent's code, `client.evaluations.prompts` lets AgentX become your prompt's *source of truth* instead
|
|
180
|
+
Since AgentX doesn't own your agent's code, `client.evaluations.prompts` lets AgentX become your prompt's *source of truth* instead - the same problem LangSmith's Prompt Hub and Langfuse's Prompt Management solve. Pull a version at runtime, tag your eval runs (or live traces) with it, and let a judge propose a rewrite from your real worst-rated results - a human always has to approve before it publishes:
|
|
181
181
|
|
|
182
182
|
```python
|
|
183
183
|
prompt = client.evaluations.prompts.get("support-agent-system-prompt") # or prompt.id
|
|
@@ -189,15 +189,15 @@ client.evaluations.run(
|
|
|
189
189
|
).execute(my_agent_fn)
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
See [Prompt registry](EVALUATIONS.md#prompt-registry) in the full guide, or [self-host's docs](https://docs.agentx.so/self-host#prompt-
|
|
192
|
+
See [Prompt registry](EVALUATIONS.md#prompt-registry) in the full guide, or [self-host's docs](https://docs.agentx.so/self-host#prompt-management) for the "Suggest improvement" dashboard flow (self-host only - no hosted-SaaS equivalent yet).
|
|
193
193
|
|
|
194
|
-
See **[EVALUATIONS.md](EVALUATIONS.md)** for the full guide
|
|
194
|
+
See **[EVALUATIONS.md](EVALUATIONS.md)** for the full guide - dataset builder, framework adapters, similarity metrics, smoke testing, judge configuration, prompt registry, and the complete API reference.
|
|
195
195
|
|
|
196
196
|
---
|
|
197
197
|
|
|
198
198
|
## Production tracing
|
|
199
199
|
|
|
200
|
-
Record live agent runs into your workspace with a single decorator or context manager
|
|
200
|
+
Record live agent runs into your workspace with a single decorator or context manager - no changes to your agent's logic. Traces appear in the **Live Traces** tab and can be evaluated against your test datasets with [`tracer.evaluate_trace()`](TRACING.md#tracerevaluate_trace).
|
|
201
201
|
|
|
202
202
|
```python
|
|
203
203
|
from agentx import AgentX
|
|
@@ -226,9 +226,23 @@ with tracer.trace("rag-agent", framework="langchain") as span:
|
|
|
226
226
|
span.output = llm.invoke(f"Context: {kb_result}\n\nQuery: {query}")
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
+
To time a tool call and capture its failures automatically, wrap the execution itself instead of reporting it after the fact:
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
with tracer.trace_tool_call("search_knowledge_base", input=query) as t:
|
|
233
|
+
t.output = search_knowledge_base(query)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
An exception escaping the block records the call as failed (`success=False` plus the error text, which is what Monitor's built-in "Tool failure" check and the dashboard's Tool quality column read) and then propagates unchanged.
|
|
237
|
+
|
|
229
238
|
### Framework integrations
|
|
230
239
|
|
|
231
|
-
Each integration auto-captures LLM calls, tool calls, and token usage
|
|
240
|
+
Each integration auto-captures LLM calls, tool calls, and token usage - including prompt-caching
|
|
241
|
+
token counts (Anthropic's cache write/read, OpenAI/LiteLLM's cached tokens, Google GenAI's cached
|
|
242
|
+
content), reported as their own `cache_read_tokens`/`cache_write_tokens` fields alongside the
|
|
243
|
+
regular totals, no extra config needed. Self-host's cost estimate prices these separately from a
|
|
244
|
+
regular input token when you've set optional cache rates on that model. Install the matching
|
|
245
|
+
extra:
|
|
232
246
|
|
|
233
247
|
| Framework | Install | Integration |
|
|
234
248
|
| --------------------- | -------------------------------------------- | ------------------------ |
|
|
@@ -243,11 +257,11 @@ Each integration auto-captures LLM calls, tool calls, and token usage — instal
|
|
|
243
257
|
| LlamaIndex | `pip install "agentx-python[llamaindex]"` | `AgentXLlamaIndexHandler`|
|
|
244
258
|
| AutoGen | `pip install "agentx-python[autogen]"` | `AgentXAutoGenObserver` |
|
|
245
259
|
|
|
246
|
-
Or plain Python
|
|
260
|
+
Or plain Python - wrap any function with `@tracer.trace(...)` and it just works, no framework required.
|
|
247
261
|
|
|
248
|
-
Running specialist agents in parallel with a `ThreadPoolExecutor`? Wrap each worker body in `tracer.use_span(span)` so their steps land on the parent trace instead of becoming independent traces
|
|
262
|
+
Running specialist agents in parallel with a `ThreadPoolExecutor`? Wrap each worker body in `tracer.use_span(span)` so their steps land on the parent trace instead of becoming independent traces - see [TRACING.md](TRACING.md) for the full pattern.
|
|
249
263
|
|
|
250
|
-
See **[TRACING.md](TRACING.md)** for the complete guide
|
|
264
|
+
See **[TRACING.md](TRACING.md)** for the complete guide - session grouping, error handling, async support, and the full API reference.
|
|
251
265
|
|
|
252
266
|
---
|
|
253
267
|
|
|
@@ -297,13 +311,32 @@ evaluator = client.monitor.online_evaluators.builder(
|
|
|
297
311
|
client.monitor.online_evaluators.ratings(evaluator.id, window="7d")
|
|
298
312
|
```
|
|
299
313
|
|
|
314
|
+
An online evaluator can also judge **whole conversations** instead of single traces: pass `scope="session"` and the engine scores each multi-turn session once it's been idle for `idle_seconds`, re-scoring if the conversation resumes. And to close the loop with reality, `client.outcomes.report(...)` records what actually happened after the fact (a reopened ticket, a human confirmation) against a trace, feeding the dashboard's Judge Calibration view, which measures how often AgentX's automated verdicts agree with real outcomes. Both are self-host features.
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
client.monitor.online_evaluators.builder(
|
|
318
|
+
name="Conversation resolution",
|
|
319
|
+
evaluation_settings_id=settings.id,
|
|
320
|
+
scope="session", # judge the whole session, not each trace
|
|
321
|
+
idle_seconds=120, # score once the conversation has been quiet this long
|
|
322
|
+
alert_threshold=5,
|
|
323
|
+
).publish()
|
|
324
|
+
|
|
325
|
+
client.outcomes.report(
|
|
326
|
+
trace_id=trace_id,
|
|
327
|
+
outcome="reopened",
|
|
328
|
+
is_negative=True,
|
|
329
|
+
reason="Customer reopened the ticket within 3 days",
|
|
330
|
+
)
|
|
331
|
+
```
|
|
332
|
+
|
|
300
333
|
See **[TRACING.md](TRACING.md)** for the complete Monitor guide.
|
|
301
334
|
|
|
302
335
|
---
|
|
303
336
|
|
|
304
337
|
## Self-host
|
|
305
338
|
|
|
306
|
-
Prefer to run Trace/Evaluate/Monitor locally instead of the hosted dashboard
|
|
339
|
+
Prefer to run Trace/Evaluate/Monitor locally instead of the hosted dashboard - no account, bring your own LLM keys? This SDK ships a launcher for [AgentX-trace-eval](https://github.com/AgentX-ai/AgentX-trace-eval), a separate, portable governance engine:
|
|
307
340
|
|
|
308
341
|
```bash
|
|
309
342
|
agentx-trace-eval --dev
|
|
@@ -316,22 +349,22 @@ export AGENTX_API_BASE_URL=http://localhost:4700/api/v1
|
|
|
316
349
|
export AGENTX_API_KEY=<printed by agentx-trace-eval on first run>
|
|
317
350
|
```
|
|
318
351
|
|
|
319
|
-
`agentx-trace-eval` isn't this SDK's own code
|
|
352
|
+
`agentx-trace-eval` isn't this SDK's own code - the engine itself is a separate, compiled binary, downloaded on demand rather than bundled into this package, so installing `agentx-python` doesn't get any heavier for the (much more common) case of just talking to the hosted AgentX API. See that repo's README for what's included, and `AGENTX_INSTALL_DIR`/`AGENTX_TRACE_EVAL_VERSION`/`AGENTX_TRACE_EVAL_SKIP_WEB` env vars to control where/what it installs.
|
|
320
353
|
|
|
321
354
|
---
|
|
322
355
|
|
|
323
356
|
## Agents & conversations
|
|
324
357
|
|
|
325
|
-
Beyond evaluation, tracing, and monitoring, this SDK is also a client for AgentX's own hosted agents
|
|
358
|
+
Beyond evaluation, tracing, and monitoring, this SDK is also a client for AgentX's own hosted agents - build, chat with, and orchestrate them directly.
|
|
326
359
|
|
|
327
360
|
```python
|
|
328
361
|
agent = client.list_agents()[0]
|
|
329
362
|
conversation = agent.new_conversation()
|
|
330
363
|
|
|
331
|
-
# Blocking
|
|
364
|
+
# Blocking - returns the full response once it's ready
|
|
332
365
|
print(conversation.chat("What can you help me with?"))
|
|
333
366
|
|
|
334
|
-
# Streaming
|
|
367
|
+
# Streaming - yields ChatResponse objects as the model produces them
|
|
335
368
|
for chunk in conversation.chat_stream("Hello!"):
|
|
336
369
|
if chunk.text:
|
|
337
370
|
print(chunk.text, end="")
|
|
@@ -354,10 +387,10 @@ for chunk in workforce.chat_stream(conversation.id, "How can you help me with th
|
|
|
354
387
|
|
|
355
388
|
## Links
|
|
356
389
|
|
|
357
|
-
- **Dashboard**
|
|
358
|
-
- **Website**
|
|
359
|
-
- **PyPI**
|
|
360
|
-
- **Tracing docs**
|
|
361
|
-
- **Evaluations docs**
|
|
362
|
-
- **Monitor docs**
|
|
363
|
-
- **Self-host**
|
|
390
|
+
- **Dashboard** - [app.agentx.so](https://app.agentx.so)
|
|
391
|
+
- **Website** - [agentx.so](https://www.agentx.so/)
|
|
392
|
+
- **PyPI** - [agentx-python](https://pypi.org/project/agentx-python/)
|
|
393
|
+
- **Tracing docs** - [TRACING.md](TRACING.md)
|
|
394
|
+
- **Evaluations docs** - [EVALUATIONS.md](EVALUATIONS.md)
|
|
395
|
+
- **Monitor docs** - [docs.agentx.so/sdk/monitor](https://docs.agentx.so/sdk/monitor)
|
|
396
|
+
- **Self-host** - [AgentX-trace-eval](https://github.com/AgentX-ai/AgentX-trace-eval)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://pypi.org/project/agentx-python/)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
The official Python SDK for **[AgentX](https://app.agentx.so/)**
|
|
7
|
+
The official Python SDK for **[AgentX](https://app.agentx.so/)** - an evaluation, tracing, and monitoring framework for AI agents, plus a client for AgentX's own hosted agents.
|
|
8
8
|
|
|
9
9
|
Also see [SDK Developer Docs](https://developers.agentx.so), [API Reference Docs](https://docs.agentx.so/reference)
|
|
10
10
|
|
|
@@ -16,24 +16,24 @@ Also see [SDK Developer Docs](https://developers.agentx.so), [API Reference Docs
|
|
|
16
16
|
- [Installation](#installation)
|
|
17
17
|
- [Authentication](#authentication)
|
|
18
18
|
- [Quick start](#quick-start)
|
|
19
|
-
- [Custom agent evaluations](#custom-agent-evaluations)
|
|
20
|
-
- [Production tracing](#production-tracing)
|
|
21
|
-
- [Monitor](#monitor)
|
|
22
|
-
- [Self-host](#self-host)
|
|
23
|
-
- [Agents & conversations](#agents--conversations)
|
|
19
|
+
- [Custom agent evaluations](#custom-agent-evaluations) - LLM-as-a-judge, cosine / Jaccard similarity, any framework
|
|
20
|
+
- [Production tracing](#production-tracing) - record live agent runs from any framework
|
|
21
|
+
- [Monitor](#monitor) - automatic production monitoring, patterns and signals
|
|
22
|
+
- [Self-host](#self-host) - run Trace/Evaluate/Monitor on your own machine instead of the hosted dashboard
|
|
23
|
+
- [Agents & conversations](#agents--conversations) - chat with and orchestrate AgentX's own hosted agents
|
|
24
24
|
- [Links](#links)
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
28
|
## Why AgentX
|
|
29
29
|
|
|
30
|
-
- **Agent Evaluations**
|
|
31
|
-
- **Production tracing**
|
|
32
|
-
- **Monitor**
|
|
33
|
-
- **Prompt registry**
|
|
34
|
-
- **Self-host**
|
|
35
|
-
- **Bring any LLM**
|
|
36
|
-
- **AgentX's own hosted agents**
|
|
30
|
+
- **Agent Evaluations** - score **any** agent (LangChain, CrewAI, AutoGen, LlamaIndex, OpenAI, Anthropic, HTTP, or plain Python) against a dataset with LLM-as-a-judge ratings plus optional cosine, Jaccard, and BLEU/ROUGE similarity metrics. Configurable judge prompt/model, per-question judge guidelines, smoke testing for phrasing robustness, and a durable multi-judge analysis pass for a qualitative report.
|
|
31
|
+
- **Production tracing** - one decorator or context manager records every agent run (input, output, latency, tool calls, token usage, and a real span tree) into your workspace, for any framework.
|
|
32
|
+
- **Monitor** - check live traces against detection patterns or a sampled LLM judge, and read back triage-ready signals, no dashboard setup required.
|
|
33
|
+
- **Prompt registry** - make AgentX the source of truth for your own agent's prompts: pull a version at runtime, tag eval runs and live traces with it, let a judge propose a rewrite from your worst-rated results.
|
|
34
|
+
- **Self-host** - run the whole Trace/Evaluate/Monitor stack locally, bring your own LLM keys, no account required.
|
|
35
|
+
- **Bring any LLM** - works across major open and closed-source vendors, for evaluation, tracing, and AgentX's own hosted agents alike.
|
|
36
|
+
- **AgentX's own hosted agents** - a simple `Agent → Conversation → Message` mental model, chain-of-thought built in, multi-agent workforces, MCP support, and A2A publishing, for when you want AgentX to run the agent too, not just evaluate/trace/monitor it.
|
|
37
37
|
|
|
38
38
|
---
|
|
39
39
|
|
|
@@ -52,11 +52,11 @@ Requires Python 3.9 or newer.
|
|
|
52
52
|
Get your API key at [app.agentx.so](https://app.agentx.so), then either pass it inline or expose it as an environment variable.
|
|
53
53
|
|
|
54
54
|
```python
|
|
55
|
-
# Option A
|
|
55
|
+
# Option A - pass the key inline
|
|
56
56
|
from agentx import AgentX
|
|
57
57
|
client = AgentX(api_key="your-api-key-here")
|
|
58
58
|
|
|
59
|
-
# Option B
|
|
59
|
+
# Option B - set AGENTX_API_KEY in your environment, then:
|
|
60
60
|
client = AgentX.from_env()
|
|
61
61
|
```
|
|
62
62
|
|
|
@@ -64,7 +64,7 @@ client = AgentX.from_env()
|
|
|
64
64
|
|
|
65
65
|
## Quick start
|
|
66
66
|
|
|
67
|
-
Evaluate your own agent
|
|
67
|
+
Evaluate your own agent - any framework, or plain Python - against a dataset:
|
|
68
68
|
|
|
69
69
|
```python
|
|
70
70
|
from agentx import AgentX
|
|
@@ -92,7 +92,7 @@ That's it. The rest of this section covers building the dataset, framework adapt
|
|
|
92
92
|
|
|
93
93
|
## Custom agent evaluations
|
|
94
94
|
|
|
95
|
-
Evaluate **any** AI agent
|
|
95
|
+
Evaluate **any** AI agent - LangChain, CrewAI, AutoGen, LlamaIndex, OpenAI, Anthropic, HTTP endpoints, or plain Python - using AgentX as the scoring and reporting backend. Includes optional **cosine**, **Jaccard**, and **BLEU/ROUGE** similarity metrics alongside LLM-graded ratings.
|
|
96
96
|
|
|
97
97
|
```python
|
|
98
98
|
report = (
|
|
@@ -115,7 +115,7 @@ print(report.recommendations) # list of prioritized, actionable fixes
|
|
|
115
115
|
|
|
116
116
|
Ask a case's question several extra ways each run, LLM-paraphrased server-side, to catch agents that break on phrasing rather than substance, and override the judge's prompt/model per config, see [Smoke testing](EVALUATIONS.md#smoke-testing-phrasing-robustness) and [Configuring the judge](EVALUATIONS.md#configuring-the-judge) in the full guide.
|
|
117
117
|
|
|
118
|
-
Since AgentX doesn't own your agent's code, `client.evaluations.prompts` lets AgentX become your prompt's *source of truth* instead
|
|
118
|
+
Since AgentX doesn't own your agent's code, `client.evaluations.prompts` lets AgentX become your prompt's *source of truth* instead - the same problem LangSmith's Prompt Hub and Langfuse's Prompt Management solve. Pull a version at runtime, tag your eval runs (or live traces) with it, and let a judge propose a rewrite from your real worst-rated results - a human always has to approve before it publishes:
|
|
119
119
|
|
|
120
120
|
```python
|
|
121
121
|
prompt = client.evaluations.prompts.get("support-agent-system-prompt") # or prompt.id
|
|
@@ -127,15 +127,15 @@ client.evaluations.run(
|
|
|
127
127
|
).execute(my_agent_fn)
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
See [Prompt registry](EVALUATIONS.md#prompt-registry) in the full guide, or [self-host's docs](https://docs.agentx.so/self-host#prompt-
|
|
130
|
+
See [Prompt registry](EVALUATIONS.md#prompt-registry) in the full guide, or [self-host's docs](https://docs.agentx.so/self-host#prompt-management) for the "Suggest improvement" dashboard flow (self-host only - no hosted-SaaS equivalent yet).
|
|
131
131
|
|
|
132
|
-
See **[EVALUATIONS.md](EVALUATIONS.md)** for the full guide
|
|
132
|
+
See **[EVALUATIONS.md](EVALUATIONS.md)** for the full guide - dataset builder, framework adapters, similarity metrics, smoke testing, judge configuration, prompt registry, and the complete API reference.
|
|
133
133
|
|
|
134
134
|
---
|
|
135
135
|
|
|
136
136
|
## Production tracing
|
|
137
137
|
|
|
138
|
-
Record live agent runs into your workspace with a single decorator or context manager
|
|
138
|
+
Record live agent runs into your workspace with a single decorator or context manager - no changes to your agent's logic. Traces appear in the **Live Traces** tab and can be evaluated against your test datasets with [`tracer.evaluate_trace()`](TRACING.md#tracerevaluate_trace).
|
|
139
139
|
|
|
140
140
|
```python
|
|
141
141
|
from agentx import AgentX
|
|
@@ -164,9 +164,23 @@ with tracer.trace("rag-agent", framework="langchain") as span:
|
|
|
164
164
|
span.output = llm.invoke(f"Context: {kb_result}\n\nQuery: {query}")
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
+
To time a tool call and capture its failures automatically, wrap the execution itself instead of reporting it after the fact:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
with tracer.trace_tool_call("search_knowledge_base", input=query) as t:
|
|
171
|
+
t.output = search_knowledge_base(query)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
An exception escaping the block records the call as failed (`success=False` plus the error text, which is what Monitor's built-in "Tool failure" check and the dashboard's Tool quality column read) and then propagates unchanged.
|
|
175
|
+
|
|
167
176
|
### Framework integrations
|
|
168
177
|
|
|
169
|
-
Each integration auto-captures LLM calls, tool calls, and token usage
|
|
178
|
+
Each integration auto-captures LLM calls, tool calls, and token usage - including prompt-caching
|
|
179
|
+
token counts (Anthropic's cache write/read, OpenAI/LiteLLM's cached tokens, Google GenAI's cached
|
|
180
|
+
content), reported as their own `cache_read_tokens`/`cache_write_tokens` fields alongside the
|
|
181
|
+
regular totals, no extra config needed. Self-host's cost estimate prices these separately from a
|
|
182
|
+
regular input token when you've set optional cache rates on that model. Install the matching
|
|
183
|
+
extra:
|
|
170
184
|
|
|
171
185
|
| Framework | Install | Integration |
|
|
172
186
|
| --------------------- | -------------------------------------------- | ------------------------ |
|
|
@@ -181,11 +195,11 @@ Each integration auto-captures LLM calls, tool calls, and token usage — instal
|
|
|
181
195
|
| LlamaIndex | `pip install "agentx-python[llamaindex]"` | `AgentXLlamaIndexHandler`|
|
|
182
196
|
| AutoGen | `pip install "agentx-python[autogen]"` | `AgentXAutoGenObserver` |
|
|
183
197
|
|
|
184
|
-
Or plain Python
|
|
198
|
+
Or plain Python - wrap any function with `@tracer.trace(...)` and it just works, no framework required.
|
|
185
199
|
|
|
186
|
-
Running specialist agents in parallel with a `ThreadPoolExecutor`? Wrap each worker body in `tracer.use_span(span)` so their steps land on the parent trace instead of becoming independent traces
|
|
200
|
+
Running specialist agents in parallel with a `ThreadPoolExecutor`? Wrap each worker body in `tracer.use_span(span)` so their steps land on the parent trace instead of becoming independent traces - see [TRACING.md](TRACING.md) for the full pattern.
|
|
187
201
|
|
|
188
|
-
See **[TRACING.md](TRACING.md)** for the complete guide
|
|
202
|
+
See **[TRACING.md](TRACING.md)** for the complete guide - session grouping, error handling, async support, and the full API reference.
|
|
189
203
|
|
|
190
204
|
---
|
|
191
205
|
|
|
@@ -235,13 +249,32 @@ evaluator = client.monitor.online_evaluators.builder(
|
|
|
235
249
|
client.monitor.online_evaluators.ratings(evaluator.id, window="7d")
|
|
236
250
|
```
|
|
237
251
|
|
|
252
|
+
An online evaluator can also judge **whole conversations** instead of single traces: pass `scope="session"` and the engine scores each multi-turn session once it's been idle for `idle_seconds`, re-scoring if the conversation resumes. And to close the loop with reality, `client.outcomes.report(...)` records what actually happened after the fact (a reopened ticket, a human confirmation) against a trace, feeding the dashboard's Judge Calibration view, which measures how often AgentX's automated verdicts agree with real outcomes. Both are self-host features.
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
client.monitor.online_evaluators.builder(
|
|
256
|
+
name="Conversation resolution",
|
|
257
|
+
evaluation_settings_id=settings.id,
|
|
258
|
+
scope="session", # judge the whole session, not each trace
|
|
259
|
+
idle_seconds=120, # score once the conversation has been quiet this long
|
|
260
|
+
alert_threshold=5,
|
|
261
|
+
).publish()
|
|
262
|
+
|
|
263
|
+
client.outcomes.report(
|
|
264
|
+
trace_id=trace_id,
|
|
265
|
+
outcome="reopened",
|
|
266
|
+
is_negative=True,
|
|
267
|
+
reason="Customer reopened the ticket within 3 days",
|
|
268
|
+
)
|
|
269
|
+
```
|
|
270
|
+
|
|
238
271
|
See **[TRACING.md](TRACING.md)** for the complete Monitor guide.
|
|
239
272
|
|
|
240
273
|
---
|
|
241
274
|
|
|
242
275
|
## Self-host
|
|
243
276
|
|
|
244
|
-
Prefer to run Trace/Evaluate/Monitor locally instead of the hosted dashboard
|
|
277
|
+
Prefer to run Trace/Evaluate/Monitor locally instead of the hosted dashboard - no account, bring your own LLM keys? This SDK ships a launcher for [AgentX-trace-eval](https://github.com/AgentX-ai/AgentX-trace-eval), a separate, portable governance engine:
|
|
245
278
|
|
|
246
279
|
```bash
|
|
247
280
|
agentx-trace-eval --dev
|
|
@@ -254,22 +287,22 @@ export AGENTX_API_BASE_URL=http://localhost:4700/api/v1
|
|
|
254
287
|
export AGENTX_API_KEY=<printed by agentx-trace-eval on first run>
|
|
255
288
|
```
|
|
256
289
|
|
|
257
|
-
`agentx-trace-eval` isn't this SDK's own code
|
|
290
|
+
`agentx-trace-eval` isn't this SDK's own code - the engine itself is a separate, compiled binary, downloaded on demand rather than bundled into this package, so installing `agentx-python` doesn't get any heavier for the (much more common) case of just talking to the hosted AgentX API. See that repo's README for what's included, and `AGENTX_INSTALL_DIR`/`AGENTX_TRACE_EVAL_VERSION`/`AGENTX_TRACE_EVAL_SKIP_WEB` env vars to control where/what it installs.
|
|
258
291
|
|
|
259
292
|
---
|
|
260
293
|
|
|
261
294
|
## Agents & conversations
|
|
262
295
|
|
|
263
|
-
Beyond evaluation, tracing, and monitoring, this SDK is also a client for AgentX's own hosted agents
|
|
296
|
+
Beyond evaluation, tracing, and monitoring, this SDK is also a client for AgentX's own hosted agents - build, chat with, and orchestrate them directly.
|
|
264
297
|
|
|
265
298
|
```python
|
|
266
299
|
agent = client.list_agents()[0]
|
|
267
300
|
conversation = agent.new_conversation()
|
|
268
301
|
|
|
269
|
-
# Blocking
|
|
302
|
+
# Blocking - returns the full response once it's ready
|
|
270
303
|
print(conversation.chat("What can you help me with?"))
|
|
271
304
|
|
|
272
|
-
# Streaming
|
|
305
|
+
# Streaming - yields ChatResponse objects as the model produces them
|
|
273
306
|
for chunk in conversation.chat_stream("Hello!"):
|
|
274
307
|
if chunk.text:
|
|
275
308
|
print(chunk.text, end="")
|
|
@@ -292,10 +325,10 @@ for chunk in workforce.chat_stream(conversation.id, "How can you help me with th
|
|
|
292
325
|
|
|
293
326
|
## Links
|
|
294
327
|
|
|
295
|
-
- **Dashboard**
|
|
296
|
-
- **Website**
|
|
297
|
-
- **PyPI**
|
|
298
|
-
- **Tracing docs**
|
|
299
|
-
- **Evaluations docs**
|
|
300
|
-
- **Monitor docs**
|
|
301
|
-
- **Self-host**
|
|
328
|
+
- **Dashboard** - [app.agentx.so](https://app.agentx.so)
|
|
329
|
+
- **Website** - [agentx.so](https://www.agentx.so/)
|
|
330
|
+
- **PyPI** - [agentx-python](https://pypi.org/project/agentx-python/)
|
|
331
|
+
- **Tracing docs** - [TRACING.md](TRACING.md)
|
|
332
|
+
- **Evaluations docs** - [EVALUATIONS.md](EVALUATIONS.md)
|
|
333
|
+
- **Monitor docs** - [docs.agentx.so/sdk/monitor](https://docs.agentx.so/sdk/monitor)
|
|
334
|
+
- **Self-host** - [AgentX-trace-eval](https://github.com/AgentX-ai/AgentX-trace-eval)
|
|
@@ -54,6 +54,12 @@ class AgentX:
|
|
|
54
54
|
workspace_id=self.workspace_id,
|
|
55
55
|
)
|
|
56
56
|
|
|
57
|
+
from agentx.outcomes import OutcomesClient
|
|
58
|
+
|
|
59
|
+
# Report real, after-the-fact outcomes ("the ticket got reopened") against traces - the
|
|
60
|
+
# ground truth behind the dashboard's Judge Calibration card. Self-host only.
|
|
61
|
+
self.outcomes = OutcomesClient(api_key=self.api_key)
|
|
62
|
+
|
|
57
63
|
_ingest_client = IngestClient(
|
|
58
64
|
api_key=self.api_key,
|
|
59
65
|
sdk_version=VERSION,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
`agentx-trace-eval`
|
|
2
|
+
`agentx-trace-eval` - thin launcher for AgentX's self-hostable governance engine (Trace,
|
|
3
3
|
Evaluate, Monitor), published separately at github.com/AgentX-ai/AgentX-trace-eval (a Go CLI
|
|
4
4
|
wrapping a Bun-compiled TypeScript engine, not Python). That compiled engine binary is tens of
|
|
5
5
|
megabytes; most `pip install agentx-python` installs are just this SDK talking to the hosted
|
|
@@ -12,7 +12,7 @@ from agentx.evaluations.results import normalize_error, normalize_result
|
|
|
12
12
|
class HttpEndpointAdapter:
|
|
13
13
|
"""
|
|
14
14
|
Calls a user-hosted HTTP endpoint for each evaluation case.
|
|
15
|
-
The SDK (running locally) makes the request
|
|
15
|
+
The SDK (running locally) makes the request - the AgentX API never
|
|
16
16
|
touches the customer's endpoint.
|
|
17
17
|
|
|
18
18
|
The endpoint receives a POST with::
|
|
@@ -8,7 +8,7 @@ from agentx.evaluations.results import normalize_result
|
|
|
8
8
|
|
|
9
9
|
class PrecomputedAdapter:
|
|
10
10
|
"""
|
|
11
|
-
Adapter for pre-computed outputs
|
|
11
|
+
Adapter for pre-computed outputs - useful when you already have agent
|
|
12
12
|
responses and just want AgentX to score them.
|
|
13
13
|
|
|
14
14
|
Accepts a list or dict keyed by case_id::
|
|
@@ -57,7 +57,7 @@ class EvaluationsClient:
|
|
|
57
57
|
raise AgentXAuthError("AGENTX_API_KEY is required")
|
|
58
58
|
self._api_key = api_key
|
|
59
59
|
self._sdk_version = sdk_version
|
|
60
|
-
# Falls back to the caller's default workspace server-side when unset
|
|
60
|
+
# Falls back to the caller's default workspace server-side when unset - see
|
|
61
61
|
# _with_workspace(). Without this, dataset/settings/run creation silently land in
|
|
62
62
|
# whatever workspace the API key's user defaults to, not the one the caller intended.
|
|
63
63
|
self._workspace_id = workspace_id
|
|
@@ -139,7 +139,7 @@ class EvaluationsClient:
|
|
|
139
139
|
# ------------------------------------------------------------------
|
|
140
140
|
|
|
141
141
|
def list_models(self, provider: Optional[str] = None) -> List[ModelInfo]:
|
|
142
|
-
"""List the LLM models AgentX supports
|
|
142
|
+
"""List the LLM models AgentX supports - the same set selectable for
|
|
143
143
|
the Sovereignty & Portability Index. Pass ``provider`` (e.g. "Google")
|
|
144
144
|
to filter."""
|
|
145
145
|
params = {"provider": provider} if provider else None
|
|
@@ -169,7 +169,7 @@ class EvaluationsClient:
|
|
|
169
169
|
return Dataset(**data)
|
|
170
170
|
|
|
171
171
|
# ------------------------------------------------------------------
|
|
172
|
-
# Evaluation Settings endpoints
|
|
172
|
+
# Evaluation Settings endpoints - standalone grading config, reusable
|
|
173
173
|
# across datasets.
|
|
174
174
|
# ------------------------------------------------------------------
|
|
175
175
|
|
|
@@ -199,7 +199,7 @@ class EvaluationsClient:
|
|
|
199
199
|
return EvaluationSettings(**data)
|
|
200
200
|
|
|
201
201
|
# ------------------------------------------------------------------
|
|
202
|
-
# Prompt registry endpoints
|
|
202
|
+
# Prompt registry endpoints - see agentx.evaluations.prompts.PromptClient for the concept
|
|
203
203
|
# (the external-agent analog to native autotune). Deliberately read-mostly: no publish here,
|
|
204
204
|
# a new version only ever comes from the dashboard's human-approved propose/publish flow.
|
|
205
205
|
# ------------------------------------------------------------------
|
|
@@ -67,7 +67,7 @@ class DatasetBuilder:
|
|
|
67
67
|
self._payload["bleuScore"] = {"enabled": True}
|
|
68
68
|
if rouge_score:
|
|
69
69
|
self._payload["rougeScore"] = {"enabled": True}
|
|
70
|
-
# Sovereignty & Portability
|
|
70
|
+
# Sovereignty & Portability - the models to compare on this dataset (use
|
|
71
71
|
# client.evaluations.list_models() to discover valid ids).
|
|
72
72
|
if sovereignty_models:
|
|
73
73
|
self._payload["sovereigntyIndex"] = {
|
|
@@ -61,7 +61,7 @@ class EvaluationSettingsBuilder:
|
|
|
61
61
|
self._payload["bleuScore"] = {"enabled": True}
|
|
62
62
|
if rouge_score:
|
|
63
63
|
self._payload["rougeScore"] = {"enabled": True}
|
|
64
|
-
# Sovereignty & Portability
|
|
64
|
+
# Sovereignty & Portability - the models to compare when this config runs
|
|
65
65
|
# (use client.evaluations.list_models() to discover valid ids).
|
|
66
66
|
if sovereignty_models:
|
|
67
67
|
self._payload["sovereigntyIndex"] = {
|