Tracer captures your agent’s inputs, outputs, latency, and tool calls — with a single decorator or context manager. Traces appear in the Live Traces tab and can be evaluated against your test datasets.
Decorator
The simplest usage. AgentX captures function arguments asinput, the return value as output, and wall-clock time as latencyMs.
Context manager
Use when you need to set input/output manually or record tool calls mid-span._TraceSpan attributes and methods
| Name | Description |
|---|---|
span.input = value | Override the captured input |
span.output = value | Set the output (required in context manager mode) |
span.add_tool_call(name, *, input, output, latency_ms) | Record a tool call made during this span |
span.set_error(message) | Mark the span as failed with a custom error message |
tracer.trace() parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Agent or operation label shown in the UI |
framework | str | "langchain", "crewai", "openai-agents", "anthropic", or custom |
model | str | LLM model used, e.g. "gpt-4o", "claude-sonnet-4-6" |
session_id | str | Groups traces from the same user session or thread |
metadata | dict | Arbitrary key-value metadata (not indexed, max 16 KB) |
Framework examples
Session grouping
Usesession_id to link traces from the same user conversation:
Error handling
Exceptions inside a traced function are captured as theerror field and re-raised — the trace is still submitted:
Flushing
Traces are sent in a background thread. Callflush() before process exit in scripts:
Evaluating a trace
Score a previously recorded trace against a dataset without re-running the agent:Limits
| Limit | Value |
|---|---|
| Traces per minute per API key | 300 |
| Max tool calls per trace | 50 |
Max input / output size | 1 MB each |
Max metadata size | 16 KB |

