Evals
Evals
An eval is a scored check of your agent. It sends real input to the real agent, then grades what the agent did. Package github.com/mark3labs/bonnie/eval drives the agent, and bonnie eval runs the evals of a tree and reports the scores.
An eval is a Go test. You get go test filters, parallel runs, timeouts, repeats, and exit codes, and there is no configuration file.
Evals use three types of check. Use the first type that can answer your question:
- Run checks read the journal: the state of the turn, the tools it called, the steps it took, the decisions it made. They are exact and free.
- The decision judge asks a decision model typed questions about the reply. It returns probabilities, so a score needs no parsing, and a call costs little. This is the recommended judge.
- The language-model judge asks a plain chat model for a score and a reason. Use it when no decision model fits the question, or when a written reason helps.
The checks read what the run recorded in the journal. This is the same record that replay and crash recovery use, so a check grades what really happened.
Write the first eval
An eval must build the same agent that your binary serves. A tree from bonnie init has a newAgent function in main.go for this:
func main() {
newAgent().Serve()
}
// newAgent builds the agent. main serves it, and each eval builds its own
// with it, so an eval tests the agent this binary ships.
func newAgent() *bonnie.Agent {
return bonnie.New(
bonnie.WithModel("anthropic/claude-sonnet-4-5"),
)
}
An older tree calls bonnie.New(...).Serve() in main. Move the call into newAgent as above. Do not put the options in a second place: an eval that builds its own agent tests options that the binary does not ship.
Put the eval in a file that ends in _eval_test.go, and start the file with the build constraint //go:build eval. The constraint keeps the eval out of a plain go test, which must never call a live model.
//go:build eval
package main
import (
"testing"
"github.com/mark3labs/bonnie/eval"
)
func TestRefundPolicy(t *testing.T) {
t.Parallel()
e := eval.New(t, newAgent())
turn := e.Send("Can I get a refund after 40 days?")
turn.Succeeded().
CalledTool("lookup_policy").
NotCalledTool("issue_refund")
e.Check(turn.Reply(), eval.Contains("30 days"))
e.Judge(eval.Bool("cites_policy", "Does the response refuse and cite the 30-day policy?")).
AtLeast(0.8)
}
eval.New opens the agent in the test process. It uses the same agent factory and runner as Agent.Run, but it starts no server, channel, or scheduler. The journal is in a temporary directory, so each eval starts with no history. The runtime closes when the test ends.
Give each eval its own agent: call newAgent() in each test. eval.New configures the journal of the agent it gets, so it fails the test when two evals share one agent.
Run the evals
bonnie eval --judge openrouter/typesafe/jev-1.14
bonnie eval generates bonnie_gen.go as bonnie build does, then runs go test -tags eval -json ./... in the tree.
On a terminal, it opens the eval interface. The evals show as they run: a spinner for each running eval, then a mark when it ends. When the run ends, the interface stays open so you can read the results:
BONNIE eval · support · 20261029-120000 FAIL ✓ 1 ✗ 1 scores 1 passed 1 scored 0 failed 0.4s
╭─ Evals ──────────────────────╮╭─ TestRefundPolicy ─────────────────────────────────────────────────────────╮
│ ✓ TestRefundPolicy 0.1s ││ 1 Scores │ 2 Conversation │ 3 Output │
│ ✗ TestGreeting 0.1s ││ │
│ ││ PASS 0.1s · 1 turn │
│ ││ │
│ ││ KIND LABEL SCORE BOUND STATUS │
│ ││ judge cites_policy 0.940 ━━━━━━━━━━━│ >= 0.900 passed │
│ ││ llm The response offers an a… 0.550 ━━━━━━━━│━━━ >= 0.700 scored │
│ ││ ↳ It refuses but does not offer store credit as an alternative. │
╰──────────────────── 1 of 2 ──╯╰────────────────────────────────────────────────────────────────────────────╯
o open run console · ↑↓ select · tab focus · 1-3 tab · f failed only · q quit
| Key | Action |
|---|---|
↑ ↓ or k j |
Select an eval, or scroll the detail when it has the focus |
tab |
Move the focus between the list and the detail |
1 2 3, or ← → |
Show the scores, the conversation, or the raw test output |
f |
Show only the failed evals |
o or enter |
Open the eval's journal in the run console, with the Conversation, Trace and Journal tabs of bonnie runs. Quit the console to come back. |
r |
Run the selected eval again |
R |
Run each failed eval again |
q |
Quit. While evals still run, the first q asks, and a second q stops them. |
| Mouse | Click an eval to select it, or a tab to show it. The wheel scrolls the panel under the pointer. Drag over the detail to copy its text. |
The Scores tab names the models: the agent's, from the steps in the eval's journal, and each judge's, from its scores. The Conversation tab names the agent's model at the top. An agent built against an older BONNIE release does not record its model, so its evals show only the judges.
A rerun happens in the same screen and keeps the whole suite on it. The evals that you rerun show a spinner at once, also while go test builds the tests, and then get a new result. The others keep their result from the earlier run, muted, with the time of that run; their detail says which run made them. The totals and the exit code are those of the whole suite, so you can fix, press R, and repeat until the header shows PASS.
A rerun uses the same flags and is a new saved run that holds the merged results. Its header names the run it came from, and the earlier run stays unchanged in bonnie eval list, so you can compare the two. A run that a kept run carries results from is not pruned, so its journals stay. The tree's wiring is generated again first, so a change that you made to the agent or to the eval is in the rerun. A merged run can therefore hold results from different versions of the code; the "from" mark shows which results are older. A rerun waits until the current run ends. When you quit, the command prints the last run.
To run one eval from the command line, give --run an anchored pattern for each level of its name. go test splits the pattern on /:
bonnie eval --run '^TestRefundPolicy