Documentation
¶
Overview ¶
Package stats tracks session-level metrics for the assistant.
Index ¶
- type Snapshot
- type Stats
- func (s *Stats) Display() string
- func (s *Stats) Duration() time.Duration
- func (s *Stats) MergeToolCalls(tools map[string]int)
- func (s *Stats) RecordCompaction()
- func (s *Stats) RecordInteraction()
- func (s *Stats) RecordIteration()
- func (s *Stats) RecordParseRetry()
- func (s *Stats) RecordTokens(input, output int)
- func (s *Stats) RecordToolCall(name string)
- func (s *Stats) RecordToolError(name string)
- func (s *Stats) RecordTurn()
- func (s *Stats) Snapshot() Snapshot
- func (s *Stats) TopTools(n int) []ToolCount
- type TokensSnapshot
- type ToolCount
- type ToolsSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Snapshot ¶
type Snapshot struct {
StartTime time.Time `json:"start_time"`
Interactions int `json:"interactions"`
Turns int `json:"turns"`
Iterations int `json:"iterations"`
ParseRetries int `json:"parse_retries"`
Compactions int `json:"compactions"`
Tools ToolsSnapshot `json:"tools"`
Tokens TokensSnapshot `json:"tokens"`
}
Snapshot is a frozen, mutex-free copy of Stats for safe read-only use.
type Stats ¶
type Stats struct {
StartTime time.Time `json:"start_time"`
Interactions int `json:"interactions"`
Turns int `json:"turns"`
Iterations int `json:"iterations"`
ParseRetries int `json:"parse_retries"`
Compactions int `json:"compactions"`
Tools ToolsSnapshot `json:"tools"`
Tokens TokensSnapshot `json:"tokens"`
// contains filtered or unexported fields
}
Stats holds cumulative session metrics. All mutation and read methods are safe for concurrent use.
func (*Stats) Display ¶
Display returns a formatted multi-line stats string. Only formats data owned by Stats — context/message counts belong to ui.Status.
func (*Stats) MergeToolCalls ¶
MergeToolCalls merges tool call counts from a subagent into the session stats.
func (*Stats) RecordCompaction ¶
func (s *Stats) RecordCompaction()
RecordCompaction increments the compaction counter.
func (*Stats) RecordInteraction ¶
func (s *Stats) RecordInteraction()
RecordInteraction increments the interaction counter (every ProcessInput call).
func (*Stats) RecordIteration ¶
func (s *Stats) RecordIteration()
RecordIteration increments the iteration counter.
func (*Stats) RecordParseRetry ¶
func (s *Stats) RecordParseRetry()
RecordParseRetry increments the parse retry counter.
func (*Stats) RecordTokens ¶
RecordTokens adds token counts from a single chat round.
func (*Stats) RecordToolCall ¶
RecordToolCall records a successful tool execution.
func (*Stats) RecordToolError ¶
RecordToolError records a failed tool execution.
type TokensSnapshot ¶
TokensSnapshot holds cumulative token counts.