Index
traces
¶
Trace system — full interaction-level recording and analysis.
The trace system captures the complete sequence of steps an agent takes to handle a query. Unlike telemetry (which records per-inference metrics), traces record the decision-making process: which model was selected, what memory was retrieved, which tools were called, and the final response.
Traces are the primary input to the learning system.
Classes¶
TraceAnalyzer
¶
TraceAnalyzer(store: TraceStore)
Read-only query layer over a :class:TraceStore.
Computes aggregated statistics from stored traces, providing the inputs that the learning system needs to update routing policies.
Source code in src/openjarvis/traces/analyzer.py
Functions¶
summary
¶
summary(*, since: Optional[float] = None, until: Optional[float] = None) -> TraceSummary
Compute an overall summary of all traces in the time range.
Source code in src/openjarvis/traces/analyzer.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
per_route_stats
¶
per_route_stats(*, since: Optional[float] = None, until: Optional[float] = None) -> List[RouteStats]
Compute stats grouped by (model, agent) routing decisions.
Source code in src/openjarvis/traces/analyzer.py
per_tool_stats
¶
per_tool_stats(*, since: Optional[float] = None, until: Optional[float] = None) -> List[ToolStats]
Compute stats grouped by tool name.
Source code in src/openjarvis/traces/analyzer.py
traces_for_query_type
¶
traces_for_query_type(*, has_code: bool = False, min_length: Optional[int] = None, max_length: Optional[int] = None, since: Optional[float] = None, until: Optional[float] = None) -> List[Trace]
Retrieve traces matching query characteristics.
Useful for the learning system to find traces similar to a new query and learn which routing decisions worked best.
Source code in src/openjarvis/traces/analyzer.py
export_traces
¶
export_traces(*, since: Optional[float] = None, until: Optional[float] = None, limit: int = 1000) -> List[Dict[str, Any]]
Export traces as plain dicts (for JSON serialization).
Source code in src/openjarvis/traces/analyzer.py
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.
Source code in src/openjarvis/traces/collector.py
TraceStore
¶
Append-only SQLite store for interaction traces.
Source code in src/openjarvis/traces/store.py
Functions¶
save
¶
save(trace: Trace) -> None
Persist a complete trace with all its steps.
Source code in src/openjarvis/traces/store.py
get
¶
get(trace_id: str) -> Optional[Trace]
Retrieve a trace by id, or None if not found.
Source code in src/openjarvis/traces/store.py
list_traces
¶
list_traces(*, agent: Optional[str] = None, model: Optional[str] = None, outcome: Optional[str] = None, since: Optional[float] = None, until: Optional[float] = None, limit: int = 100) -> List[Trace]
Query traces with optional filters.
Source code in src/openjarvis/traces/store.py
count
¶
search
¶
Full-text search across traces. Optionally filter by agent.
Source code in src/openjarvis/traces/store.py
update_feedback
¶
Update the feedback score for a trace.
Returns True if the trace was found and updated, False otherwise.