@cursor/july 0.1.91 → 0.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +4 -0
- package/dist/docs/404.html +3 -1
- package/dist/docs/ab.html +4 -2
- package/dist/docs/ab.md +338 -0
- package/dist/docs/building-with-agents.html +4 -2
- package/dist/docs/building-with-agents.md +124 -0
- package/dist/docs/concepts.html +4 -2
- package/dist/docs/concepts.md +174 -0
- package/dist/docs/deployment.html +4 -2
- package/dist/docs/deployment.md +464 -0
- package/dist/docs/evals.html +4 -2
- package/dist/docs/evals.md +481 -0
- package/dist/docs/example-agents/approval-buddy.html +4 -2
- package/dist/docs/example-agents/approval-buddy.md +266 -0
- package/dist/docs/example-agents/benny.html +4 -2
- package/dist/docs/example-agents/benny.md +182 -0
- package/dist/docs/example-agents/bugbot.html +4 -2
- package/dist/docs/example-agents/bugbot.md +229 -0
- package/dist/docs/example-agents/codebase-wiki.html +4 -2
- package/dist/docs/example-agents/codebase-wiki.md +170 -0
- package/dist/docs/example-agents/codeowners-review.html +4 -2
- package/dist/docs/example-agents/codeowners-review.md +192 -0
- package/dist/docs/example-agents/concierge.html +4 -2
- package/dist/docs/example-agents/concierge.md +201 -0
- package/dist/docs/example-agents/fsd.html +4 -2
- package/dist/docs/example-agents/fsd.md +329 -0
- package/dist/docs/example-agents/index.html +4 -2
- package/dist/docs/example-agents/index.md +102 -0
- package/dist/docs/example-agents/knowledge-base.html +4 -2
- package/dist/docs/example-agents/knowledge-base.md +168 -0
- package/dist/docs/example-agents/oncall.html +4 -2
- package/dist/docs/example-agents/oncall.md +212 -0
- package/dist/docs/example-agents/security-reviewer.html +4 -2
- package/dist/docs/example-agents/security-reviewer.md +265 -0
- package/dist/docs/example-agents/slack-agent.html +4 -2
- package/dist/docs/example-agents/slack-agent.md +142 -0
- package/dist/docs/example-agents/weather-agent.html +4 -2
- package/dist/docs/example-agents/weather-agent.md +296 -0
- package/dist/docs/guides/agent-to-agent.html +4 -2
- package/dist/docs/guides/agent-to-agent.md +113 -0
- package/dist/docs/guides/cloud-runtime.html +4 -2
- package/dist/docs/guides/cloud-runtime.md +131 -0
- package/dist/docs/guides/convert-automation.html +4 -2
- package/dist/docs/guides/convert-automation.md +171 -0
- package/dist/docs/guides/github.html +4 -2
- package/dist/docs/guides/github.md +287 -0
- package/dist/docs/guides/human-in-the-loop.html +4 -2
- package/dist/docs/guides/human-in-the-loop.md +126 -0
- package/dist/docs/guides/mcp-oauth.html +4 -2
- package/dist/docs/guides/mcp-oauth.md +159 -0
- package/dist/docs/guides/opentelemetry.html +4 -2
- package/dist/docs/guides/opentelemetry.md +209 -0
- package/dist/docs/guides/slack.html +4 -2
- package/dist/docs/guides/slack.md +337 -0
- package/dist/docs/guides/webhooks.html +4 -2
- package/dist/docs/guides/webhooks.md +463 -0
- package/dist/docs/hillclimbing.html +4 -2
- package/dist/docs/hillclimbing.md +88 -0
- package/dist/docs/index.html +4 -2
- package/dist/docs/index.md +179 -0
- package/dist/docs/llms-full.txt +11518 -0
- package/dist/docs/llms.txt +75 -0
- package/dist/docs/quickstart.html +4 -2
- package/dist/docs/quickstart.md +364 -0
- package/dist/docs/reference/agent-config.html +4 -2
- package/dist/docs/reference/agent-config.md +256 -0
- package/dist/docs/reference/artifacts.html +4 -2
- package/dist/docs/reference/artifacts.md +112 -0
- package/dist/docs/reference/channels.html +4 -2
- package/dist/docs/reference/channels.md +255 -0
- package/dist/docs/reference/cli.html +4 -2
- package/dist/docs/reference/cli.md +957 -0
- package/dist/docs/reference/connections.html +4 -2
- package/dist/docs/reference/connections.md +268 -0
- package/dist/docs/reference/hooks.html +4 -2
- package/dist/docs/reference/hooks.md +102 -0
- package/dist/docs/reference/http-api.html +4 -2
- package/dist/docs/reference/http-api.md +267 -0
- package/dist/docs/reference/instructions.html +4 -2
- package/dist/docs/reference/instructions.md +74 -0
- package/dist/docs/reference/playground.html +4 -2
- package/dist/docs/reference/playground.md +62 -0
- package/dist/docs/reference/project-layout.html +4 -2
- package/dist/docs/reference/project-layout.md +107 -0
- package/dist/docs/reference/prompt.html +4 -2
- package/dist/docs/reference/prompt.md +42 -0
- package/dist/docs/reference/schedules.html +4 -2
- package/dist/docs/reference/schedules.md +215 -0
- package/dist/docs/reference/sessions.html +4 -2
- package/dist/docs/reference/sessions.md +170 -0
- package/dist/docs/reference/skills.html +4 -2
- package/dist/docs/reference/skills.md +83 -0
- package/dist/docs/reference/subagents.html +4 -2
- package/dist/docs/reference/subagents.md +71 -0
- package/dist/docs/reference/tools.html +4 -2
- package/dist/docs/reference/tools.md +298 -0
- package/dist/docs/scaffolding-agents.html +4 -2
- package/dist/docs/scaffolding-agents.md +130 -0
- package/dist/docs/storage.html +4 -2
- package/dist/docs/storage.md +219 -0
- package/dist/docs/templates/agentic-owners.html +4 -2
- package/dist/docs/templates/agentic-owners.md +92 -0
- package/dist/docs/templates/demo.html +4 -2
- package/dist/docs/templates/demo.md +79 -0
- package/dist/docs/templates/pr-autofixer.html +4 -2
- package/dist/docs/templates/pr-autofixer.md +131 -0
- package/dist/docs/templates/security-reviewer.html +4 -2
- package/dist/docs/templates/security-reviewer.md +84 -0
- package/dist/docs/templates/triage.html +4 -2
- package/dist/docs/templates/triage.md +98 -0
- package/dist/docs/troubleshooting.html +4 -2
- package/dist/docs/troubleshooting.md +111 -0
- package/dist/internal/init-scaffold.d.ts.map +1 -1
- package/dist/internal/init-scaffold.js +1 -0
- package/dist/internal/playground/static.d.ts.map +1 -1
- package/dist/internal/playground/static.js +2 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +3 -1
- package/package.json +2 -2
- package/skills/ab/SKILL.md +3 -0
- package/skills/create-agent/SKILL.md +3 -0
- package/skills/debug/SKILL.md +3 -0
- package/skills/evals/SKILL.md +3 -0
- package/skills/framework-map/SKILL.md +3 -0
- package/skills/github/SKILL.md +3 -0
- package/skills/hillclimb/SKILL.md +3 -0
- package/skills/mcp-auth/SKILL.md +3 -0
- package/skills/otel/SKILL.md +3 -0
- package/skills/setup-slack/SKILL.md +3 -0
- package/src/internal/init-scaffold.ts +1 -0
- package/src/internal/playground/static.ts +2 -0
- package/src/internal/session-engine.ts +4 -6
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# Evals
|
|
2
|
+
|
|
3
|
+
An eval is a repeatable check that runs your agent against a fixed input
|
|
4
|
+
and gates the recorded trajectory: the run completed, the right tool
|
|
5
|
+
ran, the reply has the right shape. Evals are how you know a prompt
|
|
6
|
+
tweak helped, a refactor didn't regress the agent, and last month's fix
|
|
7
|
+
is still holding.
|
|
8
|
+
|
|
9
|
+
Evals exercise the same surface your users hit. The runner starts (or
|
|
10
|
+
targets) a real agent server, drives sessions over the public API, and
|
|
11
|
+
grades what comes back. A passing eval means the agent started,
|
|
12
|
+
accepted a message, and did what you asserted.
|
|
13
|
+
|
|
14
|
+
> [!NOTE]
|
|
15
|
+
> Import paths here use `@cursor/july/evals`. On projects still
|
|
16
|
+
> using `@anysphere/agent-serve`, swap the import and run
|
|
17
|
+
> `agent-serve eval`. See
|
|
18
|
+
> [Run the CLI](/docs/index.md#run-the-cli) for the full rename table.
|
|
19
|
+
|
|
20
|
+
## Define evals with `defineEval`
|
|
21
|
+
|
|
22
|
+
The Agent SDK discovers evals under the project-root `evals/` directory,
|
|
23
|
+
in `.eval.ts` or `.eval.js` files. That's a sibling of `agent/`, never
|
|
24
|
+
inside it (`agent/evals/` is silently ignored). TypeScript is the normal
|
|
25
|
+
authoring format.
|
|
26
|
+
|
|
27
|
+
The file path is the eval's identity, so you don't author an id.
|
|
28
|
+
Directories group related evals: `evals/builds/api.eval.ts` becomes id
|
|
29
|
+
`builds/api`. An `index` filename collapses to its directory, so
|
|
30
|
+
`evals/builds/index.eval.ts` becomes `builds`.
|
|
31
|
+
|
|
32
|
+
An eval is a single `async test(t)`. You drive the agent with `t` and
|
|
33
|
+
assert on the run with the same `t`:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// evals/readiness.eval.ts
|
|
37
|
+
import { defineEval, includes } from "@cursor/july/evals";
|
|
38
|
+
|
|
39
|
+
export default defineEval({
|
|
40
|
+
description: "Inspects a PR without approving it.",
|
|
41
|
+
tags: ["smoke"],
|
|
42
|
+
timeoutMs: 120_000,
|
|
43
|
+
async test(t) {
|
|
44
|
+
await t.send(
|
|
45
|
+
"Is https://github.com/acme/checkout/pull/42 ready to approve?"
|
|
46
|
+
);
|
|
47
|
+
t.succeeded();
|
|
48
|
+
t.calledTool("inspect_pr");
|
|
49
|
+
t.notCalledTool("approve_pr");
|
|
50
|
+
t.check(t.reply, includes(/ready|approve/i));
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
One file can also hold several datapoints through `cases` (provide
|
|
56
|
+
either `test` or `cases`, not both). Each case id becomes
|
|
57
|
+
`<fileId>/<case.id>`:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
// evals/prs.eval.ts → prs/checkout, prs/search
|
|
61
|
+
export default defineEval({
|
|
62
|
+
tags: ["smoke", "prs"],
|
|
63
|
+
cases: [
|
|
64
|
+
{
|
|
65
|
+
id: "checkout",
|
|
66
|
+
description: "Checkout PR readiness.",
|
|
67
|
+
async test(t) {
|
|
68
|
+
await t.send(
|
|
69
|
+
"Is https://github.com/acme/checkout/pull/42 ready to approve?"
|
|
70
|
+
);
|
|
71
|
+
t.succeeded();
|
|
72
|
+
t.calledTool("inspect_pr");
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "search",
|
|
77
|
+
async test(t) {
|
|
78
|
+
await t.send(
|
|
79
|
+
"Check https://github.com/acme/search/pull/7 before approval."
|
|
80
|
+
);
|
|
81
|
+
t.succeeded();
|
|
82
|
+
t.calledTool("inspect_pr");
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Case ids must be single path segments, unique within the file.
|
|
90
|
+
Each case can set its own `description`, `tags`, `timeoutMs`, and
|
|
91
|
+
`iterations`. A case-level value replaces the file-level value for that
|
|
92
|
+
datapoint.
|
|
93
|
+
|
|
94
|
+
### Iterations
|
|
95
|
+
|
|
96
|
+
`iterations` (file or case, default `1`) runs a datapoint repeatedly.
|
|
97
|
+
Discovery expands `iterations: 3` on case `nyc` to runnable ids
|
|
98
|
+
`weather/nyc/1`, `weather/nyc/2`, `weather/nyc/3` (filter prefix
|
|
99
|
+
`weather/nyc` still selects all three). Each expanded case exposes
|
|
100
|
+
`t.iteration` / `t.iterations` on the test context. Cap is 100.
|
|
101
|
+
|
|
102
|
+
`maxConcurrency` counts **authored datapoints**, not expanded
|
|
103
|
+
iterations: siblings `…/1`…`…/n` share one concurrency slot and run
|
|
104
|
+
sequentially. A suite with 11 cases × 3 iterations and
|
|
105
|
+
`maxConcurrency: 20` therefore has at most 11 cases in flight, not 33.
|
|
106
|
+
|
|
107
|
+
## Configure eval runs
|
|
108
|
+
|
|
109
|
+
Each project with evals needs `evals/evals.config.ts` or
|
|
110
|
+
`evals/evals.config.js`, and it must set `maxConcurrency`. Each case
|
|
111
|
+
issues real model-provider requests, so concurrency is capped hard at
|
|
112
|
+
200. Existing projects use 20. Discovery with `eval --list` works
|
|
113
|
+
without this file, but running a case does not.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { defineEvalConfig } from "@cursor/july/evals";
|
|
117
|
+
|
|
118
|
+
export default defineEvalConfig({
|
|
119
|
+
maxConcurrency: 20, // required
|
|
120
|
+
// timeoutMs: 180_000, // optional project-wide default
|
|
121
|
+
// judge: { model: "..." }, // default judge model for t.judge.*
|
|
122
|
+
// reporters: [], // destinations that observe every case
|
|
123
|
+
// maxPlaygroundRuns: 50, // playground /v1/dev/evals history only (default 20)
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The timeout order is case or file `timeoutMs`, CLI `--timeout-ms`,
|
|
128
|
+
project config `timeoutMs`, then the 180-second runner default.
|
|
129
|
+
|
|
130
|
+
The optional fields:
|
|
131
|
+
|
|
132
|
+
| Option | Default | Meaning |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| `timeoutMs` | `180_000` | Project-wide per-case timeout |
|
|
135
|
+
| `judge` | unset | Default judge model for `t.judge.*`; see [Judge free-form output](#judge-free-form-output) |
|
|
136
|
+
| `reporters` | unset | Destinations that observe every case; `--skip-report` suppresses them |
|
|
137
|
+
| `maxPlaygroundRuns` | `20` | Max batches in the playground / `/v1/dev/evals*` history (not CLI `eval`) |
|
|
138
|
+
|
|
139
|
+
Reporters come from `@cursor/july/evals/reporters`: `JUnit` writes a
|
|
140
|
+
JUnit XML file for CI, `Artifacts` writes per-case files, and
|
|
141
|
+
`combineReporters` merges several into one (`renderJUnitXml` renders
|
|
142
|
+
the XML for a custom destination). A file or case can add its own
|
|
143
|
+
`reporters` on top of the config list.
|
|
144
|
+
|
|
145
|
+
Playground batches survive restarts whenever `agent/storage.ts` exists
|
|
146
|
+
with an `evals` table or a KV core providing `delete` and `list` (the
|
|
147
|
+
table is derived over the core); see
|
|
148
|
+
[Storage](/docs/storage.md#eval-and-a-b-tables). Without storage they live
|
|
149
|
+
in process memory and disappear when `serve` exits — navigating away
|
|
150
|
+
and back still works while the process is up.
|
|
151
|
+
|
|
152
|
+
## Drive and assert with `t`
|
|
153
|
+
|
|
154
|
+
`t` is both the driver and the assertion surface. You write ordinary
|
|
155
|
+
control flow, sending turns and asserting inline.
|
|
156
|
+
|
|
157
|
+
Drive the agent with `t.send(message, options?)`. It runs one turn and
|
|
158
|
+
waits for the session to park or fail. Multiple sends in one case share
|
|
159
|
+
the session, which is how you write multi-turn evals.
|
|
160
|
+
|
|
161
|
+
Each `t.send` resolves to a turn result with `message`, `sessionId`,
|
|
162
|
+
`events`, `toolCalls`, `ok`, and `index`. The turn carries the same
|
|
163
|
+
assertion vocabulary as `t`, scoped to that turn, so you can grade an
|
|
164
|
+
intermediate turn before the next send overwrites `t.reply`.
|
|
165
|
+
`turn.expectOk()` throws when the turn failed, for later steps that
|
|
166
|
+
depend on it.
|
|
167
|
+
|
|
168
|
+
Read the full case state with `t.reply` (the last assistant text),
|
|
169
|
+
`t.events` (every captured session event across turns), `t.turns`
|
|
170
|
+
(settled turns, oldest first), and `t.sessionId`. `t.signal` aborts
|
|
171
|
+
when the case hits its timeout; pass it to your own async work.
|
|
172
|
+
|
|
173
|
+
Assert with the gates:
|
|
174
|
+
|
|
175
|
+
| Gate | Checks |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| `t.succeeded()` | the run did not fail and is not parked on an unanswered approval |
|
|
178
|
+
| `t.parked()` | the run cleanly parked on an unanswered approval request |
|
|
179
|
+
| `t.messageIncludes(token)` | the joined assistant text matches a string or `RegExp` |
|
|
180
|
+
| `t.calledTool(name, matcher?)` | a matching call to `name` happened |
|
|
181
|
+
| `t.notCalledTool(name)` | no request for `name`, in any lifecycle state |
|
|
182
|
+
| `t.loadedSkill(name)` | the agent opened the skill's `SKILL.md` (read, grep, or shell `cat`) |
|
|
183
|
+
| `t.toolOrder(names)` | tool requests appear in this relative order (extra calls allowed) |
|
|
184
|
+
| `t.usedNoTools()` | no tool calls at all |
|
|
185
|
+
| `t.maxToolCalls(max)` | at most `max` tool calls |
|
|
186
|
+
| `t.noFailedActions()` | no tool call reported an error |
|
|
187
|
+
| `t.calledSubagent(name, matcher?)` | a matching subagent delegation happened |
|
|
188
|
+
| `t.taggedArtifact(kind?, predicate?)` | at least one [artifact](/docs/reference/artifacts.md) was tagged |
|
|
189
|
+
| `t.event(type, matcher?)` | at least one matching event of `type` occurred |
|
|
190
|
+
| `t.notEvent(type, matcher?)` | no matching event of `type` occurred |
|
|
191
|
+
| `t.eventOrder(matchers)` | matching event groups occur in this relative order |
|
|
192
|
+
| `t.eventsSatisfy(label, predicate)` | your predicate over the typed event stream |
|
|
193
|
+
| `t.check(value, expectation)` | any value, against a builder |
|
|
194
|
+
| `t.score(name, value)` | records a 0–1 score you computed; soft until you add a bar |
|
|
195
|
+
| `t.requireToolCall(name, matcher?)` | gates on a matching call and returns it, so later code can read its input and output |
|
|
196
|
+
| `t.requireInputRequest(filter?)` | gates on exactly one pending approval request and returns it |
|
|
197
|
+
|
|
198
|
+
Every gate returns a handle: `.soft()` demotes it to tracked-only,
|
|
199
|
+
`.atLeast(0.7)` adds a soft score bar, and `.gate(0.8)` promotes a
|
|
200
|
+
scored assertion into a hard gate.
|
|
201
|
+
|
|
202
|
+
With no matcher, `calledTool` is request-based: a requested call counts
|
|
203
|
+
even when its result has not arrived. Pass
|
|
204
|
+
`t.calledTool("inspect_pr", { status: "completed" })` to require the
|
|
205
|
+
call to return. `input`, `output`, and `count` matcher fields accept a
|
|
206
|
+
literal, a `RegExp`, or a predicate.
|
|
207
|
+
|
|
208
|
+
The expectation builders are `includes(string | RegExp)`,
|
|
209
|
+
`equals(value)`, `matches(schema)`, `similarity(expected)`, and
|
|
210
|
+
`satisfies(predicate, label)`. `includes` stringifies its input,
|
|
211
|
+
`equals` compares values deeply, `matches` validates against a Standard
|
|
212
|
+
Schema (or anything with `safeParse`, like Zod), `similarity` scores
|
|
213
|
+
normalized text similarity, and `satisfies` runs your predicate. The
|
|
214
|
+
plain function `normalizedSimilarity(actual, expected)` returns the
|
|
215
|
+
same 0–1 score for use with `t.score`.
|
|
216
|
+
|
|
217
|
+
A few more context members shape a case: `t.require(value, expectation)`
|
|
218
|
+
records a gate and stops the test body when it fails, without a
|
|
219
|
+
duplicate execution error. `t.skip(reason)` ends the case as skipped
|
|
220
|
+
(reported separately, never changes the exit code; call it before
|
|
221
|
+
sending messages). `t.metric(name, value)` records a structured score
|
|
222
|
+
for the playground case card. `t.log(message)` records a debug line for
|
|
223
|
+
the CLI and playground result.
|
|
224
|
+
|
|
225
|
+
Three `t.send` options apply on session create (first `t.send` only):
|
|
226
|
+
|
|
227
|
+
- `workspaceFiles` — `{ path: contents }`, seeded into the local session
|
|
228
|
+
workspace. Prefer this over machine-local paths.
|
|
229
|
+
- `workspaceDir` — absolute harness cwd (local runtime).
|
|
230
|
+
- `cloud` — per-session cloud options merged over the agent's static
|
|
231
|
+
`cloud` config (repos / env / …). Use a pinned `repos` override to
|
|
232
|
+
attach a fixture repo for cloud evals without putting it on the
|
|
233
|
+
agent's default `cloud.repos`. Cloud ignores `workspaceFiles` seeds.
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const toolResults = t.events.filter((e) => e.type === "action.result");
|
|
237
|
+
t.check(
|
|
238
|
+
toolResults.length,
|
|
239
|
+
satisfies((n) => (n as number) <= 4, "at most 4 tool calls")
|
|
240
|
+
);
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
A case with no explicit gates falls back to whether at least one turn
|
|
244
|
+
completed successfully. Add `t.succeeded()` and behavior-specific gates
|
|
245
|
+
anyway. They make the contract visible during review.
|
|
246
|
+
|
|
247
|
+
### Judge free-form output
|
|
248
|
+
|
|
249
|
+
When wording matters and no regex captures it, `t.judge` grades the
|
|
250
|
+
reply with an LLM. The built-in graders are `factuality(expected)`,
|
|
251
|
+
`summarizes(expected)`, `closedQA(criteria)`, and `sql(expected)`. Each
|
|
252
|
+
scores `t.reply` by default; pass `{ on }` to grade another value.
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
t.judge.factuality("It is 54°F in NYC right now.").atLeast(0.7);
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Judge assertions are soft by default, so a judge never fails a build
|
|
259
|
+
until you give it a bar with `.atLeast(0.7)` or promote it with
|
|
260
|
+
`.gate(0.8)`. The judge model comes from `defineEvalConfig({ judge })`,
|
|
261
|
+
`defineEval({ judge })`, a case-level `judge`, or a per-call
|
|
262
|
+
`{ model }` override; the nearest one wins. For a domain-specific judge
|
|
263
|
+
whose verdict is not a single score, `t.judge.model(prompt)` sends a
|
|
264
|
+
raw prompt to the same model and returns the reply. You then record the
|
|
265
|
+
parsed result with `t.score` or `t.check`.
|
|
266
|
+
|
|
267
|
+
## Run evals from the CLI
|
|
268
|
+
|
|
269
|
+
The `eval` command discovers, filters, and runs cases.
|
|
270
|
+
|
|
271
|
+
Run the CLI under Node 22.13 or newer. Do not use Bun. Its HTTP/2 client
|
|
272
|
+
breaks tool-result streams and causes eval turns to fail.
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
agent-sdk eval --dir . --list # discover only
|
|
276
|
+
agent-sdk eval --dir . # run all
|
|
277
|
+
agent-sdk eval --dir . builds/checkout # one datapoint
|
|
278
|
+
agent-sdk eval --dir . builds search # several ids or prefixes
|
|
279
|
+
agent-sdk eval --dir . --tag smoke --tag pull-request # any matching tag
|
|
280
|
+
agent-sdk eval --dir . --json --no-stream # machine-readable results
|
|
281
|
+
agent-sdk eval --dir . --verbose # logs + reply snippets
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Id filters use OR semantics. Each filter selects an exact id and its
|
|
285
|
+
descendants. For example, `builds` selects `builds`,
|
|
286
|
+
`builds/checkout`, and every other case below that path. Repeated tags
|
|
287
|
+
also use OR semantics. When you provide both ids and tags, a case must
|
|
288
|
+
match both groups.
|
|
289
|
+
|
|
290
|
+
`eval` boots an ephemeral server on port 0 with a temp state root
|
|
291
|
+
outside the project, so cases don't inherit ambient monorepo rules and
|
|
292
|
+
don't pollute `.agent-serve/`. Point `--url` at a running server to eval
|
|
293
|
+
a live agent instead:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
agent-sdk eval --dir . \
|
|
297
|
+
--url http://127.0.0.1:3000/weather-agent \
|
|
298
|
+
--bearer-token "$AGENT_TOKEN"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
The eval definitions still come from `--dir`; `--url` only changes the
|
|
302
|
+
agent that receives the turns. For a locally mounted multi-agent
|
|
303
|
+
directory, `--slug weather-agent` chooses the target. Use
|
|
304
|
+
`--state-root` to keep ephemeral session state at a chosen path,
|
|
305
|
+
`--timeout-ms` to override the project timeout, and `--no-stream` to
|
|
306
|
+
keep live progress off stderr. A TTY streams turn progress by default.
|
|
307
|
+
`--verbose` still writes `t.log` lines to stderr and adds reply snippets
|
|
308
|
+
to text results.
|
|
309
|
+
|
|
310
|
+
Model turns need a Cursor credential from `agent-sdk login` or
|
|
311
|
+
`CURSOR_API_KEY`.
|
|
312
|
+
|
|
313
|
+
See [CLI: eval](/docs/reference/cli.md#eval) for flags and exit codes.
|
|
314
|
+
|
|
315
|
+
### JSON results
|
|
316
|
+
|
|
317
|
+
Use `--json --no-stream` in scripts and CI. The top-level result carries
|
|
318
|
+
the totals and one result per case:
|
|
319
|
+
|
|
320
|
+
```json
|
|
321
|
+
{
|
|
322
|
+
"ok": true,
|
|
323
|
+
"passed": 1,
|
|
324
|
+
"failed": 0,
|
|
325
|
+
"results": [
|
|
326
|
+
{
|
|
327
|
+
"id": "readiness",
|
|
328
|
+
"ok": true,
|
|
329
|
+
"assertions": [{ "name": "succeeded", "passed": true }],
|
|
330
|
+
"sessionId": "ses_123",
|
|
331
|
+
"inputs": ["Is checkout pull request 42 ready to approve?"],
|
|
332
|
+
"toolCalls": [{ "toolName": "inspect_pr", "isError": false }],
|
|
333
|
+
"logs": [],
|
|
334
|
+
"durationMs": 12340
|
|
335
|
+
}
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Each case result can also include `description`, `finalText`, `tools`,
|
|
341
|
+
`error`, and tool arguments or output. This shape lets CI report the
|
|
342
|
+
failed assertion without parsing terminal text.
|
|
343
|
+
|
|
344
|
+
## Run evals in the playground
|
|
345
|
+
|
|
346
|
+
Start the server with `--dev`, open the playground, and choose
|
|
347
|
+
**Evals**. You can run every case or one case, watch progress, and open
|
|
348
|
+
the resulting session trace.
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
agent-sdk serve --dir . --dev
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
Playground runs target the live server instead of an ephemeral one.
|
|
355
|
+
Their sessions appear in the session list. One eval batch can run at a
|
|
356
|
+
time. Batches persist across restarts whenever `agent/storage.ts`
|
|
357
|
+
provides an `evals` table or a KV core with `delete` and `list` (the
|
|
358
|
+
table is derived over the core); without storage they are **in-memory
|
|
359
|
+
only** (capped by `maxPlaygroundRuns`) — see
|
|
360
|
+
[Storage](/docs/storage.md#eval-and-a-b-tables).
|
|
361
|
+
|
|
362
|
+
The UI uses the playground eval routes (available without `--dev`):
|
|
363
|
+
`GET /v1/dev/evals` lists datapoints and config (includes `maxPlaygroundRuns` /
|
|
364
|
+
`durableRuns`),
|
|
365
|
+
`GET /v1/dev/evals/runs` rehydrates recent batches after navigation,
|
|
366
|
+
`POST /v1/dev/evals/runs` starts a batch (returns an **Eval ID** / `runId`),
|
|
367
|
+
`GET /v1/dev/evals/runs/:runId` polls it, and
|
|
368
|
+
`POST /v1/dev/evals/runs/:runId/cancel` cancels a running batch. See
|
|
369
|
+
[Playground eval routes](/docs/reference/http-api.md#playground-eval-routes).
|
|
370
|
+
The start request returns `202` while cases run in the background.
|
|
371
|
+
Poll until the snapshot status becomes `completed`, `failed`, or `cancelled`.
|
|
372
|
+
Configuration errors appear on a failed snapshot.
|
|
373
|
+
|
|
374
|
+
On `--prod` / `--url`, the CLI prints the Eval ID as soon as the batch is
|
|
375
|
+
accepted (and a Playground deep link with `?view=evals&evalRunId=…`):
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
agent-sdk eval --prod --slug vulnerability-scanner --tag deepsec
|
|
379
|
+
# Eval ID: evalrun_…
|
|
380
|
+
# Cancel: agent-sdk eval cancel evalrun_… --prod --slug vulnerability-scanner
|
|
381
|
+
# Playground: https://…/playground?view=evals&evalRunId=evalrun_…
|
|
382
|
+
|
|
383
|
+
agent-sdk eval cancel evalrun_… --prod --slug vulnerability-scanner
|
|
384
|
+
agent-sdk eval status evalrun_… --prod --slug vulnerability-scanner
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
The Evals tab prefers the server’s in-flight batch (`activeRunId`) over a
|
|
388
|
+
stale tab-local remembered id, so CLI / Slack kicks show up without an
|
|
389
|
+
incognito window.
|
|
390
|
+
|
|
391
|
+
## What good cases assert
|
|
392
|
+
|
|
393
|
+
Gate decisions and shape, not prose. Model wording varies run to run.
|
|
394
|
+
Tool choice, tool avoidance, and output structure are the stable
|
|
395
|
+
contract.
|
|
396
|
+
|
|
397
|
+
1. `t.succeeded()`: always, first.
|
|
398
|
+
2. The tool decision: `calledTool` for the intended path,
|
|
399
|
+
`notCalledTool` for the likely wrong alternative. The pair is
|
|
400
|
+
stronger than either alone.
|
|
401
|
+
3. Output shape: a regex for the contract (`/ready|blocked/i`, a JSON
|
|
402
|
+
marker, a findings-block fence), never exact sentences.
|
|
403
|
+
4. For structured output, parse `t.reply` and check fields with
|
|
404
|
+
`satisfies` instead of substring-matching JSON.
|
|
405
|
+
|
|
406
|
+
The common failure modes: asserting exact phrasing, packing more than
|
|
407
|
+
about five gates into one case (split it), and cases that depend on live
|
|
408
|
+
external state that drifts (pin the input; see fixtures).
|
|
409
|
+
|
|
410
|
+
## Pick fixtures by agent type
|
|
411
|
+
|
|
412
|
+
The right fixture depends on the surface under test.
|
|
413
|
+
|
|
414
|
+
| Agent surface | Fixture |
|
|
415
|
+
| --- | --- |
|
|
416
|
+
| Chat / domain assistant | A canonical prompt string, chosen once and frozen |
|
|
417
|
+
| Tool-heavy | Run `agent-sdk call <tool>` first to pin what the tool returns, then freeze the prompt that triggers it |
|
|
418
|
+
| GitHub webhook | `agent-sdk github replay <pr> --events '*' --dry-run --out fixtures/github` snapshots real payloads for offline replay ([GitHub guide](/docs/guides/github.md)) |
|
|
419
|
+
| PR reviewer with host preparation | Diff, metadata, and gold labels pinned to commit SHAs; keep any live PR matrix small |
|
|
420
|
+
| Workspace-dependent | `workspaceFiles` in `t.send` options, never developer-machine paths |
|
|
421
|
+
|
|
422
|
+
Tag the fast, reliably passing core `smoke` and run `--tag smoke` in the
|
|
423
|
+
inner loop. Leave slow or flaky-prone cases untagged for explicit runs.
|
|
424
|
+
|
|
425
|
+
### Materialize API-backed fixtures
|
|
426
|
+
|
|
427
|
+
An input that only points at external data, such as a pull request URL,
|
|
428
|
+
snapshot id, or pair of commit SHAs, is not self-contained. Fetch it
|
|
429
|
+
once and commit the rendered fixture before you expand the suite.
|
|
430
|
+
|
|
431
|
+
1. Save the diff, metadata, and labels under `fixtures/` at pinned
|
|
432
|
+
revisions.
|
|
433
|
+
2. Seed those files with `workspaceFiles`, or read them from the fixture
|
|
434
|
+
directory.
|
|
435
|
+
3. Assert decisions and output shape against the saved evidence.
|
|
436
|
+
4. Keep a small `smoke` subset for any remaining live pipeline checks.
|
|
437
|
+
|
|
438
|
+
Read committed fixtures with `@cursor/july/evals/loaders`: `loadJson`,
|
|
439
|
+
`loadJsonl`, and `loadYaml` resolve relative paths against the project
|
|
440
|
+
root the runner discovered, not the cwd the CLI was invoked from
|
|
441
|
+
(`resolveFixturePath` and `evalFixtureRoot` expose the same
|
|
442
|
+
resolution for other file formats).
|
|
443
|
+
|
|
444
|
+
`maxConcurrency` limits parallel datapoints. It does not limit model or
|
|
445
|
+
API fan-out inside one datapoint. Materialized fixtures prevent a large
|
|
446
|
+
suite from exhausting provider and GitHub rate limits. The
|
|
447
|
+
[evals skill](https://github.com/cursor/cursor/blob/main/packages/agent-serve/skills/evals/SKILL.md) has the full fixture workflow.
|
|
448
|
+
|
|
449
|
+
## Keep improvements with regression evals
|
|
450
|
+
|
|
451
|
+
Every [hillclimb](/docs/hillclimbing.md) round that keeps a change must land
|
|
452
|
+
an eval that would have failed before the change. If you can't express
|
|
453
|
+
the improvement as a gate (a `calledTool` shift, a bounded
|
|
454
|
+
`action.result` count, an output-shape regex), the improvement is
|
|
455
|
+
unverified, and it'll regress silently.
|
|
456
|
+
|
|
457
|
+
The rule cuts the other way too: never weaken an existing gate to make a
|
|
458
|
+
round pass. That's the freeze line moving, and it turns your regression
|
|
459
|
+
suite into a list of checks that no longer protect anything.
|
|
460
|
+
|
|
461
|
+
## Compare variants on live traffic
|
|
462
|
+
|
|
463
|
+
Use `defineAB` to compare variant metrics on live sessions. It is not a
|
|
464
|
+
test runner and has no `agent-sdk ab` command. Keep `defineEval` as the
|
|
465
|
+
regression ratchet. Eval sessions do not enroll or change live metrics.
|
|
466
|
+
See [Live A/B metrics](/docs/ab.md) for assignment, behavior, collection,
|
|
467
|
+
and inspection.
|
|
468
|
+
|
|
469
|
+
## What's next
|
|
470
|
+
|
|
471
|
+
Continue with these pages:
|
|
472
|
+
|
|
473
|
+
- [Live A/B metrics](/docs/ab.md): sticky variants and cumulative metrics
|
|
474
|
+
on live sessions
|
|
475
|
+
- [Hillclimbing](/docs/hillclimbing.md): the loop evals make trustworthy
|
|
476
|
+
- [Building agents with agents](/docs/building-with-agents.md): have a
|
|
477
|
+
coding agent write the first suite
|
|
478
|
+
- [GitHub guide](/docs/guides/github.md): deterministic webhook fixtures
|
|
479
|
+
with `github replay`
|
|
480
|
+
- [Sessions and streaming](/docs/reference/sessions.md): the events
|
|
481
|
+
`t.events` contains
|