Help us shape the future of Go! Take the 2026 Go Developer Survey

eval

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package eval runs agents against a generated question bank and aggregates the results into an analysis suitable for reporting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentAnswer

type AgentAnswer struct {
	Agent       string             `json:"agent"`
	Chosen      int                `json:"chosen"` // option index, -1 if unparsed
	Label       string             `json:"label"`
	Confidences map[string]float64 `json:"confidences,omitempty"`
	Reasoning   string             `json:"reasoning,omitempty"`
	Correct     bool               `json:"correct"`
	Err         string             `json:"error,omitempty"`
}

AgentAnswer is a single agent's answer to a single question.

type AgentMetrics

type AgentMetrics struct {
	Agent          string  `json:"agent"`
	Total          int     `json:"total"`
	Answered       int     `json:"answered"`
	Correct        int     `json:"correct"`
	Accuracy       float64 `json:"accuracy"`
	Coverage       float64 `json:"coverage"`
	MeanConfidence float64 `json:"mean_confidence"`
	Brier          float64 `json:"brier"`
	ECE            float64 `json:"ece"`
	MacroF1        float64 `json:"macro_f1,omitempty"`
}

type AggregateMetrics

type AggregateMetrics struct {
	Total    int     `json:"total"`
	Correct  int     `json:"correct"`
	Accuracy float64 `json:"accuracy"`
}

type Analysis

type Analysis struct {
	Mode           string                         `json:"mode"`
	TotalQuestions int                            `json:"total_questions"`
	Agents         []*AgentMetrics                `json:"agents"`
	PerChapter     map[int]*AggregateMetrics      `json:"per_chapter,omitempty"`
	PerDifficulty  map[string]*AggregateMetrics   `json:"per_difficulty,omitempty"`
	Confusion      map[string]map[int]map[int]int `json:"confusion,omitempty"`
	Calibration    map[string][]Bin               `json:"calibration,omitempty"`
	Debate         *DebateAnalysis                `json:"debate,omitempty"`
}

func Analyze

func Analyze(res *RunResult) *Analysis

func Report

func Report(res *RunResult, mdPath, jsonPath string) (*Analysis, error)

Report writes both Markdown and JSON for the run result.

func (*Analysis) JSON

func (an *Analysis) JSON() string

JSON renders the Analysis as pretty-printed JSON.

func (*Analysis) Markdown

func (an *Analysis) Markdown() string

Markdown renders the Analysis as GitHub-flavored Markdown.

func (*Analysis) ResultsSummary

func (an *Analysis) ResultsSummary() string

func (*Analysis) Save

func (an *Analysis) Save(path string) error

Save writes the Markdown report to path.

func (*Analysis) SaveJSON

func (an *Analysis) SaveJSON(path string) error

SaveJSON writes the JSON analysis to path.

type Bin

type Bin struct {
	Lo            float64 `json:"lo"`
	Hi            float64 `json:"hi"`
	Count         int     `json:"count"`
	Accuracy      float64 `json:"accuracy"`
	AvgConfidence float64 `json:"avg_confidence"`
}

type DebateAnalysis

type DebateAnalysis struct {
	Engaged        int            `json:"engaged"`
	Correct        int            `json:"correct"`
	Accuracy       float64        `json:"accuracy"`
	Quadrants      map[string]int `json:"quadrants,omitempty"`
	AvgDriftAgents float64        `json:"avg_drift_agents,omitempty"`
	DriftRate      float64        `json:"drift_rate,omitempty"`
}

type Mode

type Mode string

Mode selects how agents are exercised against each question.

const (
	// ModeAnswerOnly asks each agent to answer every question directly.
	ModeAnswerOnly Mode = "answer_only"
	// ModeDebate runs a full gaslit debate per question and scores the winner.
	ModeDebate Mode = "debate"
	// ModeBoth runs answer-only first, then a debate per question.
	ModeBoth Mode = "both"
)

type QuestionResult

type QuestionResult struct {
	Question      qa.Question             `json:"question"`
	Answers       map[string]*AgentAnswer `json:"answers,omitempty"`
	Debate        *core.FullDebateSummary `json:"debate,omitempty"`
	DebateWinner  int                     `json:"debate_winner"`
	DebateCorrect bool                    `json:"debate_correct"`
	DebateEngaged bool                    `json:"debate_engaged"`
}

QuestionResult bundles the per-question outcome.

type QuestionResultDetail

type QuestionResultDetail struct {
	ID            string
	Source        string
	Chapter       int
	ChapterTitle  string
	Question      string
	Options       []string
	Answer        int
	AnswerLabel   string
	AgentAnswers  map[string]*AgentAnswer
	DebateWinner  int
	DebateCorrect bool
	DebateEngaged bool
}

QuestionResult helpers for detailed reporting (optional)

type RunConfig

type RunConfig struct {
	// Mode selects the evaluation mode. Default ModeAnswerOnly.
	Mode Mode
	// Targets are the agents to test. Required.
	Targets []Target
	// SupervisorModel powers debate mode. Required for ModeDebate/ModeBoth.
	SupervisorModel model.BaseModel[*schema.Message]
	// EngineOptions are applied to the gaslit engine used in debate mode.
	EngineOptions []core.Option
	// Verbose enables engine progress logging in debate mode.
	Verbose bool
	// Logger receives progress output. Optional.
	Logger *slog.Logger
}

RunConfig configures an evaluation run.

type RunResult

type RunResult struct {
	Mode       Mode             `json:"mode"`
	Bank       *qa.QuestionBank `json:"bank"`
	Results    []QuestionResult `json:"results"`
	StartedAt  time.Time        `json:"started_at"`
	FinishedAt time.Time        `json:"finished_at"`
}

RunResult is the full outcome of an evaluation run.

func Run

func Run(ctx context.Context, bank *qa.QuestionBank, cfg RunConfig) (*RunResult, error)

Run exercises the configured targets against the question bank.

func (*RunResult) Details

func (res *RunResult) Details() []QuestionResultDetail

type Target

type Target struct {
	Name  string
	Agent adk.Agent
}

Target is a named agent under test.

Jump to

Keyboard shortcuts

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