Skip to main content

Module telemetry

Module telemetry 

Source
Expand description

Structured telemetry a tool reports ALONGSIDE its rendered text (UI Phase 1).

Why: the retrieval tools already know things the UI needs and the event stream throws away. search_code knows which trusty-search lane actually served a query, how many hits came back, and what it cost; recall_session knows every result’s score and which ones its token budget dropped. Today all of that is flattened into prose and then TRUNCATED into an args_preview/result_preview string. This module is the escape hatch: a tool returns structured data attached to its crate::tools::ToolResult, and the agent loop — the one layer that knows WHICH agent is running and owns the ToolEventSink — forwards it.

The alternative (handing every tool a sink plus its own agent name at construction) was rejected: it would make each tool’s attribution an independent copy of the loop’s, free to drift, and would force the fail-open retrieval tools to grow a second reason to fail. Tools stay pure functions of their arguments — unit-testable with no sink, no session, and no bus — and attribution keeps ONE source of truth. What: ToolTelemetry is the tool -> loop payload, one variant per structured event kind. It is deliberately NOT the wire type: the wire types live in crate::events and are built from this by the sink, which is where session_id and agent get stamped on. Test: crate::agent_loop::tests::sink_events::sink_receives_tool_telemetry_with_agent (forwarding), plus each tool’s own telemetry_* tests (production).

Structs§

RecallTelemetry
What a recall_session call recalled, and what reached the model (UI Phase 1).
SearchTelemetry
What a search_code call actually did (UI Phase 1).

Enums§

ToolTelemetry
Structured data a tool reports about what it actually did (UI Phase 1).