@alexkroman1/aai-cli 16.1.0 → 18.0.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 +2 -1
- package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
- package/dist/_build-target.d.ts +98 -19
- package/dist/_console-audio.d.ts +17 -0
- package/dist/_console-session.d.ts +70 -0
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-Dtp4aAlo.mjs} +26 -18
- package/dist/_dev-server.d.ts +5 -3
- package/dist/_init.d.ts +39 -0
- package/dist/_modal-target.d.ts +11 -6
- package/dist/_preflight-CnW9QiE7.mjs +116 -0
- package/dist/_preflight.d.ts +110 -5
- package/dist/_target-bundle.d.ts +112 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/_templates-DXadVNsL.mjs +135 -0
- package/dist/_templates.d.ts +11 -34
- package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
- package/dist/_vitest-runner.d.ts +35 -23
- package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
- package/dist/build.d.ts +34 -4
- package/dist/cli.mjs +40 -16
- package/dist/console-BsyE3DyB.mjs +422 -0
- package/dist/console.d.ts +37 -0
- package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-Du8pCWFq.mjs → dev-BGWU2zPP.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
- package/dist/init-CbOhyNYe.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +161 -166
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/start.d.ts +3 -3
- package/dist/{studio-It7SRfUN.mjs → studio-BRJsw7lr.mjs} +19 -9
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
- package/dist/templates/applicant-screening-agent/agent.test.ts +17 -13
- package/dist/templates/applicant-screening-agent/agent.ts +28 -0
- package/dist/templates/applicant-screening-agent/crews.ts +4 -4
- package/dist/templates/applicant-screening-agent/shared.ts +11 -11
- package/dist/templates/call-audit-workflow/agent.ts +2 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.test.ts +2 -2
- package/dist/templates/code-interpreter-agent/agent.ts +1 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +3 -2
- package/dist/templates/custom-pipeline-agent/modes.test.ts +4 -4
- package/dist/templates/custom-pipeline-agent/stages.test.ts +75 -83
- package/dist/templates/document-redline-workflow/agent.ts +2 -0
- package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +1 -1
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +9 -2
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
- package/dist/templates/executive-inbox-agent/agent.test.ts +35 -25
- package/dist/templates/executive-inbox-agent/agent.ts +1 -0
- package/dist/templates/executive-inbox-agent/calendar.test.ts +13 -7
- package/dist/templates/executive-inbox-agent/meeting.ts +3 -3
- package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
- package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
- package/dist/templates/front-desk-agent/agent.eval.test.ts +174 -0
- package/dist/templates/front-desk-agent/agent.test.ts +150 -0
- package/dist/templates/front-desk-agent/agent.ts +22 -0
- package/dist/templates/front-desk-agent/shared.ts +234 -0
- package/dist/templates/front-desk-agent/system-prompt.md +13 -0
- package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
- package/dist/templates/hotel-reception-agent/agent.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/agent.ts +6 -3
- package/dist/templates/hotel-reception-agent/client.tsx +14 -2
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +3 -3
- package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
- package/dist/templates/hotel-reception-agent/events.ts +2 -1
- package/dist/templates/hotel-reception-agent/session.ts +56 -0
- package/dist/templates/hotel-reception-agent/shared.ts +20 -21
- package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
- package/dist/templates/link-digest-workflow/agent.ts +5 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +57 -4
- package/dist/templates/medication-safety-agent/agent.ts +48 -1
- package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
- package/dist/templates/meeting-recap-agent/agent.ts +4 -0
- package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +68 -2
- package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
- package/dist/templates/push-to-talk-agent/agent.eval.test.ts +74 -0
- package/dist/templates/push-to-talk-agent/agent.test.ts +61 -0
- package/dist/templates/push-to-talk-agent/agent.ts +22 -0
- package/dist/templates/push-to-talk-agent/client.tsx +124 -0
- package/dist/templates/push-to-talk-agent/shared.ts +34 -0
- package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
- package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
- package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +91 -3
- package/dist/templates/quickstart-agent/agent.test.ts +22 -0
- package/dist/templates/quickstart-agent/agent.ts +18 -2
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.eval.test.ts +1 -1
- package/dist/templates/research-handoff-agent/agent.test.ts +34 -26
- package/dist/templates/research-handoff-agent/agent.ts +4 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
- package/dist/templates/research-planner-agent/agent.test.ts +26 -16
- package/dist/templates/research-planner-agent/agent.ts +3 -0
- package/dist/templates/research-planner-agent/system-prompt.md +1 -1
- package/dist/templates/retail-orders-agent/agent.eval.test.ts +1 -1
- package/dist/templates/retail-orders-agent/agent.ts +32 -3
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/resolve.ts +18 -3
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +124 -5
- package/dist/templates/roadside-assistance-agent/agent.test.ts +39 -7
- package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
- package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
- package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
- package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
- package/dist/templates/technical-support-agent/agent.test.ts +29 -23
- package/dist/templates/technical-support-agent/agent.ts +5 -1
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +3 -2
- package/dist/templates/technical-support-agent/procedure.ts +7 -6
- package/dist/templates/technical-support-agent/shared.ts +10 -146
- package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
- package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
- package/dist/templates/text-adventure-agent/agent.ts +30 -1
- package/dist/templates/text-adventure-agent/shared.ts +37 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
- package/dist/templates/topic-briefing-agent/agent.test.ts +61 -36
- package/dist/templates/topic-briefing-agent/agent.ts +4 -1
- package/dist/templates/topic-briefing-agent/shared.ts +19 -18
- package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
- package/dist/templates/transcription-workflow/agent.ts +3 -0
- package/dist/templates/travel-concierge-agent/agent.eval.test.ts +9 -7
- package/dist/templates/travel-concierge-agent/agent.test.ts +1 -2
- package/dist/templates/travel-concierge-agent/agent.ts +4 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
- package/dist/templates/web-research-agent/agent.test.ts +16 -0
- package/dist/templates/web-research-agent/agent.ts +30 -0
- package/dist/templates/web-research-agent/system-prompt.md +8 -2
- package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
- package/dist/templates/word-game-agent/agent.test.ts +3 -1
- package/dist/templates/word-game-agent/agent.ts +20 -0
- package/dist/test-CjKPQ9_B.mjs +102 -0
- package/dist/test.d.ts +37 -12
- package/package.json +5 -5
- package/dist/_init-Bp1CjRrU.mjs +0 -199
- package/dist/_preflight-CcAR577V.mjs +0 -46
- package/dist/_templates-CuP74F8D.mjs +0 -291
- package/dist/init-CY4NAXAA.mjs +0 -183
- package/dist/test-PHHv0Vj6.mjs +0 -83
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type StubDelegateCall,
|
|
6
6
|
scriptedToolContext,
|
|
7
7
|
stubDelegate,
|
|
8
|
+
toolOf,
|
|
8
9
|
toolRunner,
|
|
9
10
|
} from "@alexkroman1/aai/testing";
|
|
10
11
|
import { installStubStepFetch } from "@alexkroman1/aai/testing/vitest";
|
|
@@ -56,18 +57,21 @@ function scriptedDesk(
|
|
|
56
57
|
const research = options.research ?? ((call) => `Findings for ${call.task}.`);
|
|
57
58
|
return scriptedToolContext({
|
|
58
59
|
delegate: {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
routes: {
|
|
61
|
+
researcher: (call) => {
|
|
62
|
+
const reply = research(call);
|
|
63
|
+
if (typeof reply === "string") return { text: reply };
|
|
64
|
+
return {
|
|
65
|
+
text: reply.text,
|
|
66
|
+
toolCalls: Array.from({ length: reply.searches ?? 0 }, (_unused, index) => ({
|
|
67
|
+
name: "web_search",
|
|
68
|
+
input: { query: `q${index}` },
|
|
69
|
+
})),
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
"fact-checker":
|
|
73
|
+
options.check ?? '{"verdict": "confirmed", "detail": "Two sources say so."}',
|
|
69
74
|
},
|
|
70
|
-
"fact-checker": options.check ?? '{"verdict": "confirmed", "detail": "Two sources say so."}',
|
|
71
75
|
},
|
|
72
76
|
});
|
|
73
77
|
}
|
|
@@ -88,12 +92,12 @@ describe("the desk itself", () => {
|
|
|
88
92
|
expect(factChecker.maxSteps).toBeLessThan(MAX_RESEARCH_STEPS);
|
|
89
93
|
});
|
|
90
94
|
|
|
91
|
-
test("runs the three NARROW
|
|
95
|
+
test("runs the three NARROW subagents somewhere cheaper, and the researcher on the default", () => {
|
|
92
96
|
// The other half of the budget split, and the reason `CHEAP_MODEL` is one
|
|
93
|
-
// constant: three
|
|
97
|
+
// constant: three subagents that were each meant to be cheap, one of
|
|
94
98
|
// which quietly is not, is a bill nobody can read.
|
|
95
|
-
for (const
|
|
96
|
-
expect(
|
|
99
|
+
for (const one of [factChecker, explainer, counterpoint]) {
|
|
100
|
+
expect(one.llm, one.name).toMatchObject({ options: { model: CHEAP_MODEL } });
|
|
97
101
|
}
|
|
98
102
|
// The researcher reads whole pages and stays on the agent's own model.
|
|
99
103
|
expect(researcher.llm).toBeUndefined();
|
|
@@ -104,25 +108,25 @@ describe("the desk itself", () => {
|
|
|
104
108
|
// rather than a paragraph somebody remembered to write: the desk reads the
|
|
105
109
|
// final message and nothing else. A subagent added here without one is the
|
|
106
110
|
// regression this catches.
|
|
107
|
-
for (const
|
|
108
|
-
expect(
|
|
111
|
+
for (const one of [researcher, factChecker, explainer, counterpoint]) {
|
|
112
|
+
expect(one.expectedOutput, one.name).toBeTruthy();
|
|
109
113
|
}
|
|
110
114
|
expect(researcher.expectedOutput).toMatch(/only this/);
|
|
111
115
|
});
|
|
112
116
|
|
|
113
|
-
test("puts on the roster exactly the
|
|
117
|
+
test("puts on the roster exactly the subagents chosen by what the caller ASKED", () => {
|
|
114
118
|
// The two tools name their own subagent, so those two must NOT be on the
|
|
115
|
-
// roster: a
|
|
119
|
+
// roster: a subagent reachable both ways gives the model a second, worse
|
|
116
120
|
// route to a tool that does real work around the delegation.
|
|
117
121
|
expect(authoredAgent.subagents?.map((one) => one.name)).toEqual(["explainer", "counterpoint"]);
|
|
118
|
-
for (const
|
|
122
|
+
for (const one of authoredAgent.subagents ?? []) {
|
|
119
123
|
// The only thing the router reads. `agent()` refuses a roster without it;
|
|
120
124
|
// asserted here too because the template is what an author copies.
|
|
121
|
-
expect(
|
|
125
|
+
expect(one.description, one.name).toBeTruthy();
|
|
122
126
|
}
|
|
123
127
|
});
|
|
124
128
|
|
|
125
|
-
test("publishes the roster as one delegate tool listing both
|
|
129
|
+
test("publishes the roster as one delegate tool listing both subagents", () => {
|
|
126
130
|
const delegate = deployed.tools[DELEGATE_TOOL_NAME];
|
|
127
131
|
expect(delegate).toBeDefined();
|
|
128
132
|
expect(delegate?.description).toContain("explainer:");
|
|
@@ -171,10 +175,12 @@ describe("research_topic", () => {
|
|
|
171
175
|
let inFlight = 0;
|
|
172
176
|
let peak = 0;
|
|
173
177
|
const model = stubDelegate({
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
routes: {
|
|
179
|
+
researcher: () => {
|
|
180
|
+
inFlight += 1;
|
|
181
|
+
peak = Math.max(peak, inFlight);
|
|
182
|
+
return "found";
|
|
183
|
+
},
|
|
178
184
|
},
|
|
179
185
|
});
|
|
180
186
|
// The fake answers synchronously, so `inFlight` is only ever 1 unless the
|
|
@@ -215,9 +221,11 @@ describe("research_topic", () => {
|
|
|
215
221
|
|
|
216
222
|
test("one failed angle does not sink the briefing", async () => {
|
|
217
223
|
const model = stubDelegate({
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
routes: {
|
|
225
|
+
researcher: (call) => {
|
|
226
|
+
if (call.task === "b") throw new Error("provider is having a day");
|
|
227
|
+
return `Answer to ${call.task}.`;
|
|
228
|
+
},
|
|
221
229
|
},
|
|
222
230
|
});
|
|
223
231
|
const ctx = createToolContext({ delegate: model.delegate });
|
|
@@ -237,8 +245,10 @@ describe("research_topic", () => {
|
|
|
237
245
|
|
|
238
246
|
test("fails as a tool when every angle fails, quoting the first reason", async () => {
|
|
239
247
|
const model = stubDelegate({
|
|
240
|
-
|
|
241
|
-
|
|
248
|
+
routes: {
|
|
249
|
+
researcher: () => {
|
|
250
|
+
throw new Error("gateway said no");
|
|
251
|
+
},
|
|
242
252
|
},
|
|
243
253
|
});
|
|
244
254
|
|
|
@@ -312,9 +322,11 @@ describe("verify_claim", () => {
|
|
|
312
322
|
// `stubDelegate` parses it — what makes this the UNACCEPTED case is the
|
|
313
323
|
// staged `complaint`.
|
|
314
324
|
const model = stubDelegate({
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
325
|
+
routes: {
|
|
326
|
+
"fact-checker": {
|
|
327
|
+
text: '{"verdict": "unclear", "detail": "Nothing conclusive."}',
|
|
328
|
+
complaint: "no verdict word",
|
|
329
|
+
},
|
|
318
330
|
},
|
|
319
331
|
});
|
|
320
332
|
|
|
@@ -349,8 +361,10 @@ describe("verify_claim", () => {
|
|
|
349
361
|
|
|
350
362
|
test("reports a failed check as a tool failure the model can recover from", async () => {
|
|
351
363
|
const model = stubDelegate({
|
|
352
|
-
|
|
353
|
-
|
|
364
|
+
routes: {
|
|
365
|
+
"fact-checker": () => {
|
|
366
|
+
throw new Error("checker timed out");
|
|
367
|
+
},
|
|
354
368
|
},
|
|
355
369
|
});
|
|
356
370
|
|
|
@@ -622,6 +636,17 @@ describe("send_briefing", () => {
|
|
|
622
636
|
expect(posted.calls).toEqual([]);
|
|
623
637
|
});
|
|
624
638
|
|
|
639
|
+
test("declares onError, so a missing webhook is FATAL rather than something to retry", () => {
|
|
640
|
+
// Without it the runtime hands every throw to the model as this call's
|
|
641
|
+
// result, and the desk re-calls `send_briefing` against a variable that is
|
|
642
|
+
// still unset — burning the reply's step budget on a deploy fault. The
|
|
643
|
+
// handler re-throws, which is how a tool says "stop, this cannot work".
|
|
644
|
+
const sender = toolOf(deployed, "send_briefing");
|
|
645
|
+
expect(sender.onError).toBeDefined();
|
|
646
|
+
const cause = new Error(`Missing required environment variable: ${DESTINATION_ENV}`);
|
|
647
|
+
expect(() => sender.onError?.(cause, createToolContext())).toThrow(cause);
|
|
648
|
+
});
|
|
649
|
+
|
|
625
650
|
test("refuses a configured destination that is not Slack, without posting", async () => {
|
|
626
651
|
const posted = installStubStepFetch(() => ({ body: "ok" }));
|
|
627
652
|
const ctx = deskWithBoard({ [DESTINATION_ENV]: "https://example.test/collect" });
|
|
@@ -26,7 +26,7 @@ import { roster } from "./shared.ts";
|
|
|
26
26
|
* is for the case where the choice is the caller's — "what does curtailment
|
|
27
27
|
* mean" wants the explainer and "who says otherwise" wants the counterpoint,
|
|
28
28
|
* and nothing but the question tells them apart. It reaches the model as one
|
|
29
|
-
* `delegate` tool listing both, so a third
|
|
29
|
+
* `delegate` tool listing both, so a third subagent is a line here rather
|
|
30
30
|
* than a fourth file in `tools/` whose body is one `ctx.delegate` call.
|
|
31
31
|
*
|
|
32
32
|
* Compare `web-research-agent`, which gives the search builtins to the agent
|
|
@@ -35,6 +35,9 @@ import { roster } from "./shared.ts";
|
|
|
35
35
|
*/
|
|
36
36
|
export default agent({
|
|
37
37
|
name: "Briefing Desk",
|
|
38
|
+
// The listing line — a registry row, the studio's picker. "At once" is the
|
|
39
|
+
// part worth a reader's attention: it is what the subagents below buy.
|
|
40
|
+
description: "Researches a subject from several angles at once and reads back what was found",
|
|
38
41
|
greeting:
|
|
39
42
|
"Briefing desk. Tell me a subject and I'll put a few researchers on it — " +
|
|
40
43
|
"try something like, what's going on with home battery prices.",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
* a roster can express.
|
|
28
28
|
* - `explainer` and `counterpoint` are on the ROSTER (`agent({ subagents })`),
|
|
29
29
|
* because choosing between them IS reading what the caller asked: "what does
|
|
30
|
-
* curtailment mean" and "who says otherwise" want different
|
|
30
|
+
* curtailment mean" and "who says otherwise" want different subagents and
|
|
31
31
|
* nothing else about them differs. They reach the model as one `delegate`
|
|
32
|
-
* tool whose `
|
|
32
|
+
* tool whose `subagent` argument is the two names, described by their own
|
|
33
33
|
* {@link SubagentDef.description}s.
|
|
34
34
|
*
|
|
35
35
|
* The rule that follows: **name a subagent in code when the tool IS the choice;
|
|
@@ -52,23 +52,24 @@ import {
|
|
|
52
52
|
type TypedSubagentDef,
|
|
53
53
|
toolFailure,
|
|
54
54
|
} from "@alexkroman1/aai";
|
|
55
|
-
import { type AssemblyAIGatewayModel,
|
|
55
|
+
import { type AssemblyAIGatewayModel, llm } from "@alexkroman1/aai/llm";
|
|
56
56
|
import { z } from "zod";
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* The model the three NARROW
|
|
59
|
+
* The model the three NARROW subagents share.
|
|
60
60
|
*
|
|
61
61
|
* Named once because it is a fact about the DESK — checking one sentence,
|
|
62
62
|
* defining one word and finding one objection are not the job `researcher`
|
|
63
63
|
* does, so all three run somewhere cheaper — and each subagent still declares
|
|
64
|
-
* its own `llm`, because which model a
|
|
65
|
-
* declaring a
|
|
64
|
+
* its own `llm`, because which model a subagent runs on is part of what
|
|
65
|
+
* declaring a subagent means.
|
|
66
66
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
67
|
+
* Named ONCE rather than written as three string literals: the gateway's id
|
|
68
|
+
* type is open (a model shipped after this release still compiles), so a typo
|
|
69
|
+
* is not a compile error, and a typo in one of three copies is a refusal from
|
|
70
|
+
* ONE subagent while the other two answer — the hardest shape of failure to
|
|
71
|
+
* notice on a live call. One constant makes that impossible; annotating it as
|
|
72
|
+
* {@link AssemblyAIGatewayModel} is what autocompletes the known ids.
|
|
72
73
|
*/
|
|
73
74
|
export const CHEAP_MODEL: AssemblyAIGatewayModel = "gemini-2.5-flash-lite";
|
|
74
75
|
|
|
@@ -165,13 +166,13 @@ export const factChecker: TypedSubagentDef<Verdict> = subagent({
|
|
|
165
166
|
// that `detail` is one sentence and names the evidence.
|
|
166
167
|
expectedOutput: "`detail` is one sentence naming what you found and where.",
|
|
167
168
|
schema: VerdictSchema,
|
|
168
|
-
llm:
|
|
169
|
+
llm: llm({ provider: "assemblyai", model: CHEAP_MODEL }),
|
|
169
170
|
builtinTools: ["web_search"],
|
|
170
171
|
maxSteps: 2,
|
|
171
172
|
});
|
|
172
173
|
|
|
173
174
|
/**
|
|
174
|
-
* The ROSTER's first
|
|
175
|
+
* The ROSTER's first subagent: what a word means.
|
|
175
176
|
*
|
|
176
177
|
* No tools at all, which is legal and is the point — a definition is a
|
|
177
178
|
* reasoning pass, and giving this one a search would let it wander off into
|
|
@@ -193,7 +194,7 @@ export const explainer = subagent({
|
|
|
193
194
|
"definition is worse than an admitted gap.",
|
|
194
195
|
].join("\n"),
|
|
195
196
|
expectedOutput: "Two sentences, spoken plainly. No preamble and no list.",
|
|
196
|
-
llm:
|
|
197
|
+
llm: llm({ provider: "assemblyai", model: CHEAP_MODEL }),
|
|
197
198
|
maxSteps: 1,
|
|
198
199
|
});
|
|
199
200
|
|
|
@@ -203,7 +204,7 @@ export const explainer = subagent({
|
|
|
203
204
|
* Searches, like the fact-checker, and is told to do a different job with the
|
|
204
205
|
* results — which is exactly the case a roster is for. Nothing about
|
|
205
206
|
* `counterpoint` differs from `explainer` except what the caller wanted, so a
|
|
206
|
-
* tool file per
|
|
207
|
+
* tool file per subagent would be two bodies differing in one identifier.
|
|
207
208
|
*/
|
|
208
209
|
export const counterpoint = subagent({
|
|
209
210
|
name: "counterpoint",
|
|
@@ -217,19 +218,19 @@ export const counterpoint = subagent({
|
|
|
217
218
|
].join("\n"),
|
|
218
219
|
expectedOutput:
|
|
219
220
|
"Two or three sentences: the objection, who makes it, and how seriously to take it.",
|
|
220
|
-
llm:
|
|
221
|
+
llm: llm({ provider: "assemblyai", model: CHEAP_MODEL }),
|
|
221
222
|
builtinTools: ["web_search"],
|
|
222
223
|
maxSteps: 3,
|
|
223
224
|
});
|
|
224
225
|
|
|
225
226
|
/**
|
|
226
|
-
* The roster `agent({ subagents })` publishes — the
|
|
227
|
+
* The roster `agent({ subagents })` publishes — the subagents the MODEL picks
|
|
227
228
|
* between.
|
|
228
229
|
*
|
|
229
230
|
* Declared here rather than inline in `agent.ts` so that membership sits beside
|
|
230
231
|
* the definitions, which is where the question "should this one be routable?"
|
|
231
232
|
* gets answered. `researcher` and `factChecker` are deliberately absent: each is
|
|
232
|
-
* reached by a tool that does real work around the delegation, and a
|
|
233
|
+
* reached by a tool that does real work around the delegation, and a subagent
|
|
233
234
|
* reachable both ways gives the model a second, worse route to it.
|
|
234
235
|
*/
|
|
235
236
|
export const roster: SubagentRoster = [explainer, counterpoint];
|
|
@@ -5,7 +5,7 @@ and you have a small team of researchers you can put on it.
|
|
|
5
5
|
|
|
6
6
|
- You have no way to look anything up yourself. Everything you know about the
|
|
7
7
|
outside world comes back from `research_topic`, `verify_claim` or `delegate`.
|
|
8
|
-
- `delegate` hands one question to a
|
|
8
|
+
- `delegate` hands one question to a subagent: the explainer for "what does
|
|
9
9
|
that word mean", the counterpoint for "who says otherwise". Use it for a
|
|
10
10
|
question that stands on its own — a subject worth several angles is
|
|
11
11
|
`research_topic`, and a fact to check is `verify_claim`.
|
|
@@ -16,13 +16,16 @@ and you have a small team of researchers you can put on it.
|
|
|
16
16
|
- Each angle must stand on its own. A researcher has not heard this call and
|
|
17
17
|
cannot see the others' work, so "the same but for Europe" is not an angle;
|
|
18
18
|
"how European home battery prices moved in 2025" is.
|
|
19
|
-
-
|
|
20
|
-
|
|
19
|
+
- Call the tool BEFORE you say anything about it. Speaking ends your turn, so
|
|
20
|
+
"let me look that up" with no result behind it is a promise you never keep —
|
|
21
|
+
the caller hears it, the researchers never run, and the next thing they say
|
|
22
|
+
has to prompt you all over again. Report what came back, never what you are
|
|
23
|
+
about to do.
|
|
21
24
|
- `send_briefing` posts what is on the board to the team's channel. Offer it
|
|
22
25
|
when the caller wants the briefing in writing or wants it passed on to
|
|
23
|
-
someone who was not on the call, and
|
|
24
|
-
it
|
|
25
|
-
|
|
26
|
+
someone who was not on the call, and call it before you say it has gone. If
|
|
27
|
+
it comes back refusing, say plainly that it has not sent — never let them
|
|
28
|
+
hang up believing it did.
|
|
26
29
|
|
|
27
30
|
## How you talk
|
|
28
31
|
|
|
@@ -37,8 +40,10 @@ and you have a small team of researchers you can put on it.
|
|
|
37
40
|
- If the caller pushes back on a fact, check it with `verify_claim` rather than
|
|
38
41
|
defending it. If it comes back contradicted, correct yourself plainly. If it
|
|
39
42
|
comes back `unusable`, say it is unresolved — do not round it up to confirmed.
|
|
40
|
-
- `briefing_so_far` is for a recap. It costs nothing, so
|
|
41
|
-
|
|
43
|
+
- `briefing_so_far` is for a recap. It costs nothing, so ALWAYS call it when
|
|
44
|
+
the caller asks what you have — including when you believe the board is
|
|
45
|
+
empty. Reciting "nothing yet" from memory is the same mistake as reciting a
|
|
46
|
+
finding from memory: the board is the record, not your recollection of it.
|
|
42
47
|
|
|
43
48
|
## What not to do
|
|
44
49
|
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
errorMessage,
|
|
3
|
+
isToolFailure,
|
|
4
|
+
requireEnv,
|
|
5
|
+
type ToolErrorHandler,
|
|
6
|
+
toolFailure,
|
|
7
|
+
} from "@alexkroman1/aai";
|
|
2
8
|
import { ChannelDeliveryError, sendToChannel } from "@alexkroman1/aai/channels";
|
|
3
9
|
import { z } from "zod";
|
|
4
10
|
import { briefingSlot } from "../shared.ts";
|
|
5
11
|
import { briefingChannel, briefingMessage, DESTINATION_ENV } from "../slack.ts";
|
|
6
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Anything that reaches here is a deploy nobody finished or a bug in this file
|
|
15
|
+
* — see the note on the tool below — and neither is fixed by asking the model
|
|
16
|
+
* to try again, so it goes back up as a fatal failure.
|
|
17
|
+
*
|
|
18
|
+
* Named, with its type spelled, because the type is what says what the two
|
|
19
|
+
* outcomes are: RETURN a `ToolFailure` (or a string) and the model reads it and
|
|
20
|
+
* carries on; THROW and the call ends without an answer.
|
|
21
|
+
*/
|
|
22
|
+
const unfinishedDeployIsFatal: ToolErrorHandler = (err) => {
|
|
23
|
+
throw err;
|
|
24
|
+
};
|
|
25
|
+
|
|
7
26
|
/**
|
|
8
27
|
* Post the board to the desk's Slack channel, so the briefing outlives the
|
|
9
28
|
* call.
|
|
@@ -24,10 +43,24 @@ import { briefingChannel, briefingMessage, DESTINATION_ENV } from "../slack.ts";
|
|
|
24
43
|
* the one deliberate throw in this template. A missing key is not a refusal the
|
|
25
44
|
* desk can talk its way around and not something the caller did — it is a
|
|
26
45
|
* deploy nobody finished — so the SDK's own message names the variable and how
|
|
27
|
-
* to set it
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
46
|
+
* to set it. Everything a call CAN recover from is a `ToolFailure` below.
|
|
47
|
+
*
|
|
48
|
+
* **And `onError` is what makes that throw mean something.** Without it the
|
|
49
|
+
* runtime hands every exception to the model as this call's result, so a
|
|
50
|
+
* webhook nobody configured reads as an ordinary hiccup: the desk apologises,
|
|
51
|
+
* calls `send_briefing` again, gets the same sentence, and spends the reply's
|
|
52
|
+
* whole `maxSteps` budget on a variable that will still be unset on the next
|
|
53
|
+
* attempt. Re-throwing declares the failure FATAL — the call rejects, the model
|
|
54
|
+
* is handed nothing to retry against, and the runtime reports it as a `tool`
|
|
55
|
+
* session error where whoever deployed this can see it.
|
|
56
|
+
*
|
|
57
|
+
* **Blanket, and only because of the shape of this body.** Every failure the
|
|
58
|
+
* desk can talk about is RETURNED above and below — the empty board, a
|
|
59
|
+
* destination that is not Slack, both halves of a `ChannelDeliveryError` — so
|
|
60
|
+
* anything that reaches `onError` here is a deploy that is not finished or a
|
|
61
|
+
* bug in this file, and neither is fixed by asking the model to try again. A
|
|
62
|
+
* tool whose body can throw for a transient reason should classify instead:
|
|
63
|
+
* return a `ToolFailure` for the recoverable throws and re-throw only the rest.
|
|
31
64
|
*/
|
|
32
65
|
export default briefingSlot.tool({
|
|
33
66
|
description:
|
|
@@ -74,4 +107,9 @@ export default briefingSlot.tool({
|
|
|
74
107
|
"the briefing back out — they have it in writing now.",
|
|
75
108
|
};
|
|
76
109
|
},
|
|
110
|
+
// See the note above: the only throw this body has is `requireEnv`'s, and a
|
|
111
|
+
// missing webhook is unfixable from inside the call. Re-throwing keeps the
|
|
112
|
+
// SDK's own message — which names the variable and how to set it — as the
|
|
113
|
+
// fatal error's `cause`.
|
|
114
|
+
onError: unfinishedDeployIsFatal,
|
|
77
115
|
});
|
|
@@ -178,6 +178,9 @@ export const transcribeBatch = workflow({
|
|
|
178
178
|
|
|
179
179
|
export default workflowApp({
|
|
180
180
|
name: "Transcription Desk",
|
|
181
|
+
// The listing line. It names all THREE routes because choosing between them
|
|
182
|
+
// is the product.
|
|
183
|
+
description: "Transcribes a recording three ways: chunked, streaming while it uploads, or batch",
|
|
181
184
|
workflows: { transcribe, transcribeStream, transcribeBatch },
|
|
182
185
|
// Checked at deploy time, so a missing key is a warning naming it rather than
|
|
183
186
|
// a run that fails on its second step.
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* tools and read as a model that refuses to act.
|
|
30
30
|
*/
|
|
31
31
|
import agentDef from "virtual:aai/agent";
|
|
32
|
-
import { dialogRefusalPattern } from "@alexkroman1/aai/testing";
|
|
32
|
+
import { dialogRefusalPattern, eventsOf, isEvent } from "@alexkroman1/aai/testing";
|
|
33
33
|
import {
|
|
34
34
|
describeTurn,
|
|
35
35
|
type EvalSession,
|
|
@@ -70,12 +70,14 @@ const ProjectedTrip = z.object({
|
|
|
70
70
|
* every tool call, so the stream carries one per step.
|
|
71
71
|
*/
|
|
72
72
|
function framesBeforeConfirm(session: EvalSession): z.infer<typeof ProjectedTrip>[] {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
const events = [...session.events()];
|
|
74
|
+
// `isEvent`/`eventsOf` pick members BY NAME, so neither this nor the filter
|
|
75
|
+
// below restates the event union — a misspelled name is a compile error.
|
|
76
|
+
const confirmAt = events.findIndex(
|
|
77
|
+
(e) => isEvent(e, "tool.called") && e.toolName === "confirm_action",
|
|
78
|
+
);
|
|
79
|
+
const before = confirmAt < 0 ? events : events.slice(0, confirmAt);
|
|
80
|
+
return eventsOf(before, "state.updated").map((e) => ProjectedTrip.parse(e.state));
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** The def a DEPLOYED agent runs: authored, plus what `tools/` declares. */
|
|
2
2
|
import agentDef from "virtual:aai/agent";
|
|
3
|
-
import type { SessionEventHandler, ToolContext } from "@alexkroman1/aai";
|
|
4
|
-
import type { SessionEvent } from "@alexkroman1/aai/protocol";
|
|
3
|
+
import type { SessionEvent, SessionEventHandler, ToolContext } from "@alexkroman1/aai";
|
|
5
4
|
import {
|
|
6
5
|
createToolContext,
|
|
7
6
|
expectDialogOk,
|
|
@@ -29,6 +29,10 @@ import { gateFlow, tripProjection } from "./shared.ts";
|
|
|
29
29
|
*/
|
|
30
30
|
export default agent({
|
|
31
31
|
name: "Swiss Air Concierge",
|
|
32
|
+
// What the desk does, for whoever is reading a list of agents. It names the
|
|
33
|
+
// four specialists as the four things a caller can ask for, which is how a
|
|
34
|
+
// caller would say it and how the dialog stack is organised.
|
|
35
|
+
description: "Changes flights, hotels, car rentals and excursions for a booked traveller",
|
|
32
36
|
// The stack, the ticket and the itinerary exist before the first tool call,
|
|
33
37
|
// so a resumed connection has something to project.
|
|
34
38
|
// One projection replaces a `ctx.send` in each of eleven tools — and is the
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// `../code-interpreter-agent/agent.eval.test.ts`.
|
|
15
15
|
|
|
16
16
|
import agentDef from "virtual:aai/agent";
|
|
17
|
-
import { expectToolBeforeSpeech } from "@alexkroman1/aai-runtime/eval";
|
|
17
|
+
import { describeTurn, expectToolBeforeSpeech } from "@alexkroman1/aai-runtime/eval";
|
|
18
18
|
import { describeEval } from "@alexkroman1/aai-runtime/eval/vitest";
|
|
19
19
|
import { expect } from "vitest";
|
|
20
20
|
|
|
@@ -66,16 +66,42 @@ describeEval(agentDef, (test) => {
|
|
|
66
66
|
test(
|
|
67
67
|
"cites a site that appeared in its own results",
|
|
68
68
|
async ({ session }) => {
|
|
69
|
-
|
|
69
|
+
// A fact with ABUNDANT, stable sources, because this case measures the
|
|
70
|
+
// CITATION and everything else has to be a foregone conclusion. Two other
|
|
71
|
+
// questions failed here for opposite reasons: "who is the current CEO of
|
|
72
|
+
// Boeing" is answerable from training data, so a run answered it from
|
|
73
|
+
// memory and cited nothing; "the latest news about Boeing this week" made
|
|
74
|
+
// the desk really search and come back empty ("I'm having trouble pulling
|
|
75
|
+
// up the latest news"), which is a thin news day and not a citation bug.
|
|
76
|
+
// Whether Scout searches a fact it is sure of is the case ABOVE.
|
|
77
|
+
const turn = await session.say("Who was the first person to walk on the moon?");
|
|
70
78
|
|
|
71
79
|
const labels = hostLabels(turn);
|
|
72
|
-
|
|
80
|
+
const spoken = turn.text.toLowerCase();
|
|
81
|
+
|
|
82
|
+
// BOTH branches are the same rule, and the open web decides which one
|
|
83
|
+
// this run gets. A search that comes back empty or errors is not a
|
|
84
|
+
// citation bug — but it is where the stronger half of the claim lives, so
|
|
85
|
+
// the case measures that instead of failing on a thin result. Measured
|
|
86
|
+
// failing exactly here: "I couldn't reach the information right now. But
|
|
87
|
+
// according to historical records, Neil Armstrong was the first person to
|
|
88
|
+
// walk on the moon" obeyed "say that instead of naming a source" to the
|
|
89
|
+
// letter while stating a fact it had never read. The prompt now says to
|
|
90
|
+
// stop there, and this is what holds it to that.
|
|
91
|
+
if (labels.length === 0) {
|
|
92
|
+
expect(spoken, describeTurn(turn)).toMatch(/could ?n.?t|cannot|unable|no results|nothing/);
|
|
93
|
+
expect(spoken, describeTurn(turn)).not.toMatch(/armstrong/);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
73
97
|
// "Cite sources by website name" — and cite one you read. A reply that
|
|
74
98
|
// names an outlet absent from the results is the fabrication this case
|
|
75
99
|
// exists to catch, and it fails here exactly like a reply that cites
|
|
76
100
|
// nothing at all.
|
|
77
|
-
|
|
78
|
-
|
|
101
|
+
expect(
|
|
102
|
+
labels.filter((label) => spoken.includes(label)),
|
|
103
|
+
describeTurn(turn),
|
|
104
|
+
).not.toEqual([]);
|
|
79
105
|
},
|
|
80
106
|
{ live: true },
|
|
81
107
|
);
|
|
@@ -85,6 +85,22 @@ describe("web-research-agent template", () => {
|
|
|
85
85
|
// never says "search" is the framework default wearing Scout's name.
|
|
86
86
|
expect(expectPromptBuiltinsDeclared(agentDef)).toContain("web_search");
|
|
87
87
|
});
|
|
88
|
+
|
|
89
|
+
test("one call has a ceiling on what it can spend", () => {
|
|
90
|
+
// Scout is the only starter whose context grows with text it did not write:
|
|
91
|
+
// every `visit_webpage` result is appended to the conversation and re-sent
|
|
92
|
+
// on every later turn, and `maxSteps` bounds one reply rather than a call.
|
|
93
|
+
// So the failure this catches is a deletion — the budget is a whole line
|
|
94
|
+
// that reads like tidy-up, and losing it is invisible until somebody's bill
|
|
95
|
+
// arrives.
|
|
96
|
+
//
|
|
97
|
+
// The NUMBER is deliberately not pinned, per this file's own rule: raising
|
|
98
|
+
// or lowering the ceiling is a first customization, and a spec that fails
|
|
99
|
+
// on it fails inside a file the user never wrote. What must survive is that
|
|
100
|
+
// there is a ceiling at all.
|
|
101
|
+
const totalTokens = expectDeployable(agentDef).usageLimits?.totalTokens;
|
|
102
|
+
expect(totalTokens).toBeGreaterThan(0);
|
|
103
|
+
});
|
|
88
104
|
});
|
|
89
105
|
|
|
90
106
|
/** A plausible endpoint, only ever read back out of the config this sets. */
|
|
@@ -90,9 +90,39 @@ const mcpServers: McpServers | undefined = ARCHIVE ? { [ARCHIVE_KEY]: ARCHIVE }
|
|
|
90
90
|
|
|
91
91
|
export default agent({
|
|
92
92
|
name: "Scout",
|
|
93
|
+
// The listing line — a registry row, `aai list`, the studio's picker. Never
|
|
94
|
+
// the model: the researcher rules are `system-prompt.md`'s. It names the
|
|
95
|
+
// citation because that is what separates Scout from a model guessing.
|
|
96
|
+
description: "Answers questions by searching the open web and citing what it found",
|
|
93
97
|
greeting:
|
|
94
98
|
"Hey, I'm Scout. I search the web for answers. Try asking me something like, what happened in tech news today, or who won the last World Cup.",
|
|
95
99
|
builtinTools: ["web_search", "visit_webpage"],
|
|
100
|
+
/**
|
|
101
|
+
* A ceiling on what one call may spend — the one knob this starter needs and
|
|
102
|
+
* the other templates do not.
|
|
103
|
+
*
|
|
104
|
+
* Scout is the only agent here whose context grows with text it did not
|
|
105
|
+
* write. Every `visit_webpage` result (capped at `MAX_PAGE_CHARS`, ~2,500
|
|
106
|
+
* tokens) is appended to the conversation and RE-SENT on every later turn, so
|
|
107
|
+
* a long call reading a dozen pages spends roughly the square of what it
|
|
108
|
+
* read. Nothing else bounds that: `maxSteps` bounds one reply, not a call.
|
|
109
|
+
*
|
|
110
|
+
* The number is deliberately far above any real research call — a few pages
|
|
111
|
+
* over a few dozen turns lands an order of magnitude under it — so it is a
|
|
112
|
+
* runaway guard and not a budget a caller can feel. It is here because this
|
|
113
|
+
* is a STARTER: it deploys with two builtins and no credential of its own, on
|
|
114
|
+
* somebody's URL, and the shape of "left running" is exactly what this
|
|
115
|
+
* catches.
|
|
116
|
+
*
|
|
117
|
+
* **What it costs is stated rather than hidden.** Crossing it is fatal: the
|
|
118
|
+
* session ends with an `error.reported` frame and a browser client releases
|
|
119
|
+
* the microphone, so the caller hears a dropped call rather than an
|
|
120
|
+
* explanation. An agent that wants to say something first watches
|
|
121
|
+
* `usage.updated` through `agent({ events })` and speaks before the cap
|
|
122
|
+
* arrives — a fair amount of machinery for a starter, which is why this one
|
|
123
|
+
* takes the blunt version and says so.
|
|
124
|
+
*/
|
|
125
|
+
usageLimits: { totalTokens: 500_000 },
|
|
96
126
|
// Spread rather than `mcpServers: undefined`: an agent with no archive
|
|
97
127
|
// declares no server and asks a deploy for no credential, which is the
|
|
98
128
|
// shape every field on this call already has.
|
|
@@ -4,6 +4,13 @@ THE RULE: every turn where the caller asks for a fact begins with a web_search
|
|
|
4
4
|
call. Not a sentence, not a reply — the search. You have no knowledge of your
|
|
5
5
|
own, so until a result comes back you have nothing to say.
|
|
6
6
|
|
|
7
|
+
- WHEN A SEARCH COMES BACK EMPTY OR ERRORS, the whole of your reply is that you
|
|
8
|
+
could not find it and they can ask again. Nothing else. Do not add the answer
|
|
9
|
+
you already knew, not after "but", not as background, not as "historical
|
|
10
|
+
records say", not even if you are sure — a fact with no source is the one
|
|
11
|
+
thing this desk must never say, and putting an apology in front of it makes it
|
|
12
|
+
worse rather than better. There is no version of this reply that contains the
|
|
13
|
+
answer.
|
|
7
14
|
- Search even when you are certain. Certainty is the case this rule exists for:
|
|
8
15
|
"Who won the 2022 World Cup?" is a search, because a fact you did not just
|
|
9
16
|
read is stale and has no source to attach to it.
|
|
@@ -11,8 +18,7 @@ own, so until a result comes back you have nothing to say.
|
|
|
11
18
|
appear in a web_search or visit_webpage result you read in THIS turn.
|
|
12
19
|
- Name the source in the answer, every time: "According to Reuters, ..." or
|
|
13
20
|
"Wikipedia says ...". Name the site the result actually came from — naming a
|
|
14
|
-
publication you did not just read is a fabrication.
|
|
15
|
-
back, say that instead of naming a source.
|
|
21
|
+
publication you did not just read is a fabrication.
|
|
16
22
|
- Use visit_webpage when the search snippets aren't detailed enough.
|
|
17
23
|
- Some deployments give you extra research tools whose names begin with `mcp_`
|
|
18
24
|
— a private archive, a wiki, a docs server the open web cannot reach. Use
|