agrag.eval.trajectory.SpanCapture
SpanCapture() -> None
Capture one agent run's spans for read_trajectory.
Use as a context manager around agent.ainvoke and read the run with
trajectory() after. Each capture has its own provider and exporter,
so captures never share spans and the global provider is unchanged.
Example
with SpanCapture() as capture:
agent = build_agent(engine, settings, tracer=capture.tracer)
result = await agent.ainvoke({"messages": [...]})
trajectory = capture.trajectory()
Functions:
- trajectory – Read the captured spans as a trajectory.
Attributes:
- tracer (
Tracer) – The tracer to pass astracer=tobuild_agent.
tracer
tracer: Tracer
The tracer to pass as tracer= to build_agent.
Returns:
Tracer– A tracer bound to this capture's private provider.
trajectory
trajectory() -> Trajectory
Read the captured spans as a trajectory.
Returns:
Trajectory– The trajectory read from the spans captured so far.