create-curb 1.25.0-preview.2 → 1.25.0-preview.4
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/RELEASE_NOTES.md +6 -0
- package/package.json +1 -1
- package/templates/booking/README.md +12 -0
- package/templates/booking/src/agent/agent.tsx +7 -2
- package/templates/booking/src/agent/books-a-haircut.scenario.ts +32 -0
- package/templates/booking/src/agent/calendar.ts +12 -0
- package/templates/booking/src/agent/prices.scenario.ts +18 -0
- package/templates/default/.github/workflows/curb-test.yml +43 -0
- package/templates/default/AGENTS.md +16 -3
- package/templates/default/README.md +13 -0
- package/templates/default/src/agent/plan-the-day.scenario.ts +35 -0
- package/templates/default/src/agent/task-list.scenario.ts +28 -0
- package/templates/support/README.md +12 -0
- package/templates/support/src/agent/damaged-item.scenario.ts +33 -0
- package/templates/support/src/agent/order-status.scenario.ts +18 -0
package/RELEASE_NOTES.md
CHANGED
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ npx curb login # sign in in the browser; Curb uses your login
|
|
|
14
14
|
npm run dev # preview, chat and voice on http://127.0.0.1:4000
|
|
15
15
|
npx curb check # types, render and warnings
|
|
16
16
|
npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
17
|
+
npx curb test # the conversations in src/agent/*.scenario.ts, pass or fail
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
## Try it
|
|
@@ -29,6 +30,17 @@ npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
|
29
30
|
- `src/agent/<name>/skill.tsx`: one folder per skill, opened only when the conversation needs it.
|
|
30
31
|
- `context/`: markdown the skills read. Edit it and the agent's answers change live.
|
|
31
32
|
|
|
33
|
+
## Test it
|
|
34
|
+
|
|
35
|
+
`src/agent/*.scenario.ts` holds conversations that `npx curb test` plays in text: one with
|
|
36
|
+
scripted caller lines, which must always pass, and one with a simulated caller that a second
|
|
37
|
+
model plays. `npx curb test --runs 3` plays the simulated one three times and reports how often
|
|
38
|
+
it passed, what a judge found and how the agent talks. Text tests do not cover audio, timing or
|
|
39
|
+
interruptions: listen to a call in `npm run dev` for those.
|
|
40
|
+
|
|
41
|
+
`.github/workflows/curb-test.yml` runs `curb check` and `curb test` on every pull request once
|
|
42
|
+
the repository has `KUGELAUDIO_API_KEY` as a secret (Settings > Secrets and variables > Actions).
|
|
43
|
+
|
|
32
44
|
## Deploy to KugelAudio
|
|
33
45
|
|
|
34
46
|
```bash
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
z,
|
|
12
12
|
} from "curb";
|
|
13
13
|
import { kugelaudio } from "curb/providers";
|
|
14
|
-
import { type Appointment, addAppointment, removeAppointment } from "./calendar.js";
|
|
14
|
+
import { type Appointment, addAppointment, isPersonName, removeAppointment } from "./calendar.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Lena, the booking agent of Birch Street Studio, a made-up hair and beauty studio. This file is
|
|
@@ -63,7 +63,7 @@ const bookSchema = z.object({
|
|
|
63
63
|
service: z.enum(SERVICES).describe("The service the caller wants."),
|
|
64
64
|
date: z.iso.date().describe("The day, as YYYY-MM-DD."),
|
|
65
65
|
time: z.string().regex(/^\d{2}:00$/).describe("The start time on the hour, 24-hour HH:00, one of the free slots."),
|
|
66
|
-
name: z.string().min(1).describe("The caller's name, as they said it."),
|
|
66
|
+
name: z.string().min(1).describe("The caller's name, as they said it. Ask for it first if they have not said it."),
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
const cancelSchema = z.object({
|
|
@@ -108,6 +108,11 @@ function Calendar() {
|
|
|
108
108
|
name="book_appointment"
|
|
109
109
|
description="Book an appointment in a free slot. Call it only after the caller confirmed service, day, time and name."
|
|
110
110
|
onSubmit={(input) => {
|
|
111
|
+
// Structural, like the slot checks below: the model cannot book under a stand-in
|
|
112
|
+
// for a name it never asked for.
|
|
113
|
+
if (!isPersonName(input.name)) {
|
|
114
|
+
return { ok: false, message: `"${input.name}" is not a name. Ask the caller for their name, then book with it.` };
|
|
115
|
+
}
|
|
111
116
|
if (!isOpenDay(input.date) || !hours.includes(input.time)) {
|
|
112
117
|
return { ok: false, message: "That is outside opening hours. Offer another slot from list_free_slots." };
|
|
113
118
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { personas, scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
|
|
5
|
+
* reads the finished call. The persona makes the caller harder than the default one, who is
|
|
6
|
+
* more patient and clearer than the people who really call.
|
|
7
|
+
*
|
|
8
|
+
* The checks say what must be true when the call is over, not which way the agent took there:
|
|
9
|
+
* Lena may offer slots in one question or in three. Either way one haircut for Alex is in the
|
|
10
|
+
* calendar at the end.
|
|
11
|
+
*/
|
|
12
|
+
export default scenario({
|
|
13
|
+
name: "books a haircut on a bad line",
|
|
14
|
+
caller: {
|
|
15
|
+
goal: "Book a haircut on the next day the studio is open, at a free time the agent offers.",
|
|
16
|
+
knows: "Your name is Alex Example. You want a haircut. Any free time of day suits you.",
|
|
17
|
+
...personas.hardOfHearing,
|
|
18
|
+
},
|
|
19
|
+
// A model does not answer the same way twice, so this scenario runs three times and passes
|
|
20
|
+
// when two of the three do. The report still shows the rate and marks it flaky when a run
|
|
21
|
+
// failed. Raise minPassRate toward 1 (every run) once it passes every time for a while;
|
|
22
|
+
// a scripted scenario needs neither: the same words run once and must pass.
|
|
23
|
+
runs: 3,
|
|
24
|
+
minPassRate: 0.66,
|
|
25
|
+
// Every run runs the agent's tools for real. Here they only change this call's own calendar.
|
|
26
|
+
// A tool that writes to a real calendar gets a fake:
|
|
27
|
+
// fakes: { book_appointment: { ok: true, message: "Booked as B-1." } }
|
|
28
|
+
// A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
|
|
29
|
+
expectations: ["The agent says the appointment is booked only after its book_appointment call succeeded."],
|
|
30
|
+
// The agent's state at the end of the call: one haircut for Alex, and nothing else.
|
|
31
|
+
expect: ({ stateMatches }) => [stateMatches("lena", { appointments: [{ service: "haircut", name: /alex/i }] })],
|
|
32
|
+
});
|
|
@@ -15,6 +15,18 @@ export function addAppointment(book: Book, appointment: Omit<Appointment, "id">)
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** What a model writes into a name field when the caller never said their name. */
|
|
19
|
+
const PLACEHOLDER_NAMES = ["caller", "the caller", "customer", "client", "user", "guest", "unknown", "anonymous", "name", "none", "na", "tbd"];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Whether `name` is a name a person gave, not a word that stands in for one: a booking under
|
|
23
|
+
* "Caller" is one nobody can be greeted by when they arrive.
|
|
24
|
+
*/
|
|
25
|
+
export function isPersonName(name: string): boolean {
|
|
26
|
+
const letters = name.toLowerCase().replace(/[^\p{L}\s]/gu, "").replace(/\s+/g, " ").trim();
|
|
27
|
+
return letters !== "" && !PLACEHOLDER_NAMES.includes(letters);
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
export function removeAppointment(book: Book, id: string) {
|
|
19
31
|
return {
|
|
20
32
|
book: { ...book, appointments: book.appointments.filter((a) => a.id !== id) },
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
|
|
5
|
+
* pass. Keep one of these for every path that must never break.
|
|
6
|
+
*
|
|
7
|
+
* The price list exists only in the services skill, so a reply that states the price shows the
|
|
8
|
+
* skill was read: no check needs to name the tool.
|
|
9
|
+
*/
|
|
10
|
+
export default scenario({
|
|
11
|
+
name: "answers a price question without booking",
|
|
12
|
+
turns: ["Hi, what does a haircut cost?", "Okay, thanks. I will think about it."],
|
|
13
|
+
expect: ({ said, stateMatches }) => [
|
|
14
|
+
said(/38|thirty[- ]eight/i),
|
|
15
|
+
// A question about prices books nothing.
|
|
16
|
+
stateMatches("lena", { appointments: [] }),
|
|
17
|
+
],
|
|
18
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: curb test
|
|
2
|
+
|
|
3
|
+
# Runs the agent's checks and its conversation scenarios on every pull request. The scenarios
|
|
4
|
+
# call the agent's LLM, so the job needs KUGELAUDIO_API_KEY as a repository secret (Settings >
|
|
5
|
+
# Secrets and variables > Actions), an API key from the KugelAudio dashboard. An agent on
|
|
6
|
+
# another provider needs that provider's key here instead, under the name its .env uses.
|
|
7
|
+
#
|
|
8
|
+
# A pull request from a fork gets no secrets, so the scenarios are skipped there and only
|
|
9
|
+
# `curb check` runs.
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
pull_request:
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
concurrency:
|
|
19
|
+
group: curb-test-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
test:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
timeout-minutes: 30
|
|
26
|
+
env:
|
|
27
|
+
KUGELAUDIO_API_KEY: ${{ secrets.KUGELAUDIO_API_KEY }}
|
|
28
|
+
# CPU binaries ship in npm; this skips a download the tests do not need.
|
|
29
|
+
ONNXRUNTIME_NODE_INSTALL: skip
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
32
|
+
with:
|
|
33
|
+
persist-credentials: false
|
|
34
|
+
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
35
|
+
with:
|
|
36
|
+
node-version: 22
|
|
37
|
+
- run: npm ci
|
|
38
|
+
- run: npx curb check
|
|
39
|
+
# Each scenario says how often it runs and how many runs must pass (runs, minPassRate).
|
|
40
|
+
# The report lands in the job summary.
|
|
41
|
+
- name: npx curb test
|
|
42
|
+
if: env.KUGELAUDIO_API_KEY != ''
|
|
43
|
+
run: npx curb test
|
|
@@ -62,9 +62,18 @@ A fault in Curb itself is reported as `reporting-a-bug.md` says, with the person
|
|
|
62
62
|
2. `npx curb say "<what the caller says>"`: one spoken turn, headless. It prints the reply,
|
|
63
63
|
each tool call and the context it changed. The next `curb say` continues the
|
|
64
64
|
conversation; `npx curb say --new "<first line>"` starts over (do that after a code change).
|
|
65
|
-
3. `npx curb test
|
|
66
|
-
caller lines
|
|
67
|
-
|
|
65
|
+
3. `npx curb test --runs 3`: plays every `src/**/*.scenario.ts` conversation headlessly, in
|
|
66
|
+
text. A scenario with scripted caller lines is a gate: it runs once and must pass. One with
|
|
67
|
+
a simulated caller runs three times, because a model does not answer the same way twice,
|
|
68
|
+
so read its pass rate, not one run. The scenarios this project starts with pass when two
|
|
69
|
+
of three runs do (`minPassRate: 0.66`); raise that toward 1 once one passes every time. Then read what the report found: each `find` line
|
|
70
|
+
names a turn and quotes it, the transcript of every failed run is printed, and the `Style`
|
|
71
|
+
lines say how long the replies are and how often they repeat. A scenario marked flaky
|
|
72
|
+
passed on some runs only: fix the agent, do not rerun until it passes. A run marked
|
|
73
|
+
`error` says nothing about the agent (the provider failed, or the simulated caller went
|
|
74
|
+
wrong). After changing an `expect` or an expectation, `npx curb test --rejudge latest`
|
|
75
|
+
checks the saved conversations again without running the agent. Keep one scenario per
|
|
76
|
+
flow that matters, and fake every tool that books, sends or deletes (`testing.md`).
|
|
68
77
|
|
|
69
78
|
4. `npm run dev`: the browser preview with chat and voice on http://127.0.0.1:4000. Open it in the person's own browser yourself (`open http://127.0.0.1:4000` on macOS, `xdg-open` on Linux, `start` on Windows): a browser built into an app, like the Claude app's Browser pane, blocks the microphone, so a call there fails.
|
|
70
79
|
|
|
@@ -89,9 +98,13 @@ what really happened.
|
|
|
89
98
|
src/agent/agent.tsx the agent, where every conversation starts: <Agent llm stt tts>,
|
|
90
99
|
system prompt, skills index, tools every skill has, store
|
|
91
100
|
src/agent/<name>/skill.tsx one folder per skill, opened when needed; nested folders are sub-skills
|
|
101
|
+
src/agent/*.scenario.ts conversations `curb test` plays: a caller, and what must hold afterwards
|
|
92
102
|
context/*.md knowledge a skill reads with <Text src="file.md" />
|
|
93
103
|
.env other providers' keys, an optional KUGELAUDIO_API_KEY; never commit it
|
|
94
104
|
.data/conversations.jsonl every preview conversation: tool calls, inputs, results
|
|
105
|
+
.curb/test-runs/ every `curb test` run with its conversations, for --rejudge
|
|
106
|
+
.github/workflows/ curb-test.yml runs check and test on each pull request; it needs
|
|
107
|
+
KUGELAUDIO_API_KEY as a repository secret
|
|
95
108
|
```
|
|
96
109
|
|
|
97
110
|
## Rules
|
|
@@ -17,6 +17,7 @@ npx curb login # sign in in the browser; Curb uses your login
|
|
|
17
17
|
npm run dev # preview, chat and voice on http://127.0.0.1:4000
|
|
18
18
|
npx curb check # types, render and warnings
|
|
19
19
|
npx curb say "Hallo" # one caller turn in the terminal, no browser
|
|
20
|
+
npx curb test # the conversations in src/agent/*.scenario.ts, pass or fail
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
## Meet Juno
|
|
@@ -39,6 +40,18 @@ Type or talk in the preview:
|
|
|
39
40
|
needs it.
|
|
40
41
|
- `context/`: markdown the skills read.
|
|
41
42
|
|
|
43
|
+
## Test it
|
|
44
|
+
|
|
45
|
+
`src/agent/*.scenario.ts` holds conversations that `npx curb test` plays in text: one with
|
|
46
|
+
scripted caller lines, which must always pass, and one with a simulated caller that a second
|
|
47
|
+
model plays. `npx curb test --runs 3` plays the simulated one three times and reports how often
|
|
48
|
+
it passed, what a judge found and how the agent talks. Text tests do not cover audio, timing or
|
|
49
|
+
interruptions: listen to a call in `npm run dev` for those.
|
|
50
|
+
|
|
51
|
+
`.github/workflows/curb-test.yml` runs `curb check` and `curb test` on every pull request once
|
|
52
|
+
the repository has `KUGELAUDIO_API_KEY` as a secret (Settings > Secrets and variables >
|
|
53
|
+
Actions). Details: `node_modules/curb/docs/agent-guide/testing.md`.
|
|
54
|
+
|
|
42
55
|
## Deploy to KugelAudio
|
|
43
56
|
|
|
44
57
|
Hosted deploys accept this project, which installs Curb from npm. To run it on your own servers
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { personas, scenario } from "curb/testing";
|
|
2
|
+
import type { Task } from "./agent.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
|
|
6
|
+
* reads the finished call. The persona makes the caller harder than the default one, who is
|
|
7
|
+
* more patient and clearer than the people who really call.
|
|
8
|
+
*
|
|
9
|
+
* The checks say what must be true when the call is over, not which way the agent took there:
|
|
10
|
+
* a model that asks one question more, or adds the tasks in another order, still passes.
|
|
11
|
+
*/
|
|
12
|
+
export default scenario({
|
|
13
|
+
name: "plans the day with a talkative caller",
|
|
14
|
+
caller: {
|
|
15
|
+
goal: "Get three tasks onto your list: buy milk, call the dentist, send the invoice.",
|
|
16
|
+
knows: "Your tasks for today: buy milk, call the dentist, send the invoice.",
|
|
17
|
+
...personas.talkative,
|
|
18
|
+
},
|
|
19
|
+
// A model does not answer the same way twice, so this scenario runs three times and passes
|
|
20
|
+
// when two of the three do. The report still shows the rate and marks it flaky when a run
|
|
21
|
+
// failed. Raise minPassRate toward 1 (every run) once it passes every time for a while;
|
|
22
|
+
// a scripted scenario needs neither: the same words run once and must pass.
|
|
23
|
+
runs: 3,
|
|
24
|
+
minPassRate: 0.66,
|
|
25
|
+
// A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
|
|
26
|
+
expectations: ["The agent says a task is on the list only after its add_task call for that task succeeded."],
|
|
27
|
+
// The agent's state at the end of the call: each of the three tasks is on the list, once.
|
|
28
|
+
expect: ({ state, check }) => {
|
|
29
|
+
const titles = state<{ tasks: Task[] }>("juno").tasks.map((task) => task.title);
|
|
30
|
+
const listed = `the list holds: ${titles.join(", ") || "nothing"}`;
|
|
31
|
+
return ["milk", "dentist", "invoice"].map((word) =>
|
|
32
|
+
check(`one task about the ${word} is on the list`, titles.filter((title) => title.includes(word)).length === 1, listed),
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { scenario } from "curb/testing";
|
|
2
|
+
import type { Task } from "./agent.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
|
|
6
|
+
* pass. Keep one of these for every path that must never break.
|
|
7
|
+
*
|
|
8
|
+
* The task list changes only through its tools, so its state at the end says whether the right
|
|
9
|
+
* tools ran: no check needs to name them.
|
|
10
|
+
*/
|
|
11
|
+
export default scenario({
|
|
12
|
+
name: "keeps the task list",
|
|
13
|
+
turns: [
|
|
14
|
+
"Put buy milk and call the dentist on my list.",
|
|
15
|
+
"I've called the dentist, that one is done.",
|
|
16
|
+
"What is still open on my list?",
|
|
17
|
+
],
|
|
18
|
+
expect: ({ state, check, transcript }) => {
|
|
19
|
+
const { tasks } = state<{ tasks: Task[] }>("juno");
|
|
20
|
+
const listed = JSON.stringify(tasks);
|
|
21
|
+
const last = transcript[transcript.length - 1];
|
|
22
|
+
return [
|
|
23
|
+
check("the milk is on the list and still open", tasks.some((task) => task.title.includes("milk") && !task.done), listed),
|
|
24
|
+
check("the dentist call is on the list and done", tasks.some((task) => task.title.includes("dentist") && task.done), listed),
|
|
25
|
+
check("the last reply names the milk", /milk/i.test(last.reply), last.reply),
|
|
26
|
+
];
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -14,6 +14,7 @@ npx curb login # sign in in the browser; Curb uses your login
|
|
|
14
14
|
npm run dev # preview, chat and voice on http://127.0.0.1:4000
|
|
15
15
|
npx curb check # types, render and warnings
|
|
16
16
|
npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
17
|
+
npx curb test # the conversations in src/agent/*.scenario.ts, pass or fail
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
## Try it
|
|
@@ -29,6 +30,17 @@ npx curb say "Hello" # one caller turn in the terminal, no browser
|
|
|
29
30
|
- `src/agent/<name>/skill.tsx`: one folder per skill, opened only when the conversation needs it.
|
|
30
31
|
- `context/`: markdown the skills read. Edit it and the agent's answers change live.
|
|
31
32
|
|
|
33
|
+
## Test it
|
|
34
|
+
|
|
35
|
+
`src/agent/*.scenario.ts` holds conversations that `npx curb test` plays in text: one with
|
|
36
|
+
scripted caller lines, which must always pass, and one with a simulated caller that a second
|
|
37
|
+
model plays. `npx curb test --runs 3` plays the simulated one three times and reports how often
|
|
38
|
+
it passed, what a judge found and how the agent talks. Text tests do not cover audio, timing or
|
|
39
|
+
interruptions: listen to a call in `npm run dev` for those.
|
|
40
|
+
|
|
41
|
+
`.github/workflows/curb-test.yml` runs `curb check` and `curb test` on every pull request once
|
|
42
|
+
the repository has `KUGELAUDIO_API_KEY` as a secret (Settings > Secrets and variables > Actions).
|
|
43
|
+
|
|
32
44
|
## Deploy to KugelAudio
|
|
33
45
|
|
|
34
46
|
```bash
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { personas, scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A simulated caller with a goal: `curb test` plays the caller on a second model, and a judge
|
|
5
|
+
* reads the finished call. The persona makes the caller harder than the default one, who is
|
|
6
|
+
* more patient and clearer than the people who really call.
|
|
7
|
+
*
|
|
8
|
+
* The checks say what must be true when the call is over, not which way the agent took there:
|
|
9
|
+
* Mara may look the order up first or open the ticket straight from the number the caller
|
|
10
|
+
* read out. Either way one ticket for the damage exists at the end.
|
|
11
|
+
*/
|
|
12
|
+
export default scenario({
|
|
13
|
+
name: "opens a ticket for a damaged item",
|
|
14
|
+
caller: {
|
|
15
|
+
goal: "Report that the backpack from your order arrived with a torn shoulder strap, and get a support ticket opened for it.",
|
|
16
|
+
knows: "Your order number is NW-1001. The trail backpack arrived with a torn shoulder strap. Your name is Sam Example.",
|
|
17
|
+
...personas.rushed,
|
|
18
|
+
},
|
|
19
|
+
// A model does not answer the same way twice, so this scenario runs three times and passes
|
|
20
|
+
// when two of the three do. The report still shows the rate and marks it flaky when a run
|
|
21
|
+
// failed. Raise minPassRate toward 1 (every run) once it passes every time for a while;
|
|
22
|
+
// a scripted scenario needs neither: the same words run once and must pass.
|
|
23
|
+
runs: 3,
|
|
24
|
+
minPassRate: 0.66,
|
|
25
|
+
// Every run runs the agent's tools for real. Here find_order reads sample data and the others
|
|
26
|
+
// only change this call's own state. A tool that writes to a real system gets a fake:
|
|
27
|
+
// fakes: { open_ticket: { ok: true, message: "Ticket T-1 opened." } }
|
|
28
|
+
// A judge answers each sentence with yes, no or unknown, and quotes the turn that shows it.
|
|
29
|
+
expectations: ["The agent says a ticket is open only after its open_ticket call succeeded."],
|
|
30
|
+
// The agent's state at the end of the call: one ticket about the damage, and nothing else.
|
|
31
|
+
// (The returns policy files a damaged item under "damaged" or "return".)
|
|
32
|
+
expect: ({ stateMatches }) => [stateMatches("mara", { tickets: [{ category: /^(damaged|return)$/ }] })],
|
|
33
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { scenario } from "curb/testing";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scripted caller lines: the same words on every run, so this is a gate. It runs once and must
|
|
5
|
+
* pass. Keep one of these for every path that must never break.
|
|
6
|
+
*
|
|
7
|
+
* An order's status exists only in find_order's answer, so a reply that states it shows the
|
|
8
|
+
* lookup ran: no check needs to name the tool.
|
|
9
|
+
*/
|
|
10
|
+
export default scenario({
|
|
11
|
+
name: "tells where an order is",
|
|
12
|
+
turns: ["Hi, where is my order NW-1002?", "Great, thanks. That is all."],
|
|
13
|
+
expect: ({ said, stateMatches }) => [
|
|
14
|
+
said(/shipped|on (its|the) way|ParcelPost/i),
|
|
15
|
+
// Asking about an order opens no ticket.
|
|
16
|
+
stateMatches("mara", { tickets: [] }),
|
|
17
|
+
],
|
|
18
|
+
});
|