You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add tracing and evaluations to the JS SDK (parity with agentx-python)
The JS SDK only covered agents, conversations and workforces. Everything
AgentX is actually used for from Python - tracing runs into Observe, and the
Custom Agent Evaluations lifecycle - had no JS equivalent. This ports both,
keeping the wire format byte-for-byte identical to agentx-python so the same
engine routes serve both SDKs.
Tracing (src/tracing):
- Tracer.withSpan/trace/wrap/useSpan, with real parent/child span rows and a
shared session id. Context propagates through AsyncLocalStorage, the JS
equivalent of the Python tracer's thread-local span stack.
- traceToolCall/recordToolCall and traceRetrieval/recordRetrieval, including
the flat tool_calls mirror on the root that the engine's "Tool failure"
check and the dashboard's Tool quality column read, and the
metadata.kind = "retrieval" marker RAG judges look for.
- span.childSpan()/recordLlmCall() for callers with their own timing.
- Queued, non-blocking delivery with retry/backoff, warn-once on delivery
failure, flush(), and a beforeExit drain (Node has no daemon thread).
- sync: true spans return the ingested trace id, so a result can link to it.
- CI/CD lifecycle: runEval(), createCiRun/submitResult/finalizeCiRun/getCiRun
and evaluateTrace().
Evaluations (src/evaluations):
- datasets.builder()/fromCsv()/fromRows()/get()/list(), settings.builder(),
including judge overrides, similarity metrics, sovereignty models, smoke
tests, expected trajectories and expected retrieval context.
- run().execute().finalize().analyze()/.gate() as a thenable chain, with the
same case fan-out (numberOfRequests x sovereignty models + server-generated
smoke-test variants), idempotency keys, batch sizing and live rating stats.
- Raw callable, precomputed and HTTP endpoint adapters; result normalisation
and metadata redaction ported as-is.
- Self-host fallback for analyze/analyze-status/report onto the dashboard
router, matching the Python client's 404-probe-and-cache behaviour.
- Report printing and progress output mirroring the Python CLI experience.
Client:
- client.tracer and client.evaluations (lazily constructed), ping(),
AgentX.fromEnv(), and an options argument for baseUrl/workspaceId.
- Resource URLs now resolve through apiBase(), so AGENTX_API_BASE_URL points
the whole SDK at a self-hosted engine.
Backward compatible: every existing export, class, method and signature is
unchanged - the constructor only widens to accept an optional options object,
and everything else is additive.
npm test now runs test-tracing-eval.ts, a hermetic stub-server test that
asserts the exact payloads both surfaces send.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
awaitclient.ping(); // verifies the URL and key before anything is traced
321
+
```
322
+
150
323
## TypeScript Support
151
324
152
325
This SDK is written in TypeScript and provides full type definitions. All classes, interfaces, and methods are properly typed for better development experience.
@@ -160,13 +333,45 @@ The main client class for interacting with the AgentX API.
160
333
#### Constructor
161
334
162
335
-`new AgentX(apiKey?: string)` - Creates a new AgentX client instance
0 commit comments