evals

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package evals reads and writes eval files (spec_evals_042): cases, each a prompt and the output expected of it, in a Markdown table in .agents/evals/<name>.md; scores an agent's output against a case; and keeps the runs.

Index

Constants

View Source
const (
	// Exact passes when the output is the expected text (trimmed, line
	// endings and trailing spaces aside).
	Exact = "exact"
	// Near passes when the output's score against the expected text (0 to
	// 1) reaches the case's threshold.
	Near = "near"
)

A case's output type.

View Source
const (
	// Fail fails the eval.
	Fail = "fail"
	// Warn is reported as a warning.
	Warn = "warn"
	// Info is reported only.
	Info = "info"
)

A case's scope: what its failure means.

View Source
const (
	// Judge has a model score how close the output is in meaning.
	Judge = "judge"
	// Embedding scores by the cosine similarity of the texts' embeddings
	// (search.embedding_model).
	Embedding = "embedding"
)

How near cases are scored.

View Source
const (
	AllowNetwork = "network"
	AllowMCP     = "mcp"
)

What an eval may allow its cases beyond reading: they never change files or run commands.

View Source
const DefaultThreshold = 0.8

DefaultThreshold is a near case's threshold when it has none.

Variables

View Source
var ErrUnknown = errors.New("no such eval")

ErrUnknown means there's no eval of that name.

Functions

func Check

func Check(e Eval) []string

Check says what doesn't hold in e: its name, how it scores, what it allows, and each case.

func Cosine

func Cosine(a, b []float32) float64

Cosine is the cosine similarity of a and b, from 0 (or below, for opposite vectors: 0) to 1.

func Delete

func Delete(dir, name string) error

Delete removes eval name from dir.

func ExactMatch

func ExactMatch(expected, output string) bool

ExactMatch reports whether output is expected: both trimmed, line endings and each line's trailing spaces aside.

func JudgeNear

func JudgeNear(ctx context.Context, ask gates.Asker, prompt, expected, output string) (float64, string, error)

JudgeNear has the judge score output against expected (0 to 1), for prompt.

func Save

func Save(dir string, e Eval, previous string) (string, []string, error)

Save writes dir/<name>.md from e (its Path and Problem aside), keeping the file's other front matter, and returns its path, or the problems that keep it from being saved. previous is the eval edited ("" for a new one).

func Table

func Table(cases []Case) string

Table writes cases as a Markdown table.

func ValidName

func ValidName(name string) bool

ValidName reports whether name can be an eval's (its file's) name.

Types

type Case

type Case struct {
	ID     string
	Name   string
	Prompt string
	// Output is the output expected.
	Output    string
	Type      string
	Threshold float64
	Scope     string
}

Case is one row of an eval's table.

func ParseTable

func ParseTable(body string) (intro string, cases []Case, outro string, err error)

ParseTable reads the cases from the first Markdown table in body, returning the text around it. Columns are found by their titles, in any order; an empty type is near, an empty scope fail, an empty near threshold DefaultThreshold.

type Eval

type Eval struct {
	// Name is its file's name without .md.
	Name        string
	Path        string
	Description string
	// Agents are the agents each case runs on (none: the active one).
	Agents []string
	// Skills are given to the agent with each case's prompt.
	Skills []string
	// Near is how near cases are scored: Judge (the default) or Embedding.
	Near string
	// Allow are what cases may do beyond reading: AllowNetwork, AllowMCP.
	Allow []string
	Cases []Case
	// Intro and Outro are the body's text before and after the table,
	// kept as written.
	Intro, Outro string
	Problem      string
}

Eval is one eval file.

func Load

func Load(dir string) []Eval

Load reads every eval (*.md) in dir, by name.

func Parse

func Parse(name, path string, data []byte) Eval

Parse reads an eval file; what doesn't hold is its Problem.

type RunLog

type RunLog struct {
	// contains filtered or unexported fields
}

RunLog keeps finished eval runs, one JSON line each, in a file per workspace and eval.

func OpenRunLog

func OpenRunLog(dir string) *RunLog

OpenRunLog keeps runs under dir.

func (*RunLog) Append

func (l *RunLog) Append(r api.EvalRun) error

Append records a finished run.

func (*RunLog) List

func (l *RunLog) List(workspace, eval string, limit int) ([]api.EvalRun, error)

List returns an eval's runs, newest first, at most limit (0: all).

Jump to

Keyboard shortcuts

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