Skip to main content

Module stats

Module stats 

Source
Expand description

Session summary for /usage.

One shared implementation of the aggregate view both front-ends print: the REPL’s text line and the TUI’s notice. Keeping it in the kernel means the tally and its wording live in one place; each front-end adds only its own surrounding chrome.

Why a new module rather than folding into message.rs: message.rs is the serde wire model (ContentBlock at message.rs:5, AgentMessage at message.rs:47); stats is analysis over that model. Keeping the model pure means the derived view can change (add fields, change the cap) without touching the wire format or its round-trip tests.

Source of the tool tally: AgentMessage::Assistant ContentBlock::ToolCall blocks (message.rs:11), i.e. the model’s intent, exactly once per call. We deliberately do NOT use the paired ToolResult.name (message.rs:63): the two are 1:1 by tool_call_id (the loop synthesizes an error ToolResult for every unexecuted/blocked call — loop_.rs:683), so they count the same calls, but the Assistant block is the canonical, dedup-free definition and does not depend on the loop’s pairing invariant holding.

Structs§

SessionStats
Aggregate view of a conversation for /usage: how many turns reported usage, the summed token counts, and which tools ran.

Constants§

TOOL_LIST_CAP
How many tool names the rendered tools: segment lists before +K more. Many tools exist (crates/wcode-cli/src/tools/); the list is a glance, not a manifest.

Functions§

session_stats
Fold a conversation into a SessionStats.