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
- Variables
- func Check(e Eval) []string
- func Cosine(a, b []float32) float64
- func Delete(dir, name string) error
- func ExactMatch(expected, output string) bool
- func JudgeNear(ctx context.Context, ask gates.Asker, prompt, expected, output string) (float64, string, error)
- func Save(dir string, e Eval, previous string) (string, []string, error)
- func Table(cases []Case) string
- func ValidName(name string) bool
- type Case
- type Eval
- type RunLog
Constants ¶
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.
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.
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.
const ( AllowNetwork = "network" AllowMCP = "mcp" )
What an eval may allow its cases beyond reading: they never change files or run commands.
const DefaultThreshold = 0.8
DefaultThreshold is a near case's threshold when it has none.
Variables ¶
var ErrUnknown = errors.New("no such eval")
ErrUnknown means there's no eval of that name.
Functions ¶
func Check ¶
Check says what doesn't hold in e: its name, how it scores, what it allows, and each case.
func Cosine ¶
Cosine is the cosine similarity of a and b, from 0 (or below, for opposite vectors: 0) to 1.
func ExactMatch ¶
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.
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 ¶
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.