Skip to main content
Eval scripts are the reward function for your agents. They measure a metric before and after an agent makes changes. The delta determines whether the change is kept or reverted.

Anatomy of an Eval Script

An eval script is a bash or TypeScript file that:
  1. Runs tests, measurements, or analysis
  2. Outputs a JSON object with a primary metric
  3. Exits with code 0 (even if the metric is bad)
eval/test-coverage.sh

The AGENT_WORKTREE Pattern

Critical: Agents work in isolated git worktrees at /tmp/tenet-agent-*. Your eval script must test the agent’s changes, not the main branch.Always use AGENT_WORKTREE when referencing the target repo:
This uses the worktree when running in agent context, and falls back to the main repo for manual testing.

Good vs Bad Eval Scripts

❌ Bad: Metric at ceiling

✅ Good: Metric with real gradient

❌ Bad: Binary pass/fail

✅ Good: Continuous signal

Eval Script Requirements

  1. Output JSON — Must output a single JSON object on stdout
  2. Primary metric — The JSON must include the metric field matching your agent config
  3. Exit 0 — Even if the metric is bad. Non-zero exit = eval failure, not bad score
  4. Deterministic — Same code should produce the same score
  5. Fast — Under 30 seconds is ideal. Maximum is the agent’s time_budget_seconds
  6. Stderr for logs — Write debug output to stderr, not stdout

Composite Metrics

For multi-dimensional quality, create a weighted composite:
eval/code-quality.sh

Testing Your Eval

Run it manually first:
Make sure the output is valid JSON and the primary metric has room to improve.