collector
collector
¶
TraceCollector — wraps any BaseAgent to record interaction traces.
Classes¶
TraceCollector
¶
TraceCollector(agent: BaseAgent, *, store: Optional[TraceStore] = None, bus: Optional[EventBus] = None)
Wraps a BaseAgent and records a :class:Trace for every run().
The collector subscribes to the EventBus to capture inference, tool,
and memory events emitted during agent execution, converting them into
TraceStep objects. When the agent finishes, the complete Trace
is persisted to the TraceStore and published on the bus.
Usage::
agent = OrchestratorAgent(engine, model, tools=tools, bus=bus)
collector = TraceCollector(agent, store=trace_store, bus=bus)
result = collector.run("What is 2+2?")
# Trace is automatically saved to trace_store
Source code in src/openjarvis/traces/collector.py
Attributes¶
last_trace
property
¶
last_trace: Optional[Trace]
Return the trace from the most recent run(), if available.
Functions¶
run
¶
run(input: str, context: Optional[AgentContext] = None, **kwargs: Any) -> AgentResult
Execute the wrapped agent and record a trace.