@ouispec/agent-evals 0.20.1 → 0.22.0
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/README.md +7 -4
- package/dist/cassettes.d.ts +6 -0
- package/dist/cassettes.d.ts.map +1 -1
- package/dist/cassettes.js +8 -2
- package/dist/cassettes.js.map +1 -1
- package/dist/cli.js +9 -8
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +30 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +14 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/judge.d.ts +30 -4
- package/dist/judge.d.ts.map +1 -1
- package/dist/judge.js +65 -14
- package/dist/judge.js.map +1 -1
- package/dist/memory.d.ts +81 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +32 -2
- package/dist/memory.js.map +1 -1
- package/dist/page.d.ts +56 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +526 -0
- package/dist/page.js.map +1 -0
- package/dist/report.d.ts +10 -2
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +23 -15
- package/dist/report.js.map +1 -1
- package/dist/run.d.ts +45 -5
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +240 -47
- package/dist/run.js.map +1 -1
- package/dist/suite.d.ts.map +1 -1
- package/dist/suite.js +37 -1
- package/dist/suite.js.map +1 -1
- package/dist/usage.d.ts +29 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +65 -0
- package/dist/usage.js.map +1 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -6,13 +6,16 @@ Agent evals as data, run against your real agent configuration on every channel
|
|
|
6
6
|
npm install --save-dev @ouispec/agent-evals
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
- **Scenarios are data.** A suite is a JSON or YAML file (the contract's `agent-evals.json`): what the customer says turn by turn, their answer to an approval, a person on the staff taking the conversation over and handing it back, and what must hold after each turn. That covers what the reply must and must not say (text, a regular expression, or a rubric a judge model decides), the tools called with given arguments, the tools not called, an approval asked for with its readback, a refusal, what the turn must not store,
|
|
10
|
-
- **Your real configuration.** `defineEvals({ agent })` returns the same persona, tools, `ToolPolicy`, `TurnPolicy
|
|
9
|
+
- **Scenarios are data.** A suite is a JSON or YAML file (the contract's `agent-evals.json`): what the customer says turn by turn, their answer to an approval, a person on the staff taking the conversation over and handing it back, and what must hold after each turn. That covers what the reply must and must not say (text, a regular expression, or a rubric a judge model decides), the tools called with given arguments, the tools not called, how many times a tool or a page action was called (`calls`), an approval asked for with its readback, a refusal, what the turn must not store, a turn not run while a person holds the conversation, the turn's token budgets and the share read from the prompt cache (`usage`), the choice buttons it offered (`choices`), and where the page went and what ran on it (`page`).
|
|
10
|
+
- **Your real configuration.** `defineEvals({ agent })` returns the same persona, tools, `ToolPolicy`, `TurnPolicy`, hooks (`beforeTurn`, `filterEvent`, `approvals.preview` and `approvals.validateBeforeApproval`), `modelProviderOptions`, `forcedToolChoice` and `uiActions` settings your worker runs with. The harness runs them through the SDK's own turn runner, and replaces only what reaches the outside: the model's network, storage, the realtime server, the person's page, and each tool's execution, by its stub. A tool call with no stub fails the case: an eval never reaches a backend.
|
|
11
|
+
- **A page that answers.** A suite declares the page its turns are sent from (`page`): surfaces of its own, or your own controls from your generated manifest (`defineEvals({ page: { manifest, knowledge } })`), mounted with a real binding registry and `connectBindings` as your tab mounts them. It runs on a real oui-spec surface runtime, answers `ui_act`, `ui_describe` and `ui_read`, and goes where `app.navigate` sends it; the next turn is sent from there. What your pages show that is not a control (`shown`: the Home's numbers, a list's cards) and the problems they show (`problems`) are declared in the runtime's own shape and reported in the page state as your tab reports them, a long list indexed by its rows and read further with `ui_read`. A control bound to a query parameter (`query`) shows the address's value through your page's declared query, follows `app.navigate`'s query, and writes its value back to the address. `createFixturePage` builds one for your own tests.
|
|
12
|
+
- **Your conversation store.** `history` plugs in your store (`EvalHistory`), or your window over the whole conversation (`createMemoryHistory({ window })`), so later turns read what your worker reads. Each read is given the turn it is for (`request.turn`: its id, scenario, channel, customer, context and page).
|
|
11
13
|
- **Every channel.** Name your channels (`web_chat`, `sms`, `voice`) and what each changes: how an approval is confirmed (the card, or a readback the next message confirms), and whether a message was spoken. Every scenario runs on every channel, so the channels cannot drift apart.
|
|
12
|
-
- **Recorded in CI, live on demand.** `agent-evals` replays each scenario's recording through your real provider package, with no network and no credentials. `agent-evals --record` runs the live model and writes the recordings; `--live` runs it without writing. A recording knows the configuration it was made against: change the prompt, a tool or
|
|
14
|
+
- **Recorded in CI, live on demand.** `agent-evals` replays each scenario's recording through your real provider package, with no network and no credentials. `agent-evals --record` runs the live model and writes the recordings; `--live` runs it without writing. A recording knows the configuration it was made against: change the prompt, a tool, a scenario or its page, and its replay fails until you record it again.
|
|
15
|
+
- **A judge that answers.** A rubric's verdict is asked for as structured output and asked again when it is no verdict (`judgeOptions`). A judge that never gives one is reported apart from a failure: the case is `unjudged` (`JUDGE`, a JUnit `error`, exit 3 when nothing failed).
|
|
13
16
|
|
|
14
17
|
```sh
|
|
15
|
-
agent-evals # replay: the CI gate (exit 1 on any failed assertion)
|
|
18
|
+
agent-evals # replay: the CI gate (exit 1 on any failed assertion, 3 when only the judge failed)
|
|
16
19
|
agent-evals --record # run the live model and write the recordings
|
|
17
20
|
agent-evals --channel sms --scenario price-only --junit evals.xml
|
|
18
21
|
```
|
package/dist/cassettes.d.ts
CHANGED
|
@@ -28,6 +28,12 @@ export interface FingerprintInputs {
|
|
|
28
28
|
};
|
|
29
29
|
suite: AgentEvalSuite;
|
|
30
30
|
scenario: AgentEvalScenario;
|
|
31
|
+
/** The scenario's page, and the product's files it is built from: what the page's index and state the model reads come from. */
|
|
32
|
+
page?: unknown;
|
|
33
|
+
/** The agent's provider options, its forced-choice setting and its UI settings, when it has them. */
|
|
34
|
+
modelProviderOptions?: unknown;
|
|
35
|
+
forcedToolChoice?: boolean;
|
|
36
|
+
uiActions?: unknown;
|
|
31
37
|
}
|
|
32
38
|
export declare function fingerprint(inputs: FingerprintInputs): string;
|
|
33
39
|
//# sourceMappingURL=cassettes.d.ts.map
|
package/dist/cassettes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cassettes.d.ts","sourceRoot":"","sources":["../src/cassettes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cassettes.d.ts","sourceRoot":"","sources":["../src/cassettes.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,gBAAgB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AAKD,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3H;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAO1D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAGpE;AAED,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,WAAW,CAAA;KAAE,CAAC;IACjD,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,gIAAgI;IAChI,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,qGAAqG;IACrG,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CA2B7D"}
|
package/dist/cassettes.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The fingerprint is a hash of everything that shapes what the model is
|
|
6
6
|
* asked: the system prompt, the tools' names, descriptions and schemas, the
|
|
7
|
-
* channel's settings, the scenario's inputs
|
|
7
|
+
* channel's settings, the scenario's inputs, its page, the agent's provider
|
|
8
|
+
* and UI settings, and the rubrics its judge reads.
|
|
8
9
|
* A recording replayed against a changed configuration or scenario fails,
|
|
9
10
|
* rather than passing on answers to a question no longer asked.
|
|
10
11
|
*/
|
|
@@ -34,7 +35,7 @@ export function writeCassette(path, cassette) {
|
|
|
34
35
|
writeFileSync(path, `${JSON.stringify(cassette, null, 2)}\n`);
|
|
35
36
|
}
|
|
36
37
|
export function fingerprint(inputs) {
|
|
37
|
-
const { systemPrompt, tools, channel, suite, scenario } = inputs;
|
|
38
|
+
const { systemPrompt, tools, channel, suite, scenario, page, modelProviderOptions, forcedToolChoice, uiActions } = inputs;
|
|
38
39
|
const shaped = {
|
|
39
40
|
systemPrompt,
|
|
40
41
|
tools: [...tools]
|
|
@@ -53,6 +54,11 @@ export function fingerprint(inputs) {
|
|
|
53
54
|
// A turn's inputs; its expectations change nothing the model is asked, except a rubric's text.
|
|
54
55
|
turns: scenario.turns.map((turn) => ('user' in turn ? { user: turn.user } : 'approval' in turn ? { approval: turn.approval } : { staff: turn.staff })),
|
|
55
56
|
rubrics: rubricsOf(scenario),
|
|
57
|
+
// Only when given, so a recording made before they could be is still current.
|
|
58
|
+
...(page !== undefined ? { page } : {}),
|
|
59
|
+
...(modelProviderOptions !== undefined ? { modelProviderOptions } : {}),
|
|
60
|
+
...(forcedToolChoice !== undefined ? { forcedToolChoice } : {}),
|
|
61
|
+
...(uiActions !== undefined ? { uiActions } : {}),
|
|
56
62
|
};
|
|
57
63
|
return createHash('sha256').update(canonicalJson(shaped)).digest('hex');
|
|
58
64
|
}
|
package/dist/cassettes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cassettes.js","sourceRoot":"","sources":["../src/cassettes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cassettes.js","sourceRoot":"","sources":["../src/cassettes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAclC,iDAAiD;AACjD,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC;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AAC,EAAE,CAAC;QACvE,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAC;IACF,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
* it replays the recordings (CI: no credentials, no network); --record runs
|
|
11
11
|
* the live model and writes them; --live runs it and writes nothing.
|
|
12
12
|
*
|
|
13
|
-
* Exits 0 when every case passed, 1 when any failed, 2 when it could not run
|
|
13
|
+
* Exits 0 when every case passed, 1 when any failed, 2 when it could not run,
|
|
14
|
+
* and 3 when none failed but a rubric could not be judged (the judge gave no
|
|
15
|
+
* verdict, however often it was asked).
|
|
14
16
|
*/
|
|
15
17
|
import { existsSync, writeFileSync } from 'node:fs';
|
|
16
18
|
import { dirname, resolve } from 'node:path';
|
|
17
19
|
import { pathToFileURL } from 'node:url';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
+
import { caseLines, junitReport, summaryLine } from './report.js';
|
|
21
|
+
import { runEvals } from './run.js';
|
|
20
22
|
const USAGE = 'usage: agent-evals [--config <file>] [--record | --live] [--channel <name>]... [--scenario <id>]... [--json <file>] [--junit <file>] [--verbose]';
|
|
21
23
|
function parseArgs(argv) {
|
|
22
24
|
const args = { mode: 'replay', channels: [], scenarios: [], verbose: false };
|
|
@@ -129,9 +131,8 @@ async function main() {
|
|
|
129
131
|
...(parsed.scenarios.length ? { scenarios: parsed.scenarios } : {}),
|
|
130
132
|
onCase: (result) => {
|
|
131
133
|
restore();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
write(` ${failureLine(f)}`);
|
|
134
|
+
for (const line of caseLines(result))
|
|
135
|
+
write(line);
|
|
135
136
|
if (!parsed.verbose)
|
|
136
137
|
quietConsole();
|
|
137
138
|
},
|
|
@@ -141,12 +142,12 @@ async function main() {
|
|
|
141
142
|
restore();
|
|
142
143
|
}
|
|
143
144
|
write('');
|
|
144
|
-
write(
|
|
145
|
+
write(summaryLine(report));
|
|
145
146
|
if (parsed.json)
|
|
146
147
|
writeFileSync(resolve(parsed.json), `${JSON.stringify(report, null, 2)}\n`);
|
|
147
148
|
if (parsed.junit)
|
|
148
149
|
writeFileSync(resolve(parsed.junit), junitReport(report));
|
|
149
|
-
return report.failed > 0 ? 1 : 0;
|
|
150
|
+
return report.failed > 0 ? 1 : report.unjudged > 0 ? 3 : 0;
|
|
150
151
|
}
|
|
151
152
|
catch (err) {
|
|
152
153
|
process.stderr.write(`agent-evals: ${err instanceof Error ? err.message : String(err)}\n`);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,KAAK,GACT,kJAAkJ,CAAC;AAYrJ,SAAS,SAAS,CAAC,IAAuB;IACxC,MAAM,IAAI,GAAS,EAAE,IAAI,EAAE,QAAQ,E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AC,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
import type { ApprovalChannel, MessageInput } from '@ouispec/agent-core';
|
|
7
7
|
import type { AgentEvalScenario, AgentEvalSuite } from '@ouispec/contract';
|
|
8
8
|
import type { AgentRuntimeConfig, LanguageModel, ProviderOptions, ToolExecutionContext, ToolExecutionResult } from '@ouispec/agent-worker';
|
|
9
|
+
import type { JudgeOptions } from './judge.js';
|
|
10
|
+
import type { EvalHistory } from './memory.js';
|
|
11
|
+
import type { EvalPageSource } from './page.js';
|
|
9
12
|
/**
|
|
10
13
|
* How a run reaches the model:
|
|
11
14
|
* - `replay`: from the recordings, with no network and no credentials (CI);
|
|
@@ -33,13 +36,20 @@ export interface EvalChannel {
|
|
|
33
36
|
* only what reaches the outside (the model's network, storage, the realtime
|
|
34
37
|
* server, each tool's execution).
|
|
35
38
|
*/
|
|
36
|
-
export type EvalAgentConfig = Pick<AgentRuntimeConfig<unknown>, 'tools' | 'persona' | 'systemPrompt' | 'toolPolicy' | 'turnPolicy' | 'maxRounds' | 'maxTokens' | 'temperature' | 'toolTimeoutMs' | 'turnDeadlineMs' | 'retries' | 'beforeTurn' | 'filterEvent'> & {
|
|
39
|
+
export type EvalAgentConfig = Pick<AgentRuntimeConfig<unknown>, 'tools' | 'persona' | 'systemPrompt' | 'toolPolicy' | 'turnPolicy' | 'maxRounds' | 'maxTokens' | 'temperature' | 'toolTimeoutMs' | 'turnDeadlineMs' | 'retries' | 'beforeTurn' | 'filterEvent' | 'modelProviderOptions' | 'forcedToolChoice'> & {
|
|
37
40
|
/**
|
|
38
41
|
* The host's say before an approval is asked for, as its worker has it: its
|
|
39
42
|
* display copy (`preview`) and its check (`validateBeforeApproval`). The
|
|
40
43
|
* store is the harness's own.
|
|
41
44
|
*/
|
|
42
45
|
approvals?: Pick<NonNullable<AgentRuntimeConfig<unknown>['approvals']>, 'preview' | 'validateBeforeApproval'>;
|
|
46
|
+
/**
|
|
47
|
+
* How the worker works the page, as its worker has it: how long it waits
|
|
48
|
+
* for an answer, and how much of the page's index, state and answers the
|
|
49
|
+
* model is given. The channel is the harness's: the scenario's page
|
|
50
|
+
* answers, or, with none, nothing does.
|
|
51
|
+
*/
|
|
52
|
+
uiActions?: Omit<NonNullable<AgentRuntimeConfig<unknown>['uiActions']>, 'channel'>;
|
|
43
53
|
};
|
|
44
54
|
/** What the model factory is handed: the fetch every model request must go through, and why the model is wanted. */
|
|
45
55
|
export interface EvalModelSeam {
|
|
@@ -88,6 +98,25 @@ export interface AgentEvalConfig {
|
|
|
88
98
|
userId?: string;
|
|
89
99
|
accountId?: string;
|
|
90
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* The product's generated files a suite's page is built from: its manifest,
|
|
103
|
+
* for a page that mounts the product's own controls (`page.controls`), and
|
|
104
|
+
* its knowledge, which each turn carries for the page it is sent from.
|
|
105
|
+
*/
|
|
106
|
+
page?: EvalPageSource;
|
|
107
|
+
/**
|
|
108
|
+
* The product's conversation store for a scenario on a channel: what its
|
|
109
|
+
* worker's `getHistory` answers (its window, its summary, its step context)
|
|
110
|
+
* and how its `persistMessages` stores a turn. Default: the whole
|
|
111
|
+
* conversation, kept in memory (`createMemoryHistory()`).
|
|
112
|
+
*/
|
|
113
|
+
history?: (context: {
|
|
114
|
+
channel: string;
|
|
115
|
+
scenario: AgentEvalScenario;
|
|
116
|
+
suite: AgentEvalSuite;
|
|
117
|
+
}) => EvalHistory | Promise<EvalHistory>;
|
|
118
|
+
/** How a rubric's verdict is asked for: how many times again when the judge gives none, and how much it may write. */
|
|
119
|
+
judgeOptions?: JudgeOptions;
|
|
91
120
|
}
|
|
92
121
|
/** The configuration, as written: `defineEvals` checks nothing at run time beyond what TypeScript does, and returns it. */
|
|
93
122
|
export declare function defineEvals(config: AgentEvalConfig): AgentEvalConfig;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC3I,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEpD,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,6GAA6G;IAC7G,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,kBAAkB,CAAC,OAAO,C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[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAmIA,2HAA2H;AAC3H,MAAM,UAAU,WAAW,CAAC,MAAuB;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,22 +8,28 @@
|
|
|
8
8
|
* runner, from recorded model responses in CI or against the live model. A
|
|
9
9
|
* recording knows what it was recorded against, so a changed configuration
|
|
10
10
|
* fails until it is recorded again. Every tool is stubbed: an eval never
|
|
11
|
-
* reaches a real backend.
|
|
11
|
+
* reaches a real backend. The person's page is scripted too: a fixture
|
|
12
|
+
* surface runtime, the product's own controls or the suite's surfaces, that
|
|
13
|
+
* answers the agent's page actions and goes where they navigate.
|
|
12
14
|
*
|
|
13
15
|
* Run it with the `agent-evals` CLI, or inside a test runner with `evalCases`.
|
|
14
16
|
*/
|
|
15
17
|
export { defineEvals } from './config.js';
|
|
16
18
|
export type { AgentEvalConfig, EvalAgentConfig, EvalChannel, EvalMode, EvalModelSeam, EvalStubFunction } from './config.js';
|
|
17
19
|
export { evalCases, runEvals, runEvalCase, check, mergeExpectations, EvalCaseFailed, failureLine } from './run.js';
|
|
18
|
-
export type { EvalCase, EvalCaseResult, EvalFailure, EvalReport, EvalRunOptions, EvalTurnRecord } from './run.js';
|
|
20
|
+
export type { CheckFailure, EvalCase, EvalCaseResult, EvalChoices, EvalFailure, EvalReport, EvalRunOptions, EvalTurnRecord } from './run.js';
|
|
21
|
+
export { createFixturePage, EvalPageError } from './page.js';
|
|
22
|
+
export type { EvalPage, EvalPageRun, EvalPageSource } from './page.js';
|
|
23
|
+
export { recordingCalls, turnUsage } from './usage.js';
|
|
24
|
+
export type { EvalModelCall, EvalTurnUsage } from './usage.js';
|
|
19
25
|
export { checkSuite, readSuiteFile, rubricsOf, EvalSuiteError } from './suite.js';
|
|
20
26
|
export { DEFAULT_REFUSAL, describeMatcher, holdsSubset, matchesText } from './matchers.js';
|
|
21
|
-
export { judge, readVerdict, JUDGE_INSTRUCTIONS } from './judge.js';
|
|
22
|
-
export type { Verdict } from './judge.js';
|
|
27
|
+
export { judge, readVerdict, JUDGE_INSTRUCTIONS, VERDICT_SCHEMA } from './judge.js';
|
|
28
|
+
export type { JudgeFailure, JudgeOptions, Verdict } from './judge.js';
|
|
23
29
|
export { cassettePath, fingerprint, readCassette, writeCassette, CASSETTE_VERSION } from './cassettes.js';
|
|
24
30
|
export type { Cassette, FingerprintInputs } from './cassettes.js';
|
|
25
|
-
export { createMemoryApprovalStore, createMemoryEmit, createMemoryStops, NO_PAGE } from './memory.js';
|
|
26
|
-
export type { EmittedEvent, MemoryApprovalStore, MemoryStops } from './memory.js';
|
|
27
|
-
export { formatReport, junitReport } from './report.js';
|
|
28
|
-
export type { AgentEvalSuite, AgentEvalScenario, AgentEvalTurn, AgentEvalUserTurn, AgentEvalApprovalTurn, AgentEvalStaffTurn, AgentEvalExpectation, AgentEvalTextMatcher, AgentEvalToolCall, AgentEvalApprovalExpectation, AgentEvalStubCase, AgentEvalStubs, } from '@ouispec/contract';
|
|
31
|
+
export { createMemoryApprovalStore, createMemoryEmit, createMemoryHistory, createMemoryStops, NO_PAGE } from './memory.js';
|
|
32
|
+
export type { EmittedEvent, EvalHistory, EvalHistoryRequest, EvalHistoryTurn, MemoryApprovalStore, MemoryHistoryOptions, MemoryStops } from './memory.js';
|
|
33
|
+
export { caseLines, formatReport, junitReport, statusWord, summaryLine } from './report.js';
|
|
34
|
+
export type { AgentEvalSuite, AgentEvalScenario, AgentEvalTurn, AgentEvalUserTurn, AgentEvalApprovalTurn, AgentEvalStaffTurn, AgentEvalExpectation, AgentEvalTextMatcher, AgentEvalToolCall, AgentEvalApprovalExpectation, AgentEvalStubCase, AgentEvalStubs, AgentEvalPage, AgentEvalPageSurface, AgentEvalPageAction, AgentEvalPageControl, AgentEvalShown, AgentEvalProblems, AgentEvalShownQuery, AgentEvalShownRoutes, AgentEvalPageExpectation, AgentEvalCallCount, AgentEvalUsage, AgentEvalBound, AgentEvalShareBound, AgentEvalChoicesExpectation, } from '@ouispec/contract';
|
|
29
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC5H,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACnH,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7I,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC7D,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACpF,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC1G,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3H,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1J,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5F,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,4BAA4B,EAC5B,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,16 +8,20 @@
|
|
|
8
8
|
* runner, from recorded model responses in CI or against the live model. A
|
|
9
9
|
* recording knows what it was recorded against, so a changed configuration
|
|
10
10
|
* fails until it is recorded again. Every tool is stubbed: an eval never
|
|
11
|
-
* reaches a real backend.
|
|
11
|
+
* reaches a real backend. The person's page is scripted too: a fixture
|
|
12
|
+
* surface runtime, the product's own controls or the suite's surfaces, that
|
|
13
|
+
* answers the agent's page actions and goes where they navigate.
|
|
12
14
|
*
|
|
13
15
|
* Run it with the `agent-evals` CLI, or inside a test runner with `evalCases`.
|
|
14
16
|
*/
|
|
15
17
|
export { defineEvals } from './config.js';
|
|
16
18
|
export { evalCases, runEvals, runEvalCase, check, mergeExpectations, EvalCaseFailed, failureLine } from './run.js';
|
|
19
|
+
export { createFixturePage, EvalPageError } from './page.js';
|
|
20
|
+
export { recordingCalls, turnUsage } from './usage.js';
|
|
17
21
|
export { checkSuite, readSuiteFile, rubricsOf, EvalSuiteError } from './suite.js';
|
|
18
22
|
export { DEFAULT_REFUSAL, describeMatcher, holdsSubset, matchesText } from './matchers.js';
|
|
19
|
-
export { judge, readVerdict, JUDGE_INSTRUCTIONS } from './judge.js';
|
|
23
|
+
export { judge, readVerdict, JUDGE_INSTRUCTIONS, VERDICT_SCHEMA } from './judge.js';
|
|
20
24
|
export { cassettePath, fingerprint, readCassette, writeCassette, CASSETTE_VERSION } from './cassettes.js';
|
|
21
|
-
export { createMemoryApprovalStore, createMemoryEmit, createMemoryStops, NO_PAGE } from './memory.js';
|
|
22
|
-
export { formatReport, junitReport } from './report.js';
|
|
25
|
+
export { createMemoryApprovalStore, createMemoryEmit, createMemoryHistory, createMemoryStops, NO_PAGE } from './memory.js';
|
|
26
|
+
export { caseLines, formatReport, junitReport, statusWord, summaryLine } from './report.js';
|
|
23
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEnH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE1G,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3H,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/judge.d.ts
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rubric's verdict: a judge model reads the customer's
|
|
3
|
+
* message, the agent's reply and the rubric, and answers whether the reply
|
|
4
|
+
* does what the rubric says. Its call goes through the same fetch as the
|
|
5
|
+
* agent's, so in CI it is replayed from the scenario's recording like every
|
|
6
|
+
* other model response.
|
|
7
|
+
*
|
|
8
|
+
* The verdict is asked for as structured output (`Output.object`): the
|
|
9
|
+
* provider package chooses how its model gives an object (a JSON schema, a
|
|
10
|
+
* forced tool, or instructions for a model that refuses a forced tool). An
|
|
11
|
+
* answer that is still not a verdict is read as text, then asked for again;
|
|
12
|
+
* a judge that never gives one is a judge failure, reported apart from the
|
|
13
|
+
* case's assertions: the reply was not found wanting, it was not judged.
|
|
14
|
+
*/
|
|
15
|
+
import { jsonSchema } from 'ai';
|
|
1
16
|
import type { LanguageModel } from '@ouispec/agent-worker';
|
|
2
17
|
export interface Verdict {
|
|
3
18
|
pass: boolean;
|
|
4
19
|
reason: string;
|
|
5
20
|
}
|
|
21
|
+
/** A judge that gave no verdict, with what it answered each time it was asked. */
|
|
22
|
+
export interface JudgeFailure {
|
|
23
|
+
error: string;
|
|
24
|
+
attempts: number;
|
|
25
|
+
}
|
|
6
26
|
export declare const JUDGE_INSTRUCTIONS: string;
|
|
27
|
+
/** What the judge is asked for: a verdict and one sentence why. */
|
|
28
|
+
export declare const VERDICT_SCHEMA: Parameters<typeof jsonSchema>[0] & object;
|
|
29
|
+
export interface JudgeOptions {
|
|
30
|
+
/** How many times a judge that gave no verdict is asked again. Default 2. */
|
|
31
|
+
retries?: number;
|
|
32
|
+
/** The most the judge may write, thinking included. Default 1024. */
|
|
33
|
+
maxOutputTokens?: number;
|
|
34
|
+
}
|
|
7
35
|
/** The JSON object in a judge's answer, or why there is none. */
|
|
8
36
|
export declare function readVerdict(text: string): Verdict | {
|
|
9
37
|
error: string;
|
|
10
38
|
};
|
|
11
|
-
/** Ask the judge whether `reply` does what `rubric` says. */
|
|
12
|
-
export declare function judge(model: LanguageModel, rubric: string, customer: string, reply: string): Promise<Verdict |
|
|
13
|
-
error: string;
|
|
14
|
-
}>;
|
|
39
|
+
/** Ask the judge whether `reply` does what `rubric` says: a verdict, or a judge failure after every retry. */
|
|
40
|
+
export declare function judge(model: LanguageModel, rubric: string, customer: string, reply: string, options?: JudgeOptions): Promise<Verdict | JudgeFailure>;
|
|
15
41
|
//# sourceMappingURL=judge.d.ts.map
|
package/dist/judge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judge.d.ts","sourceRoot":"","sources":["../src/judge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"judge.d.ts","sourceRoot":"","sources":["../src/judge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAgB,UAAU,EAAkC,MAAM,IAAI,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,QAG+C,CAAC;AAE/E,mEAAmE;AACnE,eAAO,MAAM,cAAc,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,MAQ/D,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,iEAAiE;AACjE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CASrE;AAQD,8GAA8G;AAC9G,wBAAsB,KAAK,CACzB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,OAAO,GAAG,YAAY,CAAC,CAcjC"}
|
package/dist/judge.js
CHANGED
|
@@ -4,11 +4,28 @@
|
|
|
4
4
|
* does what the rubric says. Its call goes through the same fetch as the
|
|
5
5
|
* agent's, so in CI it is replayed from the scenario's recording like every
|
|
6
6
|
* other model response.
|
|
7
|
+
*
|
|
8
|
+
* The verdict is asked for as structured output (`Output.object`): the
|
|
9
|
+
* provider package chooses how its model gives an object (a JSON schema, a
|
|
10
|
+
* forced tool, or instructions for a model that refuses a forced tool). An
|
|
11
|
+
* answer that is still not a verdict is read as text, then asked for again;
|
|
12
|
+
* a judge that never gives one is a judge failure, reported apart from the
|
|
13
|
+
* case's assertions: the reply was not found wanting, it was not judged.
|
|
7
14
|
*/
|
|
8
|
-
import { generateText } from 'ai';
|
|
15
|
+
import { generateText, jsonSchema, NoObjectGeneratedError, Output } from 'ai';
|
|
9
16
|
export const JUDGE_INSTRUCTIONS = 'You grade one reply of a customer-facing AI agent against one rubric. ' +
|
|
10
17
|
'Answer with only a JSON object and nothing else: {"pass": true or false, "reason": "one sentence"}. ' +
|
|
11
18
|
'"pass" is true only when the reply clearly does what the rubric describes.';
|
|
19
|
+
/** What the judge is asked for: a verdict and one sentence why. */
|
|
20
|
+
export const VERDICT_SCHEMA = {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
pass: { type: 'boolean', description: 'True only when the reply clearly does what the rubric describes.' },
|
|
24
|
+
reason: { type: 'string', description: 'Why, in one sentence.' },
|
|
25
|
+
},
|
|
26
|
+
required: ['pass', 'reason'],
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
};
|
|
12
29
|
/** The JSON object in a judge's answer, or why there is none. */
|
|
13
30
|
export function readVerdict(text) {
|
|
14
31
|
const start = text.indexOf('{');
|
|
@@ -16,23 +33,57 @@ export function readVerdict(text) {
|
|
|
16
33
|
if (start === -1 || end < start)
|
|
17
34
|
return { error: `the judge answered no JSON: ${JSON.stringify(text.slice(0, 200))}` };
|
|
18
35
|
try {
|
|
19
|
-
|
|
20
|
-
if (typeof value.pass !== 'boolean')
|
|
21
|
-
return { error: `the judge's answer has no boolean "pass": ${text.slice(start, end + 1)}` };
|
|
22
|
-
return { pass: value.pass, reason: typeof value.reason === 'string' ? value.reason : '' };
|
|
36
|
+
return asVerdict(JSON.parse(text.slice(start, end + 1)), text.slice(start, end + 1));
|
|
23
37
|
}
|
|
24
38
|
catch {
|
|
25
39
|
return { error: `the judge's answer is not JSON: ${JSON.stringify(text.slice(start, end + 1).slice(0, 200))}` };
|
|
26
40
|
}
|
|
27
41
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
function asVerdict(value, as) {
|
|
43
|
+
const verdict = (value ?? {});
|
|
44
|
+
if (typeof verdict.pass !== 'boolean')
|
|
45
|
+
return { error: `the judge's answer has no boolean "pass": ${as.slice(0, 200)}` };
|
|
46
|
+
return { pass: verdict.pass, reason: typeof verdict.reason === 'string' ? verdict.reason : '' };
|
|
47
|
+
}
|
|
48
|
+
/** Ask the judge whether `reply` does what `rubric` says: a verdict, or a judge failure after every retry. */
|
|
49
|
+
export async function judge(model, rubric, customer, reply, options = {}) {
|
|
50
|
+
const attempts = 1 + Math.max(0, options.retries ?? 2);
|
|
51
|
+
const errors = [];
|
|
52
|
+
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
53
|
+
const answer = await askOnce(model, rubric, customer, reply, options.maxOutputTokens ?? 1024);
|
|
54
|
+
if (!('error' in answer))
|
|
55
|
+
return answer;
|
|
56
|
+
errors.push(answer.error);
|
|
57
|
+
// A request that failed is not asked again here: the provider has its own retries for that.
|
|
58
|
+
if (!answer.askAgain)
|
|
59
|
+
return { error: `the judge could not be asked: ${answer.error}`, attempts: attempt };
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
error: `the judge gave no verdict in ${attempts} attempt${attempts === 1 ? '' : 's'}: ${errors.map((e, i) => `(${i + 1}) ${e}`).join('; ')}`,
|
|
63
|
+
attempts,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function askOnce(model, rubric, customer, reply, maxOutputTokens) {
|
|
67
|
+
try {
|
|
68
|
+
const result = await generateText({
|
|
69
|
+
model,
|
|
70
|
+
instructions: JUDGE_INSTRUCTIONS,
|
|
71
|
+
prompt: `Rubric: ${rubric}\n\nThe customer wrote:\n${customer || '(nothing: the turn continued after an approval)'}\n\nThe agent replied:\n${reply || '(nothing)'}`,
|
|
72
|
+
output: Output.object({ schema: jsonSchema(VERDICT_SCHEMA), name: 'verdict', description: 'Whether the reply does what the rubric describes.' }),
|
|
73
|
+
maxOutputTokens,
|
|
74
|
+
});
|
|
75
|
+
const verdict = asVerdict(result.output, JSON.stringify(result.output));
|
|
76
|
+
return 'error' in verdict ? { ...verdict, askAgain: true } : verdict;
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
// An answer the structured parse refused may still hold a verdict as text (an older recording, a model that wrapped it).
|
|
80
|
+
if (NoObjectGeneratedError.isInstance(err)) {
|
|
81
|
+
const fromText = err.text ? readVerdict(err.text) : { error: 'the judge answered nothing' };
|
|
82
|
+
if (!('error' in fromText))
|
|
83
|
+
return fromText;
|
|
84
|
+
return { error: `${fromText.error}${err.finishReason === 'length' ? ` (cut off at ${maxOutputTokens} output tokens)` : ''}`, askAgain: true };
|
|
85
|
+
}
|
|
86
|
+
return { error: err instanceof Error ? err.message : String(err), askAgain: false };
|
|
87
|
+
}
|
|
37
88
|
}
|
|
38
89
|
//# sourceMappingURL=judge.js.map
|
package/dist/judge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"judge.js","sourceRoot":"","sources":["../src/judge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"judge.js","sourceRoot":"","sources":["../src/judge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAc9E,MAAM,CAAC,MAAM,kBAAkB,GAC7B,wEAAwE;IACxE,sGAAsG;IACtG,4EAA4E,CAAC;AAE/E,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAA8C;IACvE,IAAI,EAAE,QAAQ;IACd,UAAU,EAA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KAAK,EAAE,GAAG,QAAQ,CAAC,KAAK,GAAG,GAAG,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,eAAe,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAChJ,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACtF,CAAC;AACH,CAAC"}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { AgentEvalScenario, AgentEvalSuite } from '@ouispec/contract';
|
|
1
2
|
import type { ApprovalChannel, ApprovalDecideResult, ApprovalDecision, ConversationHold, PendingApprovalInput, StaffSpeaker } from '@ouispec/agent-core';
|
|
2
|
-
import type
|
|
3
|
+
import { type AgentRuntimeConfig, type ApprovalStoreClient, type HistoryRequest, type RealtimeEmitAdapter, type TurnHistory, type TurnHistoryMessage, type TurnStopClient, type UIActionChannel } from '@ouispec/agent-worker';
|
|
3
4
|
/** One event the worker sent a turn's room. */
|
|
4
5
|
export interface EmittedEvent {
|
|
5
6
|
room: string;
|
|
@@ -44,6 +45,84 @@ export interface MemoryStops extends TurnStopClient {
|
|
|
44
45
|
* question. Nobody presses Stop in an eval.
|
|
45
46
|
*/
|
|
46
47
|
export declare function createMemoryStops(): MemoryStops;
|
|
47
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* A conversation channel has no page: a UI action reaching it is refused, as a
|
|
50
|
+
* tab with nothing open refuses it. The harness runs it with no wait for an
|
|
51
|
+
* answer, so a turn whose context carries a page snapshot and no fixture is
|
|
52
|
+
* told at once that the page is not responding.
|
|
53
|
+
*/
|
|
48
54
|
export declare const NO_PAGE: UIActionChannel;
|
|
55
|
+
/**
|
|
56
|
+
* A conversation store, as a product's worker reads and writes it: what the
|
|
57
|
+
* harness hands the turn runner as `getHistory` and `persistMessages`, and
|
|
58
|
+
* where it puts what no turn writes (the customer's message, which a
|
|
59
|
+
* product's API stores before it runs the turn, and a person's on the staff).
|
|
60
|
+
*
|
|
61
|
+
* Give the product's own (its window that cuts old tool results, its summary,
|
|
62
|
+
* its step context) to run later turns on what its worker really reads.
|
|
63
|
+
*/
|
|
64
|
+
export interface EvalHistory {
|
|
65
|
+
/** A message no turn writes: the customer's, before their turn runs; a person's on the staff, as they act. */
|
|
66
|
+
append(conversationId: string, entry: TurnHistoryMessage): void | Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* The worker's `getHistory`: what a turn reads. Beside the worker's own
|
|
69
|
+
* request, the harness gives the turn it reads for (`turn`: its scenario,
|
|
70
|
+
* its channel, the customer, and the context it is sent with, the page's
|
|
71
|
+
* included), which a product's worker reads from the turn's payload: where
|
|
72
|
+
* the turn is sent from, whose view it is in.
|
|
73
|
+
*/
|
|
74
|
+
getHistory(conversationId: string, request: EvalHistoryRequest): Promise<TurnHistoryMessage[] | TurnHistory>;
|
|
75
|
+
/** The worker's `persistMessages`, with no database: how a turn's messages are stored. */
|
|
76
|
+
persistMessages(input: Omit<Parameters<AgentRuntimeConfig<unknown>['persistMessages']>[0], 'db'>): Promise<void | {
|
|
77
|
+
stored: false;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
/** The turn a history is read for, as the harness runs it: what a product's worker has from the turn's payload. */
|
|
81
|
+
export interface EvalHistoryTurn {
|
|
82
|
+
conversationId: string;
|
|
83
|
+
turnId: string;
|
|
84
|
+
/** Its place among the scenario's turns, from 0. */
|
|
85
|
+
index: number;
|
|
86
|
+
/** A customer's message, or the continuation after their answer to an approval. */
|
|
87
|
+
kind: 'user' | 'approval';
|
|
88
|
+
suite: AgentEvalSuite;
|
|
89
|
+
scenario: AgentEvalScenario;
|
|
90
|
+
/** The channel it runs on, as the configuration names it. */
|
|
91
|
+
channel: string;
|
|
92
|
+
/** Who sent it. */
|
|
93
|
+
user: {
|
|
94
|
+
userId: string;
|
|
95
|
+
accountId: string;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The context it is sent with, as the worker is given it: the suite's, the
|
|
99
|
+
* channel's and the scenario's (whatever names the view it is in), and the
|
|
100
|
+
* page's (`currentPath`, `oui`, `uiKnowledge`).
|
|
101
|
+
*/
|
|
102
|
+
context: Readonly<Record<string, unknown>>;
|
|
103
|
+
/** Where the page is when it is sent, with any query string; null with no page. */
|
|
104
|
+
at: string | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* What `EvalHistory.getHistory` is given: the worker's request, and the turn
|
|
108
|
+
* it reads for. The harness always gives `turn`; a store's own tests may call
|
|
109
|
+
* it with the worker's request alone.
|
|
110
|
+
*/
|
|
111
|
+
export interface EvalHistoryRequest extends HistoryRequest {
|
|
112
|
+
turn?: EvalHistoryTurn;
|
|
113
|
+
}
|
|
114
|
+
export interface MemoryHistoryOptions {
|
|
115
|
+
/**
|
|
116
|
+
* What a turn reads of the whole conversation: the product's own window
|
|
117
|
+
* (the newest messages, old tool results cut, a summary in their place, a
|
|
118
|
+
* step context beside them). Default: all of it.
|
|
119
|
+
*/
|
|
120
|
+
window?: (messages: readonly TurnHistoryMessage[], turn: EvalHistoryRequest & {
|
|
121
|
+
conversationId: string;
|
|
122
|
+
}) => TurnHistoryMessage[] | TurnHistory | Promise<TurnHistoryMessage[] | TurnHistory>;
|
|
123
|
+
}
|
|
124
|
+
/** The conversation, kept whole in memory; a turn reads it through `window` when one is given. */
|
|
125
|
+
export declare function createMemoryHistory(options?: MemoryHistoryOptions): EvalHistory & {
|
|
126
|
+
messages(conversationId: string): readonly TurnHistoryMessage[];
|
|
127
|
+
};
|
|
49
128
|
//# sourceMappingURL=memory.d.ts.map
|