@introspection-ai/recipes 0.57.0 → 0.59.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/dist/agents.d.ts +6 -0
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js.map +1 -1
- package/dist/batch/files.d.ts +5 -0
- package/dist/batch/files.d.ts.map +1 -1
- package/dist/batch/files.js +39 -0
- package/dist/batch/files.js.map +1 -1
- package/dist/batch/index.d.ts +33 -7
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +59 -27
- package/dist/batch/index.js.map +1 -1
- package/dist/batch/lines.d.ts +51 -9
- package/dist/batch/lines.d.ts.map +1 -1
- package/dist/batch/lines.js +86 -30
- package/dist/batch/lines.js.map +1 -1
- package/dist/batch/runner.d.ts +44 -5
- package/dist/batch/runner.d.ts.map +1 -1
- package/dist/batch/runner.js +433 -52
- package/dist/batch/runner.js.map +1 -1
- package/dist/compaction.d.ts +11 -0
- package/dist/compaction.d.ts.map +1 -0
- package/dist/compaction.js +27 -0
- package/dist/compaction.js.map +1 -0
- package/dist/issues/arguments.d.ts +51 -1
- package/dist/issues/arguments.d.ts.map +1 -1
- package/dist/issues/arguments.generated.d.ts.map +1 -1
- package/dist/issues/arguments.generated.js +97 -0
- package/dist/issues/arguments.generated.js.map +1 -1
- package/dist/issues/module.d.ts.map +1 -1
- package/dist/issues/module.js +8 -1
- package/dist/issues/module.js.map +1 -1
- package/dist/issues/tool.d.ts.map +1 -1
- package/dist/issues/tool.js +127 -4
- package/dist/issues/tool.js.map +1 -1
- package/dist/issues/types.d.ts +40 -1
- package/dist/issues/types.d.ts.map +1 -1
- package/dist/issues/types.js +8 -1
- package/dist/issues/types.js.map +1 -1
- package/dist/judges/classifier.d.ts +16 -0
- package/dist/judges/classifier.d.ts.map +1 -0
- package/dist/judges/classifier.js +47 -0
- package/dist/judges/classifier.js.map +1 -0
- package/dist/judges/cli-main.d.ts +41 -0
- package/dist/judges/cli-main.d.ts.map +1 -0
- package/dist/judges/cli-main.js +184 -0
- package/dist/judges/cli-main.js.map +1 -0
- package/dist/judges/cli.d.ts +2 -0
- package/dist/judges/cli.d.ts.map +1 -0
- package/dist/judges/cli.js +43 -0
- package/dist/judges/cli.js.map +1 -0
- package/dist/judges/controller.d.ts +78 -0
- package/dist/judges/controller.d.ts.map +1 -0
- package/dist/judges/controller.js +243 -0
- package/dist/judges/controller.js.map +1 -0
- package/dist/judges/definition.d.ts +93 -0
- package/dist/judges/definition.d.ts.map +1 -0
- package/dist/judges/definition.js +105 -0
- package/dist/judges/definition.js.map +1 -0
- package/dist/judges/gate.d.ts +46 -0
- package/dist/judges/gate.d.ts.map +1 -0
- package/dist/judges/gate.js +256 -0
- package/dist/judges/gate.js.map +1 -0
- package/dist/judges/identity.d.ts +21 -0
- package/dist/judges/identity.d.ts.map +1 -0
- package/dist/judges/identity.js +48 -0
- package/dist/judges/identity.js.map +1 -0
- package/dist/judges/index.d.ts +10 -0
- package/dist/judges/index.d.ts.map +1 -0
- package/dist/judges/index.js +10 -0
- package/dist/judges/index.js.map +1 -0
- package/dist/judges/resolve-hooks.d.ts +10 -0
- package/dist/judges/resolve-hooks.d.ts.map +1 -0
- package/dist/judges/resolve-hooks.js +25 -0
- package/dist/judges/resolve-hooks.js.map +1 -0
- package/dist/judges/run.d.ts +130 -0
- package/dist/judges/run.d.ts.map +1 -0
- package/dist/judges/run.js +356 -0
- package/dist/judges/run.js.map +1 -0
- package/dist/judges/session.d.ts +9 -0
- package/dist/judges/session.d.ts.map +1 -0
- package/dist/judges/session.js +109 -0
- package/dist/judges/session.js.map +1 -0
- package/dist/judges/trajectory.d.ts +82 -0
- package/dist/judges/trajectory.d.ts.map +1 -0
- package/dist/judges/trajectory.js +170 -0
- package/dist/judges/trajectory.js.map +1 -0
- package/dist/judges/verdict.d.ts +31 -0
- package/dist/judges/verdict.d.ts.map +1 -0
- package/dist/judges/verdict.js +121 -0
- package/dist/judges/verdict.js.map +1 -0
- package/dist/model-binding.d.ts +12 -0
- package/dist/model-binding.d.ts.map +1 -1
- package/dist/model-binding.js +38 -6
- package/dist/model-binding.js.map +1 -1
- package/dist/prompts/budget.d.ts +28 -0
- package/dist/prompts/budget.d.ts.map +1 -0
- package/dist/prompts/budget.js +31 -0
- package/dist/prompts/budget.js.map +1 -0
- package/dist/prompts/builder.d.ts +32 -0
- package/dist/prompts/builder.d.ts.map +1 -0
- package/dist/prompts/builder.js +22 -0
- package/dist/prompts/builder.js.map +1 -0
- package/dist/prompts/builders/conversation-synthesis.d.ts +106 -0
- package/dist/prompts/builders/conversation-synthesis.d.ts.map +1 -0
- package/dist/prompts/builders/conversation-synthesis.js +495 -0
- package/dist/prompts/builders/conversation-synthesis.js.map +1 -0
- package/dist/prompts/builders/trajectory.d.ts +14 -0
- package/dist/prompts/builders/trajectory.d.ts.map +1 -0
- package/dist/prompts/builders/trajectory.js +66 -0
- package/dist/prompts/builders/trajectory.js.map +1 -0
- package/dist/prompts/fit.d.ts +7 -0
- package/dist/prompts/fit.d.ts.map +1 -0
- package/dist/prompts/fit.js +15 -0
- package/dist/prompts/fit.js.map +1 -0
- package/dist/prompts/index.d.ts +8 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +8 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/registry.d.ts +8 -0
- package/dist/prompts/registry.d.ts.map +1 -0
- package/dist/prompts/registry.js +15 -0
- package/dist/prompts/registry.js.map +1 -0
- package/dist/prompts/spec.d.ts +16 -0
- package/dist/prompts/spec.d.ts.map +1 -0
- package/dist/prompts/spec.js +12 -0
- package/dist/prompts/spec.js.map +1 -0
- package/dist/prompts/template.d.ts +12 -0
- package/dist/prompts/template.d.ts.map +1 -0
- package/dist/prompts/template.js +31 -0
- package/dist/prompts/template.js.map +1 -0
- package/dist/prompts/text.d.ts +5 -0
- package/dist/prompts/text.d.ts.map +1 -0
- package/dist/prompts/text.js +13 -0
- package/dist/prompts/text.js.map +1 -0
- package/dist/recipe/agent.d.ts +11 -1
- package/dist/recipe/agent.d.ts.map +1 -1
- package/dist/recipe/agent.js +76 -1
- package/dist/recipe/agent.js.map +1 -1
- package/dist/recipe/manifest.generated.d.ts +1 -1
- package/dist/recipe/manifest.generated.js +1 -1
- package/dist/recipe/model.d.ts +5 -12
- package/dist/recipe/model.d.ts.map +1 -1
- package/dist/recipe/model.js +197 -263
- package/dist/recipe/model.js.map +1 -1
- package/dist/recipe/session.d.ts +5 -0
- package/dist/recipe/session.d.ts.map +1 -1
- package/dist/recipe/session.js +82 -4
- package/dist/recipe/session.js.map +1 -1
- package/dist/run-controller.d.ts.map +1 -1
- package/dist/run-controller.js +4 -0
- package/dist/run-controller.js.map +1 -1
- package/dist/session.d.ts +6 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +6 -2
- package/dist/session.js.map +1 -1
- package/docs/README.md +1 -0
- package/docs/agent-composition.md +3 -2
- package/docs/issues/README.md +34 -12
- package/docs/judges.md +269 -0
- package/docs/providers.md +12 -3
- package/docs/recipe-format.md +80 -12
- package/docs/recipe-judges.md +149 -61
- package/package.json +14 -6
- package/skills/issues/SKILL.md +28 -10
package/docs/issues/README.md
CHANGED
|
@@ -105,14 +105,14 @@ sandbox. `create` files the issue on the calling task
|
|
|
105
105
|
|
|
106
106
|
## Commands
|
|
107
107
|
|
|
108
|
-
| Command | Takes
|
|
109
|
-
| ------------ |
|
|
110
|
-
| `search` | `query`, `status`, `assignee`, `container`, `label`, `limit`
|
|
111
|
-
| `get` | `handle`
|
|
112
|
-
| `create` | `title`, `description`, `priority`, `labels`, `assignee`, `container`, `issue_type`
|
|
113
|
-
| `update` | `handle`, `title`, `description`, `priority`, `labels`, `assignee`
|
|
114
|
-
| `comment` | `handle`, `body`
|
|
115
|
-
| `transition` | `handle`, `status` (a name or a category)
|
|
108
|
+
| Command | Takes | Does |
|
|
109
|
+
| ------------ | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
110
|
+
| `search` | `query`, `status`, `assignee`, `container`, `label`, `limit` | find issues |
|
|
111
|
+
| `get` | `handle` | one issue with its comments and attachments |
|
|
112
|
+
| `create` | `title`, `description`, `priority`, `labels`, `assignee`, `container`, `issue_type`, `attachments` | a new issue |
|
|
113
|
+
| `update` | `handle`, `title`, `description`, `priority`, `labels`, `assignee`, `add_attachments`, `remove_attachments` | change fields, add or remove attachments |
|
|
114
|
+
| `comment` | `handle`, `body` | add a comment |
|
|
115
|
+
| `transition` | `handle`, `status` (a name or a category) | move to another status |
|
|
116
116
|
|
|
117
117
|
## The shape
|
|
118
118
|
|
|
@@ -131,6 +131,7 @@ Every issue comes back in one shape, with a handle every later command takes:
|
|
|
131
131
|
| `container` | team | project, with the issue type | the project |
|
|
132
132
|
| `url` | ✓ | the site's `/browse/<key>` | not yet |
|
|
133
133
|
| `comments` (on `get`) | ✓ | ✓ | read with the issue |
|
|
134
|
+
| `attachments` (on `get`) | the issue's link attachments | the issue's remote links | every kind, read with the issue; an unknown kind is left out |
|
|
134
135
|
|
|
135
136
|
## What each provider supports
|
|
136
137
|
|
|
@@ -142,6 +143,7 @@ Every issue comes back in one shape, with a handle every later command takes:
|
|
|
142
143
|
| `update` | ✓ | ✓ | ✓; assignee: a member id, or `none` |
|
|
143
144
|
| `comment` | ✓ | ✓ | ✓ |
|
|
144
145
|
| `transition` | sets the state; a category picks the team's state of that type | applies the workflow transition that reaches the status | sets `status` |
|
|
146
|
+
| attachments | `link`, append-only | `link`, append-only | `link`, `file`, `event`, `span`; add (deduplicated) and remove |
|
|
145
147
|
|
|
146
148
|
An Introspection comment is an event attached to the issue. The provider
|
|
147
149
|
writes one with `POST /v1/issues/{id}/comments` and reads them with the issue
|
|
@@ -151,6 +153,23 @@ writes one with `POST /v1/issues/{id}/comments` and reads them with the issue
|
|
|
151
153
|
these, `comment` and an assignee search answer `not_supported`, and `get`
|
|
152
154
|
returns no comments.
|
|
153
155
|
|
|
156
|
+
## Attachments
|
|
157
|
+
|
|
158
|
+
An attachment is `{ id?, kind, ... }`: a `link` (`url`, `title`), a `file`
|
|
159
|
+
(`file_id`, `name`), an `event` (`event_id`) or a `span` (`trace_id`,
|
|
160
|
+
`span_id`). `create` takes `attachments`; `update` takes `add_attachments`
|
|
161
|
+
and `remove_attachments` (ids from `get`). The tool checks each item's
|
|
162
|
+
fields, then refuses with `not_supported` a kind outside the provider's
|
|
163
|
+
`capabilities.attachments.kinds`, or a removal when its `remove` is false.
|
|
164
|
+
|
|
165
|
+
Introspection writes them with the issue (`attachments` on create,
|
|
166
|
+
`add_attachments` and `remove_attachments` on update), and the server skips
|
|
167
|
+
one the issue already holds. Linear sends links as `save_issue`'s `links`,
|
|
168
|
+
whose title is required, so an untitled link takes its url as title. Jira
|
|
169
|
+
creates one remote link per item. Neither tracker can remove an attachment
|
|
170
|
+
through its tools here, and files, events and spans are not offered on them
|
|
171
|
+
yet.
|
|
172
|
+
|
|
154
173
|
## Tool maps
|
|
155
174
|
|
|
156
175
|
Each MCP adapter calls its server through one tool map
|
|
@@ -165,7 +184,7 @@ documentation; replace them with captured lists, fix the maps, and set
|
|
|
165
184
|
| -------- | -------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
166
185
|
| `linear` | search | `list_issues` | `query`, `state`, `assignee`, `team`, `label`, `limit` |
|
|
167
186
|
| `linear` | get | `get_issue`, `list_comments` | `id`; `issueId` |
|
|
168
|
-
| `linear` | create, update, transition | `save_issue` (else `create_issue`, `update_issue`) | `id`, `team`, `title`, `description`, `priority` (0–4), `labels`, `assignee`, `state`
|
|
187
|
+
| `linear` | create, update, transition | `save_issue` (else `create_issue`, `update_issue`) | `id`, `team`, `title`, `description`, `priority` (0–4), `labels`, `assignee`, `state`, `links` |
|
|
169
188
|
| `linear` | comment | `create_comment` | `issueId`, `body` |
|
|
170
189
|
| `linear` | transition by category | `list_issue_statuses` | `team` |
|
|
171
190
|
| `jira` | every call | `getAccessibleAtlassianResources` | none; the first site with Jira scopes gives `cloudId` |
|
|
@@ -176,14 +195,17 @@ documentation; replace them with captured lists, fix the maps, and set
|
|
|
176
195
|
| `jira` | update | `editJiraIssue` | `cloudId`, `issueIdOrKey`, `fields` |
|
|
177
196
|
| `jira` | comment | `addOrEditJiraIssueComment` (else `addCommentToJiraIssue`) | `cloudId`, `issueIdOrKey`, `commentBody` |
|
|
178
197
|
| `jira` | transition | `listJiraIssueTransitions` (else `getTransitionsForJiraIssue`), `transitionJiraIssue` | `cloudId`, `issueIdOrKey`, `transition: { id }` |
|
|
198
|
+
| `jira` | get, attachments | `listJiraIssueRemoteIssueLinks` | `cloudId`, `issueIdOrKey` |
|
|
199
|
+
| `jira` | create, update, links | `createJiraIssueRemoteIssueLink` | `cloudId`, `issueIdOrKey`, `object: { url, title }` |
|
|
179
200
|
|
|
180
201
|
## A provider of your own
|
|
181
202
|
|
|
182
|
-
A provider module is `{ kind: "issues", apiVersion:
|
|
203
|
+
A provider module is `{ kind: "issues", apiVersion: 2, id, capabilities,
|
|
183
204
|
mcp?, available?, createSession }` (`RecipeIssuesProviderModule`), importing
|
|
184
205
|
only types from `@introspection-ai/recipes/issues`. `capabilities` lists the
|
|
185
|
-
commands it serves, the fields it fills,
|
|
186
|
-
|
|
206
|
+
commands it serves, the fields it fills, the attachments it takes
|
|
207
|
+
(`attachments: { kinds, remove }`), every host it calls, and the options it
|
|
208
|
+
takes. Its session receives the declaration's options as `config.options`.
|
|
187
209
|
`createSession` returns one method per command; each receives the provider's
|
|
188
210
|
own reference (the handle without its prefix) and, for an MCP provider, a
|
|
189
211
|
caller bound to its server. A failure the model should read throws an
|
package/docs/judges.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# Running judges
|
|
2
|
+
|
|
3
|
+
Run a Recipe's [judges](recipe-judges.md) over conversations. Every run is one
|
|
4
|
+
[batch](batch.md): each judge and conversation pair is a line of it. One
|
|
5
|
+
conversation under ten judges and a thousand conversations under one judge are
|
|
6
|
+
the same run, with the batch's concurrency, its rate-limit retries and its
|
|
7
|
+
resume.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { resolveRecipe } from "@introspection-ai/recipes";
|
|
13
|
+
import {
|
|
14
|
+
createJudgeRunController,
|
|
15
|
+
loadJudges,
|
|
16
|
+
piClassifier,
|
|
17
|
+
runJudges,
|
|
18
|
+
} from "@introspection-ai/recipes/judges";
|
|
19
|
+
|
|
20
|
+
const recipeDir = "./my-recipe";
|
|
21
|
+
const judges = loadJudges(recipeDir);
|
|
22
|
+
const controller = createJudgeRunController({
|
|
23
|
+
recipe: resolveRecipe({ recipeDir }),
|
|
24
|
+
judges,
|
|
25
|
+
cwd: process.cwd(),
|
|
26
|
+
classify: piClassifier(),
|
|
27
|
+
concurrency: 8,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { results, skipped } = await runJudges({
|
|
31
|
+
judges,
|
|
32
|
+
input: ["monday.jsonl", "tuesday.jsonl"],
|
|
33
|
+
controller,
|
|
34
|
+
directory: "./judged",
|
|
35
|
+
});
|
|
36
|
+
await controller.shutdown();
|
|
37
|
+
|
|
38
|
+
for (const line of results) {
|
|
39
|
+
console.log(line.custom_id, line.judge, line.result, line.reasoning);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The judgements are returned and, with a `directory`, written to
|
|
44
|
+
`<directory>/results.jsonl`.
|
|
45
|
+
|
|
46
|
+
## From the command line
|
|
47
|
+
|
|
48
|
+
The package ships the same run as a script, for a host that launches it as a
|
|
49
|
+
process:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
node node_modules/@introspection-ai/recipes/dist/judges/cli.js \
|
|
53
|
+
--recipe ./my-recipe --input monday.jsonl --input tuesday.jsonl --out ./judged
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The script is started by Node rather than loaded by Pi, so it finds Pi's own
|
|
57
|
+
packages in the folder `PI_PACKAGE_DIR` names, else in the installed Pi whose
|
|
58
|
+
`pi` is on `PATH`. With `PI_PACKAGE_DIR` set, it needs no `pi` executable.
|
|
59
|
+
|
|
60
|
+
`--input -` reads conversations from standard input, and `--judge <name>`
|
|
61
|
+
keeps only the judges named. It runs on this machine's Pi: its logins and
|
|
62
|
+
provider keys, with each judge's `ai.fallbacks`. It prints one JSON report,
|
|
63
|
+
`{ schema_version, results, skipped, counts, stopped }`, and exits 0 when the
|
|
64
|
+
run finished, whatever the verdicts.
|
|
65
|
+
|
|
66
|
+
`--schema` prints the protocol the script speaks, `{"schema_version":2}`, and
|
|
67
|
+
exits 0 without loading Pi. A host checks it before running: the report's
|
|
68
|
+
`schema_version` is the same number.
|
|
69
|
+
|
|
70
|
+
### Where the judge definitions come from
|
|
71
|
+
|
|
72
|
+
The runner doesn't parse judge YAML. `introspection-recipe-check` normalizes
|
|
73
|
+
it, so the runner, the checker and the hosted platform all read the same
|
|
74
|
+
definition, and an [older `llm:` block](recipe-judges.md#the-older-llm-block)
|
|
75
|
+
means the same everywhere. By default, `loadJudges` runs the binary that
|
|
76
|
+
`INTROSPECTION_RECIPE_CHECK` names, or the `introspection-recipe-check` on
|
|
77
|
+
`PATH`, as `introspection-recipe-check judges`, with the judge files as JSON
|
|
78
|
+
`[{ "path", "content" }]` on standard input.
|
|
79
|
+
|
|
80
|
+
A host that links the recipe-check crate passes the definitions itself, and
|
|
81
|
+
nothing is spawned:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
node node_modules/@introspection-ai/recipes/dist/judges/cli.js \
|
|
85
|
+
--recipe ./my-recipe --input monday.jsonl --definitions judges.json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`judges.json` is exactly what `introspection-recipe-check judges` prints for the
|
|
89
|
+
Recipe's `judges/`: an array of
|
|
90
|
+
`{ "source_path", "definition", "warnings"? }`, which is the
|
|
91
|
+
`ParsedJudgeDefinition` of `parse_judge_definitions`. Each `definition` carries
|
|
92
|
+
its model only as `ai:`, never `llm:`. In code, pass the same
|
|
93
|
+
array as `loadJudges(recipeDir, { definitions })`. The judge files are still
|
|
94
|
+
read, for each judge's `definition_hash`.
|
|
95
|
+
|
|
96
|
+
## Input
|
|
97
|
+
|
|
98
|
+
`input` is one or more JSONL files, or the lines themselves. Several files run
|
|
99
|
+
as one batch. Each line is one conversation:
|
|
100
|
+
|
|
101
|
+
| Field | Required | Meaning |
|
|
102
|
+
| --------------------- | -------- | -------------------------------------------------------------------------------------------- |
|
|
103
|
+
| `custom_id` | yes | Your id for the conversation, unique across every input file. Defaults to `conversation_id`. |
|
|
104
|
+
| `trajectory` | yes | The conversation: a trajectory export's records, or events already normalized. |
|
|
105
|
+
| `conversation_id` | no | The platform conversation this is. Defaults to `custom_id`. |
|
|
106
|
+
| `system_instructions` | no | The agent's effective system instructions, when they are evidence too. |
|
|
107
|
+
| `feedback_events` | no | Feedback on the conversation, for a judge whose `on` matches `feedback`. |
|
|
108
|
+
| `environment` | no | Where the conversation ran. A judge's `sample_rate` applies only to `production` lines. |
|
|
109
|
+
|
|
110
|
+
A trajectory export's records are keyed by `role` (`user`, `assistant`, `tool`,
|
|
111
|
+
`reasoning`, `meta`); reasoning and meta records are not evidence. Normalized
|
|
112
|
+
events are keyed by `type`:
|
|
113
|
+
|
|
114
|
+
```jsonl
|
|
115
|
+
{
|
|
116
|
+
"custom_id": "c-1",
|
|
117
|
+
"trajectory": [
|
|
118
|
+
{
|
|
119
|
+
"type": "message",
|
|
120
|
+
"role": "user",
|
|
121
|
+
"content": "Where is my order?"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"type": "tool_call",
|
|
125
|
+
"id": "t1",
|
|
126
|
+
"name": "orders_get",
|
|
127
|
+
"arguments": {
|
|
128
|
+
"id": "42"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"type": "tool_result",
|
|
133
|
+
"tool_call_id": "t1",
|
|
134
|
+
"content": {
|
|
135
|
+
"status": "shipped"
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "message",
|
|
140
|
+
"role": "assistant",
|
|
141
|
+
"content": "It shipped yesterday."
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
A line may name a Pi session file in place of `trajectory`, as
|
|
148
|
+
`{"custom_id": "C1", "session_file": "tasks/C1/.introspection/session/….jsonl"}`:
|
|
149
|
+
the session's active branch is read as the conversation, without its system
|
|
150
|
+
prompt or reasoning.
|
|
151
|
+
|
|
152
|
+
A line that is not JSON, lacks a `trajectory`, has neither a `custom_id` nor a
|
|
153
|
+
`conversation_id`, or repeats a `custom_id` stops the run before anything is judged. A line whose trajectory
|
|
154
|
+
cannot be read, such as a tool result with no call, records an `error` for that
|
|
155
|
+
conversation and the rest carry on.
|
|
156
|
+
|
|
157
|
+
## Results
|
|
158
|
+
|
|
159
|
+
One line per judge and conversation, by judge and then in input order:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"custom_id": "c-1",
|
|
164
|
+
"judge": "helpful",
|
|
165
|
+
"conversation_id": "c-1",
|
|
166
|
+
"definition_hash": "9f2c…",
|
|
167
|
+
"contract_version": "3",
|
|
168
|
+
"result": "pass",
|
|
169
|
+
"status": "ok",
|
|
170
|
+
"reasoning": "Answered with the order's shipping status.",
|
|
171
|
+
"sequence_hash": "4be1…",
|
|
172
|
+
"model": "openai/gpt-5",
|
|
173
|
+
"usage": { "input_tokens": 1830, "output_tokens": 41, "total_tokens": 1871 },
|
|
174
|
+
"run_id": "agent-run-1a2b3c4d",
|
|
175
|
+
"attempts": 1
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- `result` is `pass`, `fail`, `not_applicable` or `error`. A judge that could
|
|
180
|
+
not reach a verdict records `error` with the reason in `error`; it is never
|
|
181
|
+
counted as a `fail`.
|
|
182
|
+
- A classifier judge adds `scores`, its probability of yes for each question
|
|
183
|
+
from 0 to 1, and its `reasoning` names each score against its threshold.
|
|
184
|
+
Questions are listed in name order.
|
|
185
|
+
- `sequence_hash` is the hash of the evidence the judge read (`evidenceHash`
|
|
186
|
+
of its input).
|
|
187
|
+
- `model` is the `<provider>/<model>` that answered, after any `ai.fallbacks`.
|
|
188
|
+
`usage` is the tokens the judgement took, counting cached prompt tokens as
|
|
189
|
+
input. It is present only when the model reported tokens, never as zeros.
|
|
190
|
+
Both come from the controller's `runDetails`. With a `directory`, they are
|
|
191
|
+
also kept in `<directory>/run-details.jsonl`, so a judgement resumed from an
|
|
192
|
+
earlier run keeps them.
|
|
193
|
+
- `definition_hash` is the SHA-256 of the judge file. Judgements compare only
|
|
194
|
+
when it and `contract_version` match.
|
|
195
|
+
- `judgement_id` is present when the judge has a registered id (see
|
|
196
|
+
[Platform settings](#platform-settings)). It is derived from the judge, its
|
|
197
|
+
definition, the evidence and the conversation, so the same judgement made
|
|
198
|
+
twice has the same id.
|
|
199
|
+
|
|
200
|
+
`skipped` lists each judge that did not run on a conversation, with the reason:
|
|
201
|
+
`gate` (its `on` did not match), `no_evidence`, `disabled` or `sampled_out`.
|
|
202
|
+
A skipped judgement is not written to the results.
|
|
203
|
+
|
|
204
|
+
## How a judge runs
|
|
205
|
+
|
|
206
|
+
- **An LLM judge** runs as a fresh session with the judge's `ai:` settings, no
|
|
207
|
+
tools, and the judge's `instructions` as its whole system prompt. The
|
|
208
|
+
conversation is the prompt. One code fence around the reply (` ```json ` in
|
|
209
|
+
any case, or a bare ` ``` `) is dropped first. A reply that is still not
|
|
210
|
+
JSON is sent back to be fixed, up to two times, and then checked: the
|
|
211
|
+
verdict must be in the vocabulary, and the reply must not repeat a span of
|
|
212
|
+
the conversation.
|
|
213
|
+
- **A classifier judge** is one decision-model call through `classify`, with
|
|
214
|
+
the judge's questions and a transcript slimmed to fit: long tool arguments
|
|
215
|
+
and results are clipped first, and what still does not fit loses its middle.
|
|
216
|
+
`piClassifier()` asks Pi's classifier models, with the provider's key read
|
|
217
|
+
from the environment. A run with classifier judges and no `classify` records
|
|
218
|
+
an `error` for each of their lines.
|
|
219
|
+
|
|
220
|
+
## Fallbacks and retries
|
|
221
|
+
|
|
222
|
+
A judge's `ai.fallbacks` apply as an agent's do: with Pi's `modelRegistry` and
|
|
223
|
+
no `credentials` of your own, the judge starts on the first model that has a
|
|
224
|
+
credential.
|
|
225
|
+
|
|
226
|
+
A batch expects rate limits, so a judge does not leave its model at the first
|
|
227
|
+
failure. `fallbackAfterRetries` (default 2) is how many retries the model gets
|
|
228
|
+
before the judge moves to the next fallback. Pi's `retry.maxRetries` must be
|
|
229
|
+
higher than that for a fallback to be reached. A classifier judge tries each
|
|
230
|
+
model once, in order.
|
|
231
|
+
|
|
232
|
+
When a line still fails on a rate limit, the batch waits, retries it up to
|
|
233
|
+
`max_attempts` times and lowers its concurrency until requests succeed again.
|
|
234
|
+
|
|
235
|
+
## Resuming
|
|
236
|
+
|
|
237
|
+
Run again with the same `directory` and each judge skips every conversation it
|
|
238
|
+
already judged successfully with the same definition and transcript. Editing a
|
|
239
|
+
judge file changes its `definition_hash`, so the edited judge runs again in
|
|
240
|
+
full; its earlier answers stay in `<directory>/batch/`.
|
|
241
|
+
|
|
242
|
+
## Platform settings
|
|
243
|
+
|
|
244
|
+
`operational` carries what a platform has set for each judge, by judge name:
|
|
245
|
+
|
|
246
|
+
| Field | Default | Meaning |
|
|
247
|
+
| ------------- | ------- | --------------------------------------------------------------- |
|
|
248
|
+
| `judge_id` | none | The judge's registered UUID. Judgement ids are derived from it. |
|
|
249
|
+
| `enabled` | `true` | `false` skips the judge. |
|
|
250
|
+
| `sample_rate` | 1 | The fraction of `production` conversations the judge runs on. |
|
|
251
|
+
|
|
252
|
+
Sampling is stable: the same judge and conversation are always in or out.
|
|
253
|
+
|
|
254
|
+
## Options
|
|
255
|
+
|
|
256
|
+
| Option | Default | Meaning |
|
|
257
|
+
| -------------- | -------- | ------------------------------------------------------------- |
|
|
258
|
+
| `judges` | required | The judges to run: `loadJudges(recipeDir)`, or a subset. |
|
|
259
|
+
| `input` | required | The conversations: JSONL paths (or `file:` URLs), or lines. |
|
|
260
|
+
| `controller` | required | Runs each judgement: `createJudgeRunController`, or your own. |
|
|
261
|
+
| `directory` | none | Where the run keeps its state and writes `results.jsonl`. |
|
|
262
|
+
| `concurrency` | 8 | Judgements in flight at once, across every judge. |
|
|
263
|
+
| `max_attempts` | 3 | How many times a rate-limited judgement is tried. |
|
|
264
|
+
| `operational` | none | Platform settings by judge name. |
|
|
265
|
+
| `signal` | none | Abort it to stop gracefully; `stopped` is then `true`. |
|
|
266
|
+
| `onResult` | none | Called with each judgement as it completes. |
|
|
267
|
+
|
|
268
|
+
Give the controller at least the run's `concurrency`: an LLM judge's sessions
|
|
269
|
+
count against the controller's own limit.
|
package/docs/providers.md
CHANGED
|
@@ -138,9 +138,9 @@ One `issues` tool with these commands:
|
|
|
138
138
|
| Command | Does |
|
|
139
139
|
| --- | --- |
|
|
140
140
|
| `search` | find issues by text, status, assignee, project or label |
|
|
141
|
-
| `get` | one issue with its comments |
|
|
142
|
-
| `create` | a new issue |
|
|
143
|
-
| `update` | title, description, assignee, labels, priority |
|
|
141
|
+
| `get` | one issue with its comments and attachments |
|
|
142
|
+
| `create` | a new issue, with attachments |
|
|
143
|
+
| `update` | title, description, assignee, labels, priority; add or remove attachments |
|
|
144
144
|
| `comment` | add a comment |
|
|
145
145
|
| `transition` | move to another status |
|
|
146
146
|
|
|
@@ -166,6 +166,7 @@ later command takes:
|
|
|
166
166
|
| `labels` | labels | labels | tags |
|
|
167
167
|
| `container` | team | project and issue type | the Recipe's project |
|
|
168
168
|
| `url`, `created_at`, `updated_at` | ✓ | ✓ | ✓ |
|
|
169
|
+
| `attachments` (`link`, `file`, `event`, `span`, each with its `id`) | links: the issue's attachments | links: the issue's remote links | every kind |
|
|
169
170
|
|
|
170
171
|
The providers differ, so each declares the commands and fields it supports in
|
|
171
172
|
`capabilities`, as productivity providers do:
|
|
@@ -184,6 +185,14 @@ The providers differ, so each declares the commands and fields it supports in
|
|
|
184
185
|
name the caller's. A name or email is refused with `invalid_request`. A data
|
|
185
186
|
plane whose issues have no assignee answers an assignee search with
|
|
186
187
|
`not_supported` rather than list every issue.
|
|
188
|
+
- **Attachments:** a provider declares the kinds it takes and whether it
|
|
189
|
+
removes in `capabilities.attachments`, and the tool answers anything else
|
|
190
|
+
with `not_supported`, naming what the provider can do. Introspection takes
|
|
191
|
+
all four kinds, appends with dedup by identity and removes by id
|
|
192
|
+
(`add_attachments`, `remove_attachments` on `PATCH /v1/issues/{id}`).
|
|
193
|
+
Linear (`save_issue` `links`) and Jira (a remote link per item) take links
|
|
194
|
+
alone, append-only; Jira's file upload needs a local path the tool does not
|
|
195
|
+
have.
|
|
187
196
|
- **Moving an issue:** `transition` takes a status name or category. Linear
|
|
188
197
|
sets the state, Jira applies the workflow transition that reaches it, and
|
|
189
198
|
Introspection sets `status`.
|
package/docs/recipe-format.md
CHANGED
|
@@ -177,7 +177,26 @@ value; endpoint compatibility must be verified against the provider.
|
|
|
177
177
|
`session` owns portable Pi session behavior. Queue modes accept `all` or
|
|
178
178
|
`one-at-a-time`; `tool_execution` accepts `parallel` or `sequential`. The
|
|
179
179
|
`retry`, `compaction`, and `images` use the managed runtime's corresponding Pi
|
|
180
|
-
settings with snake_case keys.
|
|
180
|
+
settings with snake_case keys. `compaction` accepts `enabled`,
|
|
181
|
+
`reserve_tokens`, `keep_recent_tokens`, `model_overrides` and `instructions`:
|
|
182
|
+
|
|
183
|
+
```yaml
|
|
184
|
+
session:
|
|
185
|
+
compaction:
|
|
186
|
+
reserve_tokens: 16384
|
|
187
|
+
model_overrides:
|
|
188
|
+
anthropic/claude-sonnet-4-5:
|
|
189
|
+
reserve_tokens: 65536
|
|
190
|
+
instructions: Keep every open decision and the files it touches.
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`model_overrides` is keyed by Pi's exact, case-sensitive
|
|
194
|
+
`<provider>/<model_id>` and sets `reserve_tokens` or `keep_recent_tokens` for
|
|
195
|
+
that model. Each value falls back on its own: the model's override, then the
|
|
196
|
+
block's value, then Pi's default; `enabled` applies to every model.
|
|
197
|
+
`instructions` is a non-empty string passed as the custom instructions of every
|
|
198
|
+
compaction of the session, automatic or manual; a manual compaction's own
|
|
199
|
+
instructions follow it. Each session gets a session-local copy of the
|
|
181
200
|
host's effective settings, including overrides the host applied to the
|
|
182
201
|
settings manager it passes (Pi >=0.99; older Pi exposes only the file-backed
|
|
183
202
|
settings and drops those overrides when it reloads the manager), with the
|
|
@@ -190,6 +209,8 @@ branch summaries, UI, shell, resource loading, persistence, networking,
|
|
|
190
209
|
analytics, telemetry, and model-default settings are
|
|
191
210
|
not portable session policy and remain host-owned or belong under `ai`.
|
|
192
211
|
|
|
212
|
+
`session.cache` is described in [Prompt cache](#prompt-cache).
|
|
213
|
+
|
|
193
214
|
`tools` MUST NOT contain `agent`. The host materializes that session-generated
|
|
194
215
|
tool for a session whose effective `subagents` list is non-empty and whose
|
|
195
216
|
delegation depth allows it (see below).
|
|
@@ -198,6 +219,52 @@ The default agent is named `agent`. If no `agent` exists, a host MAY select the
|
|
|
198
219
|
only declared agent. When multiple agents exist without `agent`, the caller
|
|
199
220
|
MUST select one explicitly.
|
|
200
221
|
|
|
222
|
+
### Prompt cache
|
|
223
|
+
|
|
224
|
+
```yaml
|
|
225
|
+
session:
|
|
226
|
+
cache:
|
|
227
|
+
retention: long
|
|
228
|
+
warming: off
|
|
229
|
+
compaction:
|
|
230
|
+
reserve_tokens: 750000
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`cache.retention` is Pi's `cacheRetention` request option: `none` sends no
|
|
234
|
+
cache markers, `short` asks for the provider's default cache of about five
|
|
235
|
+
minutes, and `long` for about an hour where the model supports it, otherwise
|
|
236
|
+
the default. Omitted, Pi's default applies. A cache serves only a prefix that
|
|
237
|
+
has not changed, so content that changes every turn belongs after the history,
|
|
238
|
+
not in the system prompt; the [Current date](#current-date) rule keeps the
|
|
239
|
+
prompt the same all day for this reason.
|
|
240
|
+
|
|
241
|
+
`ai.options.cache_retention`, and `model.cache_retention` in the older
|
|
242
|
+
`model:` block, are deprecated spellings of `cache.retention`. Each still
|
|
243
|
+
applies and draws a warning. It is read as `session.cache.retention` before
|
|
244
|
+
inheritance, so a parent and a child may use either, and one agent MUST NOT
|
|
245
|
+
declare both.
|
|
246
|
+
|
|
247
|
+
`cache.warming` is Pi's `cacheWarming` setting: `off`, `streaming` or `idle`.
|
|
248
|
+
Pi refreshes the cache before it expires while a run streams (`streaming`) or
|
|
249
|
+
also between runs (`idle`), when a refresh is expected to cost less than the
|
|
250
|
+
rewrite it avoids; idle warming stops 30 minutes after the run's first request,
|
|
251
|
+
so it refreshes a `short` cache and never a `long` one. Each refresh is billed.
|
|
252
|
+
|
|
253
|
+
A large context is bounded by Pi's compaction, which runs at the end of a turn
|
|
254
|
+
or before a request once the context exceeds the model's window less
|
|
255
|
+
`compaction.reserve_tokens`. A Recipe that wants smaller cache rewrites after a
|
|
256
|
+
long pause sets `reserve_tokens` so that compaction starts at the context size
|
|
257
|
+
it is willing to rewrite.
|
|
258
|
+
|
|
259
|
+
| Code | Severity | Rule |
|
|
260
|
+
| --------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|
|
261
|
+
| `agent.session.cache_invalid` | error | `cache` is not an object; `agent.session.cache_key_unknown` reports a key other than `retention` and `warming`. |
|
|
262
|
+
| `agent.session.cache.retention_invalid` | error | `retention` is not `none`, `short` or `long`. |
|
|
263
|
+
| `agent.session.cache.warming_invalid` | error | `warming` is not `off`, `streaming` or `idle`. |
|
|
264
|
+
| `agent.session.cache.retention_conflict` | error | The agent declares `session.cache.retention` and `ai.options.cache_retention` (or `model.cache_retention`). |
|
|
265
|
+
| `agent.ai.options.cache_retention_deprecated` | warning | The agent declares `ai.options.cache_retention`; move it to `session.cache.retention`. |
|
|
266
|
+
| `agent.model.cache_retention_deprecated` | warning | The agent declares `model.cache_retention`; move it to `session.cache.retention`. |
|
|
267
|
+
|
|
201
268
|
## First-party packages
|
|
202
269
|
|
|
203
270
|
Some tools come from packages we publish: **channel tools**
|
|
@@ -309,7 +376,7 @@ See [Productivity tools](productivity/README.md).
|
|
|
309
376
|
|
|
310
377
|
## Judges
|
|
311
378
|
|
|
312
|
-
A Recipe MAY include portable
|
|
379
|
+
A Recipe MAY include portable grading definitions as direct `.yaml` or
|
|
313
380
|
`.yml` children of `judges/`. Nested files are not judge sources. Every judge
|
|
314
381
|
YAML MUST declare a package-unique lowercase kebab-case `name`. As with agent
|
|
315
382
|
definitions, this is the stable authored identity and the filename has no
|
|
@@ -320,8 +387,8 @@ alias and normalize it to `name`. A definition cannot declare both fields.
|
|
|
320
387
|
|
|
321
388
|
The authored schema, defaults, applicability gates, and model configuration are
|
|
322
389
|
defined in [Recipe judges](recipe-judges.md). The Recipe Format owns this
|
|
323
|
-
declarative evaluation contract;
|
|
324
|
-
credentials,
|
|
390
|
+
declarative evaluation contract; [Running judges](judges.md) covers execution,
|
|
391
|
+
and hosts own credentials, persistence, and result processing.
|
|
325
392
|
|
|
326
393
|
## Instructions, skills, prompts, and extensions
|
|
327
394
|
|
|
@@ -521,13 +588,13 @@ Besides Pi's own tools (`read`, `bash`, `edit`, `write`, `grep`, `find`,
|
|
|
521
588
|
`ls`), Recipes provides these built-in tools, available only to an agent that
|
|
522
589
|
lists them in `tools`:
|
|
523
590
|
|
|
524
|
-
| Tool | What it does
|
|
525
|
-
| -------------------- |
|
|
526
|
-
| `ask_user_question` | Asks the user one to four multiple-choice questions and waits for the answers; the user can always type their own answer. Works in Pi's terminal, on pause/resume hosts and headless. See [Interactions](interactions.md#the-built-in-ask_user_question-tool).
|
|
527
|
-
| `show_artifact` | Shows a markdown file the agent wrote (a brief, test cases, a report) in a panel on the right of Pi's terminal, and adds `/recipe view`; Esc closes it. Elsewhere it returns the file's path as text. See [Pi extension](pi-extension.md#artifact-panel).
|
|
528
|
-
| `review_artifacts` | Asks the user to review several markdown files the agent wrote, one decision per file (approve, or request changes saying what to change). In Pi's terminal each file shows in the artifact panel; other hosts render their own review. See [Pi extension](pi-extension.md#reviewing-several-files).
|
|
591
|
+
| Tool | What it does |
|
|
592
|
+
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
593
|
+
| `ask_user_question` | Asks the user one to four multiple-choice questions and waits for the answers; the user can always type their own answer. Works in Pi's terminal, on pause/resume hosts and headless. See [Interactions](interactions.md#the-built-in-ask_user_question-tool). |
|
|
594
|
+
| `show_artifact` | Shows a markdown file the agent wrote (a brief, test cases, a report) in a panel on the right of Pi's terminal, and adds `/recipe view`; Esc closes it. Elsewhere it returns the file's path as text. See [Pi extension](pi-extension.md#artifact-panel). |
|
|
595
|
+
| `review_artifacts` | Asks the user to review several markdown files the agent wrote, one decision per file (approve, or request changes saying what to change). In Pi's terminal each file shows in the artifact panel; other hosts render their own review. See [Pi extension](pi-extension.md#reviewing-several-files). |
|
|
529
596
|
| `introspection_open` | Asks the person to open an Introspection page (install GitHub or Slack, add a connector, connect their own account, set up sign-in, connect a Runtime's MCP server, look at a Runtime, task or Introspection issue) and, with `wait: true`, pauses until they are done. In Pi's terminal it runs the Introspection CLI's loopback; pause/resume hosts render a card. See [Interactions](interactions.md#the-built-in-introspection_open-tool). |
|
|
530
|
-
| `today`
|
|
597
|
+
| `today` | Returns the current date, weekday and time, with the time zone and its UTC offset: the person's, or, with `time_zone`, another zone's. It reads the session's clock (see [Current date](#current-date)). |
|
|
531
598
|
|
|
532
599
|
```yaml
|
|
533
600
|
tools: [read, bash, ask_user_question, show_artifact]
|
|
@@ -638,8 +705,9 @@ The host owns:
|
|
|
638
705
|
|
|
639
706
|
- credentials and secret resolution;
|
|
640
707
|
- workspaces and filesystem isolation;
|
|
641
|
-
- task and process lifecycle;
|
|
642
|
-
- persistence and recovery
|
|
708
|
+
- task and process lifecycle, including when an idle session ends;
|
|
709
|
+
- persistence and recovery, including the cache retention clock, where a
|
|
710
|
+
prepared compaction is stored, and how a session is restored;
|
|
643
711
|
- scheduling and concurrency enforcement;
|
|
644
712
|
- network protocols and user authentication;
|
|
645
713
|
- telemetry export policy;
|