Evals
An eval runs an agent scenario and checks the result. Define cases in evals/. Deterministic assertions inspect replies, tool events, and run metrics. Prose assertions are graded by an LLM judge or TypeSafe Jev.
Layout
evals/
├── refund-over-cap/
│ ├── eval.json
│ └── eval.md
├── ingest-report/
│ ├── eval.json
│ ├── eval.ts
│ └── report.pdf
├── triage.md
└── README.mdA directory case uses eval.md or eval.ts, with an optional eval.json manifest and fixtures. A flat Markdown file works for a case without supporting files. Every other .md or .ts file under evals/ also loads as a case, so a fixture cannot be Markdown or TypeScript. README.md is skipped.
Discovery is recursive. The ID is the path relative to evals/, without the file extension or trailing /eval: refund-over-cap or journeys/onboarding/first-run. Moving a case changes its ID, which identifies baselines and trends.
Top-level evals/traces/ is reserved for online trace evaluators and excluded from eval discovery.
eval.json: metadata only
{
"tags": ["refusal", "write-path"],
"objectives": { "turns": { "max": 4 }, "hitlRequests": { "min": 1 } },
"runs": 5,
"passRate": 0.8,
"timeoutMs": 60000
}| Field | Meaning |
|---|---|
tags | Labels for amodal eval --tag. |
objectives | Soft run-metric bounds; see Objectives. |
attachments | Fixture files; see Attachments. |
runs | Number of repetitions; default 1. |
passRate | Fraction of declared runs that must pass; default 1. |
timeoutMs | Deadline for each attempt in milliseconds, also bounded by the suite deadline. |
judgeModel | Judge model as provider/model. Without it, the run's judge model applies (ci.evals.judgeModel or the run request), then EVAL_JUDGE_MODEL, then the agent's own model. |
grader | Prose grader; see Grading with TypeSafe Jev. |
| Session | agent, scopeId, user, scope, and maxSessionTokens; see The session an eval runs in. |
The same fields can be written in YAML frontmatter. Declaring a field in both frontmatter and eval.json is a load error.
eval.md: the case
# Eval: Looks up the order before answering
Check that the answer comes from the order system.
## Setup
Context: The operator is viewing order ORD-1001.
## Query
"What's the status of ORD-1001?"
## Assertions
- tool_called_with: lookup_order {"order_id": "ORD-1001"}
- contains: delivered
- no_failed_actions
- Should state the order status clearly.
- Should NOT invent a delivery date the tool did not return.| Section | Meaning |
|---|---|
# Eval: … | Title. Text before the first ## section becomes the description. |
## Setup | A Context: line, prepended to the first user message. App: and Runs: lines are accepted but do not affect the run. Other lines are a load error. |
## Query | One user message. ## Conversation replaces it when both exist. |
## Conversation | A script of messages and actions. |
## Assertions | One bullet per check. A case without assertions is a load error. |
Set repetitions with runs in metadata, not a Runs: line. Set scopeId, user, and agent in metadata, not in ## Setup. A ## Objectives section is a load error.
Grading with TypeSafe Jev
Prose assertions use an LLM judge unless the case or the run selects TypeSafe Jev. Save grading settings in eval.json or frontmatter:
{
"grader": {
"kind": "typesafe",
"model": "jev-latest",
"passAbove": 0.7,
"fallback": {
"model": "anthropic/claude-haiku-4-5-20251001",
"uncertain": { "low": 0.3, "high": 0.7 }
}
}
}kind is typesafe or llm_judge; both accept an optional model. passAbove passes each prose assertion at or above a probability. For scored grading, use rubric: { "levels": ["Not satisfied", "Partly satisfied", "Fully satisfied"], "passAt": 2 } instead. Levels are numbered from zero, and a rubric accepts 2 to 10 nonempty levels.
The optional fallback sends uncertain answers to an LLM. Statement probabilities within uncertain, including both endpoints, use the fallback. A rubric's fallback uses confidenceBelow, such as 0.6, instead of uncertain. A failed grading call is reported as Not graded.
Deterministic checks, named scorers, and code-authored evals keep their own rules. In Studio, Run settings on the Evals page can override the saved grader for a run; Saved with each case uses the saved grader.
Standalone runtimes require TYPESAFE_API_KEY; hosted runs use the platform's TypeSafe configuration. Each Jev request has a 30-second ceiling. Responses over 100,000 characters require an LLM judge.
Repeating an eval
With "runs": 5, "passRate": 0.8, at least four of the five runs must pass. The required count is ceil(runs × passRate). Execution stops when the verdict is settled; here a second failure makes a pass impossible, so the remaining attempts are skipped.
Each attempt gets its own timeoutMs, bounded by the time left in the suite's --timeout. A deadline that stops the repeats does not reduce the number needed to pass. The result reports attempted, passed, required, and total runs, and includes the first failing attempt when the case fails.
The session an eval runs in
An eval without agent follows ordinary chat routing. In schema version 2 it uses main.
{
"agent": "request-intake",
"scopeId": "user-a",
"user": "user_123",
"maxSessionTokens": 4000,
"scope": { "mission_id": "m-42" }
}| Field | Meaning |
|---|---|
agent | Named agent under agents/. An unknown name is an error. |
scopeId | Data scope identifier for tools, memory, and non-shared runtime stores. |
user | The user the session acts for. Tools read it as ctx.userId, as with amodal dev --user. In a local run, dev-users.json can give it claims. |
scope | Per-turn context, equivalent to chat request context, used by CONTEXT.md. |
maxSessionTokens | Session token ceiling; exhaustion ends with budget_exceeded. |
Each attempt creates a fresh session. scopeId does not supply authenticated user claims. user sets ctx.userId. Under amodal eval or amodal dev, a user listed in dev-users.json also gets that entry's claims, merged over the org_id claim when the run has an organization. An unlisted user gets no claims, and a hosted run never reads the file.
The answer model is selected for the whole suite: amodal eval --model sets it when the CLI starts the runtime, and a --url target uses its own model. A case cannot pin an answer model or force a skill. Use skill_loaded: to check whether the model chose the expected skill.
Assertions
Deterministic keys
| Key | Checks |
|---|---|
contains: <text> | Reply contains text. |
regex: /pattern/flags | Reply matches a regex. Bare patterns also work. |
starts_with: <text> | Reply begins with text. |
length_between: [min, max] | Reply length in characters. |
tool_called: <name> | Tool executed. |
tool_not_called: <name> | Deprecated alias of not tool_called: <name>. |
tool_called_with: <name> {json} | A call's arguments match a JSON subset. |
tool_returned: <name> {json} | A call's result matches a JSON subset. Non-object returns are wrapped under result. |
tool_result_contains: <name> <text> | A result contains a substring. |
tool_succeeded: <name> | Tool executed without an error. |
tool_order: a, b, c | Tools ran in that relative order. |
subagent_called: <name> | Specialist was invoked. |
skill_loaded: <name> | Skill was activated. |
hitl_requested | Run requested human input of any kind. |
hitl_requested: <subject> | A confirmation for that endpoint, or a durable approval for that tool, was requested. |
no_failed_actions | No failed tool or subagent, error, or warning. |
max_turns: <n> | Maximum model round trips. |
max_hitl: <n> / max_compactions: <n> | Maximum human-input requests or compactions. |
max_latency: <ms> | Maximum wall-clock duration. |
scorer: <name> | Run a named scorer. |
An unknown key shaped like snake_case: is a load error. Other text is judged prose.
Prefix a key with not or Should NOT to invert it. Use an argument-level negative when the tool may run for other records:
- tool_called_with: update_request {"request_id": "R-16"}
- not tool_called_with: update_request {"request_id": "R-11"}Pair tool_succeeded with tool_returned when the value matters. A JSON subset such as tool_returned: combine {"sum": 14} distinguishes 14 from 1400; a substring check does not.
Judged prose
| Bullet | Effect |
|---|---|
Should … | Required behavior. |
Should NOT … | Required absence. |
May … | Optional behavior. Graded and reported, but excluded from pass/fail. |
Conversation
## Conversation
- user: "Refund ORD-1002 in full, $940."
- deny: issue_refund
- user: "What would it take to approve it?"| Step | Meaning |
|---|---|
user: | Send a message. |
approve: / deny: | Supply the turn's confirmation decision. |
choose: | Answer ask_choice by option label. |
tool: | Invoke a tool directly without model selection. |
Inline confirmations default to denied. A durable approval with no scripted decision stays unanswered. The first approve: or deny: after a user message controls all of that turn's confirmation requests. Its tool name is a label, not a selector. Use separate user turns for actions needing different decisions, and assert the actual operation and arguments.
For a native OpenAPI write, denial happens before execution:
## Conversation
- user: "Record that Lee Park is adopting Biscuit."
- deny: shelter\_\_adoptResident
## Assertions
- hitl_requested: /residents/{residentId}/adopt
- not tool_succeeded: shelter\_\_adoptResident
- no_failed_actionsThis assumes a shelter connection with confirmation required on the adoption operation. A confirmation question in ordinary prose does not exercise the runtime's approval gate.
Calling a tool directly
A tool: step tests a handler without relying on the model to choose it:
## Conversation
- tool: build_from_packet {"packet_id": "PK-1"}
- user: "What did the packet build?"
## Assertions
- subagent_called: package-reviewer
- tool_returned: build_from_packet {"status": "staged"}Arguments must be a JSON object and can be omitted for a tool with no parameters. Missing required arguments fail validation before execution. Nested tool and subagent events are recorded for assertions. A script can contain only tool steps.
Direct invocation skips the outer permission checker, preToolUse and postToolUse hooks, and requiresConfirmation, so it can execute a write without asking. The handler's own checks still run. ctx.request() responses keep their field restrictions. A subagent the tool delegates to runs its model's calls through hooks and endpoint policy. Test approval with user: and deny:. An approval step directly after a tool: step is a load error.
Attachments
Declare fixture files in the manifest and attach them to user turns by name:
{
"attachments": [{ "path": "report.pdf" }, { "name": "annex", "path": "fixtures/annex-b.pdf" }]
}- user: "Summarize this report and its annex." [attach: report.pdf, annex]Paths resolve against the eval directory. A name defaults to the filename. Only user turns can attach files.
MIME type is inferred for .pdf, .png, .jpg, .jpeg, .gif, .webp, .txt, .md, .csv, .docx, .pptx, .xlsx, .odt, .odp, .ods, .rtf, .msg, .eml, .zip, .doc, .xls, .html, .htm, and .json. Other extensions require mimeType. The model receives Office and OpenDocument files converted to text. The types from .msg onward reach only an agent with a sandbox.
An undeclared attachment name fails loading. An unreadable file or an unknown extension without a MIME type fails the eval when it runs, before the first model call. Assert a fact found only inside the fixture to verify that the document reached the model.
Objectives
Objectives are soft bounds used for ranking, not pass/fail. Supported metrics are turns, userTurns, toolCalls, redundantToolCalls, subagentCalls, hitlRequests, failedActions, replyChars, latencyMs, and costMicros. Each takes a min, a max, or "minimize". An unknown metric is a load error.
Use an assertion when a bound must fail the case: max_turns: 4 is a gate, while an objective on turns is a ranking signal.
Code-authored evals
Use eval.ts for branching conversations, custom predicates, or assertions scoped to one turn:
export const readsBothDocuments = {
description: 'Read facts from documents as they arrive.',
async test(t) {
const first = await t.send('Read this report.', { attachments: ['report.pdf'] });
t.require('report reached the model', () => /Project Cedar/.test(first.reply ?? ''));
first.satisfies('does not invent the annex amount', () => !/1572/.test(first.reply ?? ''));
const second = await t.send('Read its annex.', { attachments: ['annex.pdf'] });
second.satisfies('reads the annex amount', () => /1572/.test(second.reply ?? ''));
t.noFailedActions();
},
};Declare both attachments in the sibling manifest. One file can export several cases. A named export contributes to the case ID, such as ingest/readsBothDocuments. An exported object can set tags, objectives, runs, passRate, timeoutMs, agent, scopeId, user, and maxSessionTokens, which override the file's eval.json. Set scope and attachments in eval.json; t.send can also pass scope per turn. A code-authored eval has no judged prose, so grader and judgeModel do not apply. Its eval.json and exported fields are not validated at load.
The context t and returned turn objects expose calledTool, notCalledTool, calledSubagent, loadedSkill, toolOrder, messageIncludes, maxTurns, maxToolCalls, noFailedActions, succeeded, and satisfies(label, predicate). Methods on a returned turn inspect only that turn. calledTool(name, {input, output}) accepts a JSON subset or a predicate for each matcher.
| Method | Purpose |
|---|---|
t.send(message, {approve, attachments, scope}) | Drive a conversation turn. approve defaults to false. |
t.callTool(name, args) | Invoke a tool directly, with the same ungated behavior as a tool: step. |
t.simulateUser(opts) | Let a model play the user. Requires instructions, opening, maxUserTurns, and stopTokens. |
t.require(label, predicate) | Record a precondition; stop with failure if it fails. |
t.skip(reason) | Mark the case not applicable and stop. |
t.log(message) | Add a note to the result. |
Ordinary assertions collect failures and continue.
Scorers
A scorer is a reusable check in scorers/<name>/scorer.ts. Reference it with scorer: <name>.
const known = new Set(['1', '2.1', '2.2']);
export default {
description: 'Every cited section exists in the reference index.',
requires: ['finalMessage'],
preprocess: ({ facts }) => {
const cited = [...(facts.finalMessage ?? '').matchAll(/§\s*([\d.]+)/g)].map((m) => m[1]);
return { cited, missing: cited.filter((id) => !known.has(id)) };
},
score: ({ pre }) => (pre.cited.length === 0 ? 1 : 1 - pre.missing.length / pre.cited.length),
reason: ({ pre }) =>
pre.missing.length ? `Unknown sections: ${pre.missing.join(', ')}` : 'All cited sections exist',
};A scorer: assertion passes only when the score is 1. Scores are clamped to the range 0 to 1, and a scorer that throws scores 0.
requires declares the facts a scorer reads: finalMessage, toolCalls, toolArguments, subagentCalls, skillsActivated, hitlRequests, or turns. A scorer that requires a fact the run cannot supply, or an unknown fact name, scores 0 and names the missing facts.
Running
Run cases from a terminal with amodal eval.
Running in Amodal
On the agent's Evals page, run one case or Run all. Filtering the list turns Run all into Run N shown. Selecting several models (and optional per-model effort levels) under Run settings compares them on the same cases: each case's comparison table shows the verdict, checks, attempts, duration, and combined answer + grading cost for every selected model, and badges the Lowest cost passing result.
Runs execute from the browser tab. Refreshing, closing the tab, signing out, or leaving the agent workspace aborts unfinished runs; navigating within the workspace does not. Stop run in the progress banner stops the active case and skips the queued ones. Completed results saved to the agent's history appear under Run history on the case.
Hosted eval sessions are not saved to conversation history. Agent and judge calls still produce traces and incur model usage charges.
Comparing a deployment against production
A comparison runs a deployment's evals next to the agent's live production deployment and sorts every case into one bucket. The deployment under test is the candidate. The live production deployment is the baseline, so it cannot be a candidate itself. When the agent has no production deployment, the comparison runs the candidate alone and every case is New.
What a comparison runs
One job runs the first pass on both deployments at the same time, so a change in a hosted model between runs does not reach the result.
- Both sides use the same answer model and effort, the same judge model, and the same repeat policy. The answer model is the agent's saved model, or the candidate's
models.mainwhen the agent has none. The judge model and repeat policy areci.evals.judgeModel,ci.evals.runs, andci.evals.passRatefrom the candidate's bundle. - Each side runs the cases its own runtime lists, Markdown and code-authored, in that deployment's version. A case's own
runs,passRate, andjudgeModelapply on the side whose bundle declares them. - Production runs fresh in every comparison. No production result from an earlier run is reused.
- Cases call real tools. Each side runs in its own deployment's runtime, through that deployment's connections and secrets. A tool that writes to an external system writes on both sides, once per attempt, reruns included.
When the candidate's runtime is stopped, the comparison starts it. Once the comparison completes, it stops that runtime again, unless the candidate went live in the meantime.
A candidate outside the production environment runs with its own environment's connections and secrets. Studio labels its comparison Different environment from production, because results can then differ for reasons outside the agent's code.
Buckets
The rules are checked from top to bottom, and a case takes the first bucket that matches. In the first pass, a case passes or fails by its verdict, which already applies the case's repeat policy.
| Bucket | Rule |
|---|---|
| Incomplete | Either side reported an error for the case, in the first pass or in a rerun. A case that never reported counts as an error. |
| New | Production does not have the case. |
| Removed | The candidate does not have the case. |
| Edited | The case's content differs between the two bundles, or cannot be compared. Its title and description are not content. Both results show. |
| Regressed | Passed on production and failed on the candidate, the reruns confirmed the flip, and the case is not flaky. |
| Inconclusive | Passed on production and failed on the candidate, but the reruns did not confirm the flip. Every flaky case is also here. |
| Fixed | Failed on production and passed on the candidate. |
| Still failing | Failed on both sides. |
| Unchanged | Passed on both sides. |
Only Incomplete and Regressed set the verdict. The other buckets are shown for information and block nothing.
Confirming a regression
After the first pass, each case that passed on production and failed on the candidate, with the same content on both sides, reruns on both sides. Each side reruns the case up to 5 times. The flip is Regressed when production passes at least 80% of the reruns, rounded up, and the candidate passes at most 20%, rounded down. With 5 reruns, production must pass at least 4 and the candidate at most 1. A side stops rerunning once its outcome is settled.
Set ci.evals.confirmRuns in amodal.json to rerun more times. With "confirmRuns": 10, production must pass at least 8 of 10 and the candidate at most 2. A value of 5 or less keeps 5 reruns.
A case that sets its own runs or passRate reruns under that policy instead, while the thresholds stay those of confirmRuns. Such a case usually cannot reach them, and its flip then reads Inconclusive.
Flaky cases
A case is flaky when production's last 10 results for it, with the same content, include both a pass and a fail. These results come from the production side of the agent's comparisons, the current one included, whichever deployment was live at the time. A flaky case is never Regressed. It reads Inconclusive whatever its result in the current comparison.
The verdict
| Verdict | When |
|---|---|
incomplete | Any case is Incomplete, or a deployment's bundle could not be read. |
regressed | No case is Incomplete, and at least one case is Regressed. |
clear | No case is Incomplete or Regressed. |
The verdict and the buckets are written once, when the comparison completes, and never change afterward. A deployment shows its latest comparison. Run another comparison to replace it.
Time limit
A comparison has 60 minutes from the moment it starts running. Time spent queued behind other comparisons does not count. When the time runs out, it completes with the results that reported. Every case without a result is saved as an error, so the verdict is incomplete. A failed attempt is retried, up to 3 attempts in all. A retry runs only the cases that have not reported and shares the first attempt's 60 minutes. A comparison that fails every attempt completes the same way. A comparison still running 70 minutes after it started, or still queued 24 hours after it was queued, completes the same way the next time Studio or the API reads it or starts another comparison for the deployment. A stuck or partial comparison reads incomplete, never clear.
A comparison that the platform could not queue has status failed and no verdict, and its commit status reads error. It does not prevent another comparison.
Commit status
For a deployment built from GitHub or GitLab, the comparison posts an amodal/evals commit status on the candidate's commit. The status links to the agent's Deployments page in Studio.
| Moment | GitHub state | GitLab state |
|---|---|---|
| The comparison is queued | pending | pending |
| The first pass starts | pending | pending |
| The comparison cannot be queued | error | failed |
The verdict is clear | success | success |
The verdict is regressed | failure | failed |
The verdict is incomplete | error | failed |
When GitLab refuses pending over an earlier pending status for the same commit, the comparison posts running. The description counts the cases per bucket and names the production commit, for example 2 regressed, 1 fixed, 27 unchanged vs production abc1234. Without a production deployment, it ends with (no production deploy). Posting is best effort: the comparison's result stands whether or not the status reaches the repository. A deployment from Amodal-hosted source gets no commit status.
The status is output only. The eval gate reads the comparison itself, so it gates deployments from every source, and a repository that cannot be reached does not open it.
Starting a comparison
Each deployment has at most one comparison queued or running. Starting a comparison while one is in flight returns that one.
- Studio: on the deployment's page, Run evals vs production starts a comparison. The button shows when the deployment has no comparison, or its latest one has status
failedorcancelledor verdictincomplete. It does not show on the live production deployment or to a user without permission to manage deployments. - API:
POST /api/deployments/{id}/eval-comparison. See Deployment API. - Build:
ci.evals.runOnstarts a comparison when a build completes. See Deployment triggers.
Deployment triggers
Automatic comparisons are opt-in. Set ci.evals.runOn in amodal.json to compare each deployment against production once its build completes:
{
"ci": {
"evals": {
"runOn": "production",
"confirmRuns": 10
}
}
}ci.evals.runOn | Automatic comparison |
|---|---|
"never" or omitted | No comparison. This is the default. |
"production" | Compare deployments of the production environment only. |
"all" | Compare every deployment. |
ci.evals.gate sets what refuses making a deployment live in production for the first time. See Eval gate.
ci.evals.gate | Refuses |
|---|---|
"regressions" | A comparison that is missing, unfinished, regressed, or incomplete. The default when runOn is "production" or "all". |
"failures" | The same, and any case that fails or errors on the deployment, including a case that fails in production too. |
"off" | Nothing. |
The gate applies only when runOn covers production and the deployment has cases. With runOn set to "never" or omitted, nothing is gated.
ci.evals also accepts runs, passRate, and judgeModel as suite defaults, and confirmRuns for the reruns. A case that sets its own runs or passRate keeps both of its values, and a case's judgeModel overrides the suite's.
Cloud reads the configuration from the deployment's own bundle, whatever its source. Missing or unreadable configuration, invalid JSON, and an unrecognized runOn value start no comparison. A deployment without cases is not compared. A deployment that goes live in production as its build completes is not compared either, because it is the production side of every comparison.
Held production pushes
With Auto-promote branch on, a production build that ci.evals.runOn compares does not go live as its build completes. It stays inactive, with its runtime running, while its comparison runs against production. Studio shows Evaluating on it.
When the comparison freezes, the eval gate set by ci.evals.gate decides whether the push goes live, the same rule that decides Make production.
- The gate allows it: the platform makes the deployment live once its runtime passes its health check. The audit log records
deployment_promotedbysystem:eval-comparison, with the comparison ID. With"regressions", the gate allows aclearverdict. With"failures", it allows aclearverdict when no case fails or errors on the deployment. With"off", it allows every verdict. - The gate refuses it: the deployment stays inactive until someone activates it. Its commit status description ends with
, not promoted. For aregressedorincompleteverdict, Studio shows Not promoted: N regressions or Not promoted: evals incomplete, and Not promoted for aclearverdict. - A newer held push: the newest push wins, whichever build finishes first. The comparison of an older held push that is still queued or running is cancelled, and an older push whose build finishes after the newer one's is cancelled as soon as its comparison is created. The older comparison gets status
cancelled, its commit gets anerrorstatus that readsSuperseded by a newer push, and the older deployment stays inactive. Studio shows Superseded. - Any activation in the meantime: activating, promoting, or rolling back a production deployment of the agent cancels the pending release of every held push. A held push that later clears stays inactive, so a rollback made while it was evaluated stays in place. A live deployment created after the held push also keeps it from going live.
If the bundle cannot be read when the build completes, the push is not held and goes live as usual.
Results in eval history
Each side of a comparison, and each side's reruns, saves one result per case it ran to the agent's eval history. On the Evals page, a case's Run history lists those results next to runs started from the page. The Source column names where each came from, for example Deploy check · abc1234, with the commit of the side that ran it. Opening a deployment result shows the same detail as a manual run. A case that never reported is saved as an error that names the reason, and shows as Not run, not as a failure.
Online trace evaluators
Markdown files under evals/traces/*.md define online evaluators that grade recorded runs on Traces > Evaluators and sync automatically on deploy (repo badge):
# Trace Eval: Grounded Tax Ruling Citations
Check that cited IRS sections match the retrieved knowledge.
## Config
Kind: llm_judge
Model: google/gemini-3.5-flash
Sampling: 100%
Enabled: true
## Filters
Source: deployed
Status: ok
Tool: load_knowledge
## Assertions
- Should cite only rulings and form numbers returned by tool calls in the trace.Each file defines one evaluator (## Assertions must contain a single - bullet). ## Config accepts Kind (llm_judge, the default, or typesafe), Model, Sampling (0% to 100%), and Enabled (true or false). ## Filters optionally narrows eligible runs by Source (local or deployed), Status (ok or error), Model, and Tool. For Kind: typesafe, add a ## Question section with an Instructions: line and either Type: noul with Pass above: or Type: score with Pass at: and a ## Levels bullet list, and an optional ## Fallback section (Model: plus Uncertain: 0.3 to 0.7 or Confidence below: 0.6).