trace

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package trace defines shared types for conversation trace parsing. These types are produced by each provider's ParseTrace method and consumed by the TUI views for rendering.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateTurnCost

func EstimateTurnCost(model string, tokIn, tokOut int64) float64

EstimateTurnCost calculates the estimated cost for a turn based on model name and token counts, delegating to the cost package.

func EstimateTurnCostLegacy

func EstimateTurnCostLegacy(model string, tokIn, tokOut int64) float64

EstimateTurnCostLegacy uses the original heuristic-based cost estimation from the view layer. It applies rough per-million-token rates based on model name substrings. Use EstimateTurnCost for more accurate pricing.

Types

type ToolSpan

type ToolSpan struct {
	Name      string
	Snippet   string // short description of the input
	Success   bool   // true if tool succeeded
	ErrorMsg  string // error message if failed
	OldString string // for Edit: the old text
	NewString string // for Edit: the new text
	ToolUseID string // for matching tool_result entries
}

ToolSpan represents a single tool call within a turn.

type Turn

type Turn struct {
	Number      int
	Timestamp   time.Time
	EndTime     time.Time // timestamp of last entry in this turn (for duration)
	UserLines   []string  // full user input text
	Actions     []ToolSpan
	OutputLines []string
	TokensIn    int64
	TokensOut   int64
	CostUSD     float64       // calculated from tokens + model
	Model       string        // model used for this turn
	Subagent    subagent.Info // subagent identity (empty for main thread)
}

Turn groups a user prompt with the assistant response into one logical unit -- the fundamental trace element for evaluation (input -> actions -> output).

func (Turn) Duration

func (t Turn) Duration() time.Duration

Duration returns the wall-clock duration of this turn.

func (Turn) ErrorCount

func (t Turn) ErrorCount() int

ErrorCount returns the number of failed tool calls in this turn.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL