@cavelon/cli 0.1.4 → 0.1.5

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.
@@ -22,11 +22,62 @@ Write cases for:
22
22
 
23
23
  - the questions the solution exists for, with the facts a good answer needs;
24
24
  - edge cases: out of scope, ambiguous, a follow-up in the same conversation;
25
- - the tools it must call, and the ones it must not;
26
- - what it must refuse or hand over;
25
+ - the tools it must call, and the ones it must not (`tool_called`,
26
+ `tool_not_called`, below);
27
+ - what it must refuse or hand over, and to which agent (`handoff_to`,
28
+ `answered_by`);
27
29
  - in a pipeline with an approval: the cases that must reach it, and the ones
28
30
  that must not.
29
31
 
32
+ ## Assertions: tools and routing
33
+
34
+ A step's `evaluation_criteria` can hold, besides the judge's criteria (plain
35
+ sentences), **assertions**: objects with a `type` and a `value`, checked in
36
+ code before the judge runs. A failed assertion fails the step whatever the
37
+ judge says, so use them for facts with one right answer:
38
+
39
+ | Type | Value | Passes when |
40
+ |---|---|---|
41
+ | `tool_called` | tool slug | the step called the tool |
42
+ | `tool_not_called` | tool slug | the step did not call it |
43
+ | `answered_by` | agent slug | that agent produced the answer (it made the step's last model call) |
44
+ | `handoff_to` | agent slug | the step handed the turn to that agent |
45
+
46
+ The answer text cannot show which agent wrote it, so make routing part of the
47
+ regression wherever a solution has a handoff. For an entry agent that should
48
+ hand price questions to a ticket agent:
49
+
50
+ ```yaml
51
+ test_cases:
52
+ - name: Family ticket price goes to the ticket agent
53
+ steps:
54
+ - user_message: What does a family ticket cost?
55
+ evaluation_criteria:
56
+ - States the price of the family ticket.
57
+ - {type: handoff_to, value: ticket-agent}
58
+ - {type: answered_by, value: ticket-agent}
59
+ - {type: tool_called, value: search_documents}
60
+ - name: Opening hours stay with the front desk
61
+ steps:
62
+ - user_message: When are you open?
63
+ evaluation_criteria:
64
+ - States the opening hours.
65
+ - {type: answered_by, value: front-desk}
66
+ ```
67
+
68
+ `answered_by` with the entry agent's slug checks the opposite: that a question
69
+ stays where it is. A consulted agent is a tool call of the agent that consulted
70
+ it, which still answers, so check a consultation with `tool_called` and the
71
+ consult tool's name, not with `handoff_to`. Use the slugs from
72
+ `package/agents.yaml`.
73
+
74
+ `cavelon validate` checks the assertions against the instance's package
75
+ schema where the schema describes a step's criteria. Where it does not, it
76
+ warns `test_assertion_unchecked`: an instance that does not know a type grades
77
+ it as a judge criterion instead of checking it, so read `cavelon docs get
78
+ concepts/regression-testing` for the types the instance knows before relying on
79
+ `answered_by` or `handoff_to`.
80
+
30
81
  ## Testing an approval
31
82
 
32
83
  A test run never waits for a person and never approves anything. A run that
@@ -92,13 +143,29 @@ carries the id its route needs. A case's traces are under its
92
143
  under the test run's id; a wrong id answers with a hint naming the right one.
93
144
  A low-scoring pass shows the judge's reasoning too.
94
145
 
146
+ Each step names the agent that answered it (AGENT, `agent` in `--json`), and a
147
+ case that did not pass says `Answered by: <agent>` under its reason: the first
148
+ thing to check when a routing assertion failed. A failed assertion's reason is
149
+ the case's reason, and `--json` carries each assertion's result in
150
+ `judge_breakdown.deterministic_criteria` (expected, observed, reasoning). A
151
+ knowledge search's spans show what the agent recorded the search found
152
+ (`knowledge_outcome`: `usable_evidence`, `content_gap`, `unusable_hits`,
153
+ `retrieval_fault` or `deliberately_unanswerable`) on the search's tool span
154
+ and its retrieval span; a search without one is one the agent did not
155
+ classify. An instance that records none shows no such column.
156
+
95
157
  ## Optimizing
96
158
 
97
159
  Change one thing at a time, then run the same suite again and compare:
98
160
 
99
161
  - **Wrong or missing facts:** check retrieval first (which chunks came back in
100
- the retrieval span). Fix the documents or the knowledge base's settings
101
- before the prompt.
162
+ the retrieval span, and its `knowledge_outcome`: `content_gap` means the
163
+ knowledge base lacks the answer, `unusable_hits` that what came back did not
164
+ answer it, `retrieval_fault` that the search failed). Fix the documents or
165
+ the knowledge base's settings before the prompt.
166
+ - **Wrong agent answered:** the handoff instructions of the entry agent, and
167
+ the target agent's description, decide where a question goes; fix those, and
168
+ keep the `answered_by` and `handoff_to` assertions that caught it.
102
169
  - **Wrong tool, or a tool called with bad arguments:** sharpen the tool's
103
170
  description and parameters, then the agent's instructions about when to use it.
104
171
  - **Right facts, poor answer:** adjust the agent's instructions; keep them short
@@ -17,7 +17,7 @@ export async function searchTenants(client, text) {
17
17
  const found = await readTenantless(client, { search: text });
18
18
  return found && !found.refused ? (found.tenants ?? []) : [];
19
19
  }
20
- export async function chooseTenant(ctx, client, reach) {
20
+ export async function chooseTenant(ctx, client, reach, options = {}) {
21
21
  const { tenants, reachesAll } = reach;
22
22
  if (!reachesAll && tenants.length === 1)
23
23
  return { kind: "chosen", tenant: tenants[0], how: "only" };
@@ -25,17 +25,24 @@ export async function chooseTenant(ctx, client, reach) {
25
25
  return { kind: "none" };
26
26
  if (!canAsk(ctx))
27
27
  return { kind: "open" };
28
- const intro = reachesAll
29
- ? `This token reaches every tenant on ${client.url}.${tenants.length ? " Yours:" : ""}`
30
- : `This token reaches ${tenants.length} tenants on ${client.url}:`;
28
+ const later = reachesAll && options.later;
29
+ const intro = later
30
+ ? `This token works in every tenant on ${client.url}, one at a time: \`cavelon use\` switches, ` +
31
+ `and --tenant or \`tenant:\` in cavelon.yaml choose one per command or per solution folder.${tenants.length ? "\nYours:" : ""}`
32
+ : reachesAll
33
+ ? `This token reaches every tenant on ${client.url}.${tenants.length ? " Yours:" : ""}`
34
+ : `This token reaches ${tenants.length} tenants on ${client.url}:`;
31
35
  const picked = await pick(ctx, {
32
36
  intro,
33
- question: "Which tenant?",
37
+ question: later ? "Which tenant to start in?" : "Which tenant?",
34
38
  items: tenants,
35
39
  extra: (t) => t.role ?? undefined,
36
40
  preferred: tenants.find((t) => t.is_default),
37
41
  search: reachesAll ? (text) => searchTenants(client, text) : undefined,
42
+ ...(later ? { later: "choose later" } : {}),
38
43
  });
44
+ if ("later" in picked)
45
+ return { kind: "later" };
39
46
  if (!("item" in picked))
40
47
  throw new Error("unreachable: the tenant list offers no other entry");
41
48
  return { kind: "chosen", tenant: picked.item, how: "picked" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",