Documentation
¶
Index ¶
- Constants
- func CountMidTaskCompactions(boundaryOrdinals []int, toolCalls []ToolCallOrdinal) int
- func IsFailure(c ToolCallRow) bool
- type ContextPressureResult
- type ContextTokenRow
- type OutcomeInput
- type OutcomeResult
- type ScoreInput
- type ScoreResult
- type ToolCallOrdinal
- type ToolCallRow
- type ToolHealthSignals
Constants ¶
const RecencyWindow = 10 * time.Minute
RecencyWindow is the duration within which a session is considered still active.
Variables ¶
This section is empty.
Functions ¶
func CountMidTaskCompactions ¶
func CountMidTaskCompactions( boundaryOrdinals []int, toolCalls []ToolCallOrdinal, ) int
CountMidTaskCompactions returns the number of compact boundary messages where the first few tool calls after the boundary share names with the tool calls immediately before it. A boundary surrounded by overlapping tool work is a strong signal that compaction interrupted active work and the agent is repeating itself.
boundaryOrdinals must be sorted ascending. toolNamesByOrdinal holds the ordinal of the message that issued each call paired with its tool name, in chronological order.
func IsFailure ¶
func IsFailure(c ToolCallRow) bool
IsFailure returns true when a tool call represents a failure, either by event status or by content heuristics.
Types ¶
type ContextPressureResult ¶
type ContextPressureResult struct {
CompactionCount int
PressureMax *float64 // nil when data unavailable
}
ContextPressureResult holds computed context pressure metrics.
func ComputeContextPressure ¶
func ComputeContextPressure( tokens []ContextTokenRow, peakContextTokens int, model string, ) ContextPressureResult
ComputeContextPressure computes compaction count and peak context pressure from an ordered slice of token rows. Pure computation, no DB access.
type ContextTokenRow ¶
ContextTokenRow represents a single message's context token measurement.
type OutcomeInput ¶
type OutcomeInput struct {
IsAutomated bool
MessageCount int
EndedWithRole string // "user" or "assistant"
FinalFailureStreak int
LastAssistantText string
LastActivity time.Time
}
OutcomeInput holds the data needed to classify a session's outcome. Populated by the caller from DB queries.
type OutcomeResult ¶
type OutcomeResult struct {
Outcome string // "completed", "abandoned", "errored", "unknown"
Confidence string // "high", "medium", "low"
IsRecent bool
}
OutcomeResult is the classification result for a session.
func ClassifyOutcome ¶
func ClassifyOutcome(in OutcomeInput) OutcomeResult
ClassifyOutcome classifies a session's outcome based on its metadata. Pure computation, no DB access.
type ScoreInput ¶
type ScoreInput struct {
Outcome string
OutcomeConfidence string
HasToolCalls bool
FailureSignalCount int
RetryCount int
EditChurnCount int
ConsecutiveFailMax int
HasContextData bool
CompactionCount int
MidTaskCompactionCount int
PressureMax *float64
}
ScoreInput holds all signals needed to compute a health score. Populated by the caller from outcome, tool health, and context pressure results.
type ScoreResult ¶
type ScoreResult struct {
Score *int // nil = not scored
Grade string // "", "A", "B", "C", "D", "F"
Basis []string // which categories contributed
Penalties map[string]int // signal_name -> penalty applied
}
ScoreResult holds the computed health score and its breakdown.
func ComputeHealthScore ¶
func ComputeHealthScore(in ScoreInput) ScoreResult
ComputeHealthScore computes a penalty-based health score from session signals. Starts at 100, subtracts penalties, floors at 0. Pure computation, no DB access.
type ToolCallOrdinal ¶
ToolCallOrdinal pairs a tool call with the ordinal of the message that emitted it. Used by the mid-task compaction detector to locate calls relative to a boundary.
type ToolCallRow ¶
type ToolCallRow struct {
ToolName string
Category string // "Bash", "Edit", "Write", "Read", "Search"
InputJSON string
ResultContent string
MessageOrdinal int
CallIndex int
EventStatus string // "", "completed", "errored", "cancelled", "running"
}
ToolCallRow is populated from a JOIN of tool_calls + messages.
type ToolHealthSignals ¶
type ToolHealthSignals struct {
FailureSignalCount int
RetryCount int
EditChurnCount int
ConsecutiveFailureMax int
}
ToolHealthSignals holds computed health metrics for a session's tool calls.
func ComputeToolHealth ¶
func ComputeToolHealth(calls []ToolCallRow) ToolHealthSignals
ComputeToolHealth computes health signals from an ordered slice of tool call rows. Pure computation, no DB access.