Skip to main content
TelemetryEvent is the SDK’s primitive for product telemetry — user actions, tool calls, agent decisions, anything you’d send to a product analytics tool. Events are pushed independently of trajectories, and can be correlated to them via trace_id (see Linking Events to Trajectories).

Quickstart

For telemetry-only usage, only project_id and trajectory_api_key are required in init() — no provider credentials needed.

Constructing Events

TelemetryEvent is a frozen dataclass. Only event_type and session_id are required; every other field has a sensible default.

Idempotency

event_id is the idempotency key. The default UUID4 means re-runs of the same code produce different IDs (and the backend will accept both as separate events). For at-least-once delivery pipelines — webhooks, retries, replay from a queue — set event_id deterministically from your own primary key so duplicate pushes are coalesced server-side:
Re-pushing the same event_id is a no-op on the backend.

Pushing Events

tj.push_events(events) validates, chunks, retries, and pushes a batch of events.
The call returns a PushResult:
Invalid events are dropped with a logged warning rather than raising. This matches the pattern used by upload() for empty trajectories: bad inputs don’t poison a whole batch. Inspect result.errors to see what was rejected.

Producing Events via TraceContext

When you’re already inside a TraceContext (the recommended path for SDK-instrumented agent runs), use trace.event(...) so events automatically inherit the trace_id:
TraceContext.event(...) sets session_id = trace_id automatically. Override either via the keyword arguments if you need a different grouping. See Linking Events to Trajectories for the full workflow, including tj.upload_trace() which uploads a trajectory and pushes correlated events in one atomic call.

Linking Events to Trajectories

The trace_id correlation story end-to-end.

API Reference

Full signatures for push_events, TelemetryEvent, PushResult.