@introspection-ai/recipes 0.56.0 → 0.58.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.
Files changed (204) hide show
  1. package/dist/batch/index.d.ts +2 -0
  2. package/dist/batch/index.d.ts.map +1 -1
  3. package/dist/batch/index.js +2 -1
  4. package/dist/batch/index.js.map +1 -1
  5. package/dist/batch/runner.d.ts +5 -0
  6. package/dist/batch/runner.d.ts.map +1 -1
  7. package/dist/batch/runner.js +6 -0
  8. package/dist/batch/runner.js.map +1 -1
  9. package/dist/batch/shards.d.ts +1 -1
  10. package/dist/batch/shards.d.ts.map +1 -1
  11. package/dist/batch/shards.js +3 -3
  12. package/dist/batch/shards.js.map +1 -1
  13. package/dist/child/agent.d.ts.map +1 -1
  14. package/dist/child/agent.js +6 -5
  15. package/dist/child/agent.js.map +1 -1
  16. package/dist/child/session.d.ts +1 -0
  17. package/dist/child/session.d.ts.map +1 -1
  18. package/dist/child/session.js +9 -6
  19. package/dist/child/session.js.map +1 -1
  20. package/dist/judges/classifier.d.ts +8 -0
  21. package/dist/judges/classifier.d.ts.map +1 -0
  22. package/dist/judges/classifier.js +30 -0
  23. package/dist/judges/classifier.js.map +1 -0
  24. package/dist/judges/cli-main.d.ts +41 -0
  25. package/dist/judges/cli-main.d.ts.map +1 -0
  26. package/dist/judges/cli-main.js +182 -0
  27. package/dist/judges/cli-main.js.map +1 -0
  28. package/dist/judges/cli.d.ts +2 -0
  29. package/dist/judges/cli.d.ts.map +1 -0
  30. package/dist/judges/cli.js +43 -0
  31. package/dist/judges/cli.js.map +1 -0
  32. package/dist/judges/controller.d.ts +78 -0
  33. package/dist/judges/controller.d.ts.map +1 -0
  34. package/dist/judges/controller.js +243 -0
  35. package/dist/judges/controller.js.map +1 -0
  36. package/dist/judges/definition.d.ts +86 -0
  37. package/dist/judges/definition.d.ts.map +1 -0
  38. package/dist/judges/definition.js +100 -0
  39. package/dist/judges/definition.js.map +1 -0
  40. package/dist/judges/gate.d.ts +46 -0
  41. package/dist/judges/gate.d.ts.map +1 -0
  42. package/dist/judges/gate.js +256 -0
  43. package/dist/judges/gate.js.map +1 -0
  44. package/dist/judges/identity.d.ts +21 -0
  45. package/dist/judges/identity.d.ts.map +1 -0
  46. package/dist/judges/identity.js +48 -0
  47. package/dist/judges/identity.js.map +1 -0
  48. package/dist/judges/index.d.ts +10 -0
  49. package/dist/judges/index.d.ts.map +1 -0
  50. package/dist/judges/index.js +10 -0
  51. package/dist/judges/index.js.map +1 -0
  52. package/dist/judges/resolve-hooks.d.ts +10 -0
  53. package/dist/judges/resolve-hooks.d.ts.map +1 -0
  54. package/dist/judges/resolve-hooks.js +25 -0
  55. package/dist/judges/resolve-hooks.js.map +1 -0
  56. package/dist/judges/run.d.ts +123 -0
  57. package/dist/judges/run.d.ts.map +1 -0
  58. package/dist/judges/run.js +319 -0
  59. package/dist/judges/run.js.map +1 -0
  60. package/dist/judges/session.d.ts +9 -0
  61. package/dist/judges/session.d.ts.map +1 -0
  62. package/dist/judges/session.js +109 -0
  63. package/dist/judges/session.js.map +1 -0
  64. package/dist/judges/trajectory.d.ts +91 -0
  65. package/dist/judges/trajectory.d.ts.map +1 -0
  66. package/dist/judges/trajectory.js +223 -0
  67. package/dist/judges/trajectory.js.map +1 -0
  68. package/dist/judges/verdict.d.ts +31 -0
  69. package/dist/judges/verdict.d.ts.map +1 -0
  70. package/dist/judges/verdict.js +121 -0
  71. package/dist/judges/verdict.js.map +1 -0
  72. package/dist/mcp/daemon/server.d.ts +0 -2
  73. package/dist/mcp/daemon/server.d.ts.map +1 -1
  74. package/dist/mcp/daemon/server.js +1 -1
  75. package/dist/mcp/daemon/server.js.map +1 -1
  76. package/dist/mcp-chunks/{auth-command-PZLSOYAT.js → auth-command-WE7QY6RH.js} +27 -27
  77. package/dist/mcp-chunks/call-arguments-2ABANGLE.js +16 -0
  78. package/dist/mcp-chunks/{call-command-VILJIFYG.js → call-command-OOBUGVTM.js} +56 -70
  79. package/dist/mcp-chunks/{chunk-N2U2FODH.js → chunk-2PTK6KBV.js} +4 -4
  80. package/dist/mcp-chunks/{chunk-F2X4Y2TQ.js → chunk-2R2HWX2E.js} +1 -1
  81. package/dist/mcp-chunks/{chunk-ORJND4AI.js → chunk-2R7UGABC.js} +70 -70
  82. package/dist/mcp-chunks/{chunk-US63Y6XE.js → chunk-32UZRZIL.js} +1 -1
  83. package/dist/mcp-chunks/{chunk-THRMUZZD.js → chunk-37VJZIFW.js} +8 -8
  84. package/dist/mcp-chunks/{chunk-5Z6WSV5D.js → chunk-3KSDZBUJ.js} +5 -5
  85. package/dist/mcp-chunks/{chunk-JTPTAO4M.js → chunk-44KI6DPL.js} +24 -15
  86. package/dist/mcp-chunks/{chunk-BHXCAVFP.js → chunk-4ACA5GWL.js} +1 -1
  87. package/dist/mcp-chunks/{chunk-E76ZUBOJ.js → chunk-4NABHXDS.js} +4 -4
  88. package/dist/mcp-chunks/{chunk-AJDK5Z7O.js → chunk-4SO2DY7F.js} +2 -3
  89. package/dist/mcp-chunks/{chunk-I6UFV7RW.js → chunk-5ZQKSEUN.js} +1 -1
  90. package/dist/mcp-chunks/{chunk-KZGUH7E2.js → chunk-73TMUGJL.js} +2039 -1148
  91. package/dist/mcp-chunks/{chunk-UVRJ3AAD.js → chunk-7KOGD2JK.js} +2 -2
  92. package/dist/mcp-chunks/{chunk-KJ5FPQF6.js → chunk-7SQZWTDU.js} +30 -26
  93. package/dist/mcp-chunks/{chunk-MYAMG6VL.js → chunk-ABPXAKP7.js} +89 -28
  94. package/dist/mcp-chunks/{chunk-2YV72LUA.js → chunk-AIUZOMBB.js} +12 -12
  95. package/dist/mcp-chunks/{chunk-V42T3QNK.js → chunk-BI6L3SYV.js} +9 -9
  96. package/dist/mcp-chunks/{chunk-757ZF552.js → chunk-CFRA424Y.js} +4 -4
  97. package/dist/mcp-chunks/{chunk-DU4SDPEV.js → chunk-CIQX62WO.js} +2 -2
  98. package/dist/mcp-chunks/{chunk-MHUMLEBO.js → chunk-CWM4RO33.js} +1 -1
  99. package/dist/mcp-chunks/{chunk-TUPFPO4L.js → chunk-DEYGZRBD.js} +5 -5
  100. package/dist/mcp-chunks/{chunk-3SXP4S2A.js → chunk-DL3GVI4M.js} +2 -2
  101. package/dist/mcp-chunks/{chunk-O7SIXJM6.js → chunk-EUHXZKP2.js} +108 -108
  102. package/dist/mcp-chunks/{chunk-H5PBSJP3.js → chunk-EV3SP7ME.js} +1 -1
  103. package/dist/mcp-chunks/chunk-EVEVCVYR.js +42 -0
  104. package/dist/mcp-chunks/{chunk-RUF27IUF.js → chunk-FDVES4CU.js} +2 -2
  105. package/dist/mcp-chunks/{chunk-L2MSWQDL.js → chunk-FJNWUAGR.js} +1 -1
  106. package/dist/mcp-chunks/{chunk-IWCVZ46B.js → chunk-G5DK4L6M.js} +2 -2
  107. package/dist/mcp-chunks/{chunk-3ETUDW7N.js → chunk-GQM53HF7.js} +1 -1
  108. package/dist/mcp-chunks/{chunk-2AKSS7WR.js → chunk-H44A4G2O.js} +2 -2
  109. package/dist/mcp-chunks/{chunk-WDWSA7RL.js → chunk-HGEKP2E5.js} +4 -4
  110. package/dist/mcp-chunks/{chunk-ELHS763C.js → chunk-HKMH4N3Z.js} +1 -1
  111. package/dist/mcp-chunks/{chunk-GZ53GNFP.js → chunk-HPFIAALB.js} +13 -10
  112. package/dist/mcp-chunks/chunk-KUJUYFDC.js +224 -0
  113. package/dist/mcp-chunks/{chunk-OIK5AH2S.js → chunk-MG6EVYIM.js} +41 -19
  114. package/dist/mcp-chunks/{chunk-QNXOIF5U.js → chunk-MSPGQEWX.js} +12 -12
  115. package/dist/mcp-chunks/{chunk-JEHI2YU4.js → chunk-MW3YO24Q.js} +3 -3
  116. package/dist/mcp-chunks/{chunk-WQL7FJQ3.js → chunk-NJR33E7V.js} +4 -4
  117. package/dist/mcp-chunks/{chunk-7U5NSQ5T.js → chunk-OSK2JGFH.js} +2 -2
  118. package/dist/mcp-chunks/{chunk-ZEA3Y5ZD.js → chunk-QHD5RXW4.js} +7 -7
  119. package/dist/mcp-chunks/{chunk-TC2JPBFB.js → chunk-QYR3UKJS.js} +7 -4
  120. package/dist/mcp-chunks/{chunk-3FRLDHVD.js → chunk-SYBDN4SV.js} +5 -5
  121. package/dist/mcp-chunks/{chunk-3P3KGT4H.js → chunk-TQ5T5VO7.js} +2 -2
  122. package/dist/mcp-chunks/{chunk-OWGTNJNR.js → chunk-TT3LOCMN.js} +2 -2
  123. package/dist/mcp-chunks/{chunk-3LENTPGE.js → chunk-TTVO6RCP.js} +2 -2
  124. package/dist/mcp-chunks/{chunk-IRSL7JRH.js → chunk-UY2QWZB3.js} +53 -49
  125. package/dist/mcp-chunks/{chunk-B6S43WID.js → chunk-VJ45Y5IO.js} +1 -1
  126. package/dist/mcp-chunks/{chunk-IRARVOUM.js → chunk-VJ5VDK6D.js} +1 -1
  127. package/dist/mcp-chunks/{chunk-6O42UGLI.js → chunk-VLJQSE6L.js} +9 -9
  128. package/dist/mcp-chunks/{chunk-HNQSUT44.js → chunk-W47YAN6W.js} +3 -3
  129. package/dist/mcp-chunks/{chunk-66VSGFXA.js → chunk-XU4D5QN2.js} +1 -1
  130. package/dist/mcp-chunks/{chunk-CXST5CVH.js → chunk-Y7JQJ352.js} +22 -18
  131. package/dist/mcp-chunks/{chunk-3HSC6NHZ.js → chunk-Y7UTXETL.js} +1 -1
  132. package/dist/mcp-chunks/{chunk-O3RTM5HD.js → chunk-YFPPHEDE.js} +1 -1
  133. package/dist/mcp-chunks/{chunk-N6YUOYDS.js → chunk-YGT57XUN.js} +2 -2
  134. package/dist/mcp-chunks/{chunk-BUOGKTKK.js → chunk-Z43KJRXY.js} +1 -1
  135. package/dist/mcp-chunks/{chunk-6P3KAQ5N.js → chunk-Z5XOB522.js} +1 -1
  136. package/dist/mcp-chunks/{chunk-63L6SHK3.js → chunk-ZEMVGFKG.js} +2 -2
  137. package/dist/mcp-chunks/{chunk-MEQXX43K.js → chunk-ZJZ53NIB.js} +1 -1
  138. package/dist/mcp-chunks/{cli-UQ5QXFXU.js → cli-TJFAYJO4.js} +81 -283
  139. package/dist/mcp-chunks/client-LDKUW5K5.js +32 -0
  140. package/dist/mcp-chunks/{config-command-ZSPJI34E.js → config-command-YGNK2VVL.js} +29 -29
  141. package/dist/mcp-chunks/daemon-command-UYAYRHVD.js +36 -0
  142. package/dist/mcp-chunks/dist-5JNZD3JV.js +69 -0
  143. package/dist/mcp-chunks/{dist-Q7WSCBBK.js → dist-IFOLXE2R.js} +351 -1305
  144. package/dist/mcp-chunks/{emit-ts-command-SY4LQE4S.js → emit-ts-command-4EVF6CIG.js} +28 -25
  145. package/dist/mcp-chunks/{generate-cli-runner-LQBBQ7F5.js → generate-cli-runner-UFVSXJVK.js} +58 -49
  146. package/dist/mcp-chunks/generated-daemon-runtime-LTH36X2R.js +32 -0
  147. package/dist/mcp-chunks/{inspect-cli-command-JPX4ON6N.js → inspect-cli-command-L3JGLLTG.js} +11 -11
  148. package/dist/mcp-chunks/{launch-UG7IH27P.js → launch-LUKDWKH4.js} +1 -1
  149. package/dist/mcp-chunks/{lifecycle-QBYGUHQ3.js → lifecycle-H57PYAZ5.js} +1 -1
  150. package/dist/mcp-chunks/{list-command-SDITI3ZM.js → list-command-QBO4LK5Q.js} +53 -42
  151. package/dist/mcp-chunks/logger-LvdykevT-BQ5B4N5O.js +995 -0
  152. package/dist/mcp-chunks/{output-utils-YTMZTA7J.js → output-utils-MB3PEV2M.js} +3 -3
  153. package/dist/mcp-chunks/{pi-mcp-runtime-OLO25D7A.js → pi-mcp-runtime-OIMIJV5A.js} +73 -17
  154. package/dist/mcp-chunks/{prompt-DkftHXS7-N7UENQ4C.js → prompt-DkftHXS7-TE2LNPAM.js} +1 -1
  155. package/dist/mcp-chunks/{record-command-JGTMATYI.js → record-command-RYDP3Y2A.js} +5 -5
  156. package/dist/mcp-chunks/{replay-command-S2VAC4RW.js → replay-command-QDJCQ5JU.js} +6 -6
  157. package/dist/mcp-chunks/{resource-command-SRFQQROJ.js → resource-command-RKHHQBFP.js} +9 -9
  158. package/dist/mcp-chunks/{result-utils-JASGNHXK.js → result-utils-ZD5GFX7P.js} +3 -3
  159. package/dist/mcp-chunks/runtime-F7PP4V25.js +39 -0
  160. package/dist/mcp-chunks/{runtime-wrapper-7HYO3NM5.js → runtime-wrapper-AV4JCNRF.js} +3 -3
  161. package/dist/mcp-chunks/{serve-command-YKSIXG7K.js → serve-command-MRPTK4XX.js} +26 -26
  162. package/dist/mcp-chunks/server-2WSYXDII.js +43 -0
  163. package/dist/mcp-chunks/{timeouts-BJWDJEMH.js → timeouts-2SQIDYBE.js} +4 -3
  164. package/dist/mcp-chunks/{vault-command-EYOIFWEY.js → vault-command-6JVDCFWU.js} +5 -5
  165. package/dist/mcp-chunks/{webapi-WMMA3OEC.js → webapi-CI4O7AUX.js} +1 -1
  166. package/dist/mcp-daemon.js +35 -31
  167. package/dist/mcp-run-worker.js +34 -30
  168. package/dist/model-binding.d.ts +44 -3
  169. package/dist/model-binding.d.ts.map +1 -1
  170. package/dist/model-binding.js +195 -4
  171. package/dist/model-binding.js.map +1 -1
  172. package/dist/recipe/manifest.generated.d.ts +2 -2
  173. package/dist/recipe/manifest.generated.d.ts.map +1 -1
  174. package/dist/recipe/manifest.generated.js +2 -2
  175. package/dist/recipe/manifest.generated.js.map +1 -1
  176. package/dist/recipe/model.d.ts +7 -12
  177. package/dist/recipe/model.d.ts.map +1 -1
  178. package/dist/recipe/model.js +197 -249
  179. package/dist/recipe/model.js.map +1 -1
  180. package/dist/session.d.ts +11 -0
  181. package/dist/session.d.ts.map +1 -1
  182. package/dist/session.js +59 -6
  183. package/dist/session.js.map +1 -1
  184. package/dist/suggestion-picker.d.ts +2 -2
  185. package/dist/suggestion-picker.d.ts.map +1 -1
  186. package/dist/suggestion-picker.js +5 -3
  187. package/dist/suggestion-picker.js.map +1 -1
  188. package/docs/README.md +1 -0
  189. package/docs/batch.md +2 -2
  190. package/docs/judges.md +269 -0
  191. package/docs/recipe-format.md +23 -12
  192. package/docs/recipe-judges.md +119 -59
  193. package/package.json +20 -16
  194. package/skills/documents/SKILL.md +6 -2
  195. package/skills/issues/SKILL.md +2 -1
  196. package/skills/search/SKILL.md +3 -0
  197. package/skills/signature/SKILL.md +4 -4
  198. package/dist/mcp-chunks/call-arguments-GCXZA4HC.js +0 -16
  199. package/dist/mcp-chunks/client-SBELHRAE.js +0 -32
  200. package/dist/mcp-chunks/daemon-command-MQS6AP2W.js +0 -32
  201. package/dist/mcp-chunks/dist-SDPPH7XQ.js +0 -65
  202. package/dist/mcp-chunks/generated-daemon-runtime-TUCZ3JEP.js +0 -32
  203. package/dist/mcp-chunks/runtime-5SOGEUTQ.js +0 -39
  204. package/dist/mcp-chunks/server-HQBFWAJR.js +0 -41
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.
@@ -132,6 +132,17 @@ All remaining agent fields are optional. Omitted `tools`, `skills`, and
132
132
  provider or session default. Omitted agent instructions preserve `SYSTEM.md`
133
133
  when present, or Pi's normal base prompt otherwise.
134
134
 
135
+ `ai.fallbacks` MAY list, in order, other `<provider>/<model_id>` models. They
136
+ apply when the agent runs as a subagent in a local Pi, never on a hosted
137
+ runtime or when the host passes its own credentials. The agent starts on its
138
+ `ai.model` when Pi has a credential for it, otherwise on the first fallback
139
+ that has one. When a request fails and Pi retries it (a rate limit, an
140
+ overloaded or failing provider, a timeout such as `ai.options.timeout_ms`),
141
+ the retry goes to the next model, and the agent stays on the model that last
142
+ answered. A model named under `openai` also runs as the same model under
143
+ `openai-codex` when Pi is logged in to ChatGPT and has no OpenAI key, whether
144
+ it is the `ai.model` or a fallback; that alias also applies only to subagents.
145
+
135
146
  `phases` MAY list, in order, the phases the agent moves through, each the
136
147
  prefix of its step skills (`build` for `build-draft`). It changes only what
137
148
  Pi's footer shows: the phase of the step skill last read, with the agent's
@@ -298,7 +309,7 @@ See [Productivity tools](productivity/README.md).
298
309
 
299
310
  ## Judges
300
311
 
301
- A Recipe MAY include portable LLM grading definitions as direct `.yaml` or
312
+ A Recipe MAY include portable grading definitions as direct `.yaml` or
302
313
  `.yml` children of `judges/`. Nested files are not judge sources. Every judge
303
314
  YAML MUST declare a package-unique lowercase kebab-case `name`. As with agent
304
315
  definitions, this is the stable authored identity and the filename has no
@@ -309,8 +320,8 @@ alias and normalize it to `name`. A definition cannot declare both fields.
309
320
 
310
321
  The authored schema, defaults, applicability gates, and model configuration are
311
322
  defined in [Recipe judges](recipe-judges.md). The Recipe Format owns this
312
- declarative evaluation contract; hosts own transcript assembly, execution,
313
- credentials, retries, persistence, and result processing.
323
+ declarative evaluation contract; [Running judges](judges.md) covers execution,
324
+ and hosts own credentials, persistence, and result processing.
314
325
 
315
326
  ## Instructions, skills, prompts, and extensions
316
327
 
@@ -373,13 +384,13 @@ agent a session runs; when that agent offers none, it shows its own defaults.
373
384
 
374
385
  - **In Pi.** A new session in the terminal (`pi --recipe <dir>`, or
375
386
  `introspection local`) with no messages asks once, "What would you like to
376
- do?", with up to three templates the session's agent offers (a random
377
- three, in file order, when it offers more) and a row to type your own
387
+ do?", with up to four templates the session's agent offers (a random
388
+ four, in file order, when it offers more) and a row to type your own
378
389
  request. When it offers none, it does not ask. Picking one sends it as the first message;
379
390
  a template whose `argument-hint` has a required `<argument>` is put in the
380
391
  editor instead, for you to finish. Typing sends what you typed, and Esc
381
392
  leaves the empty prompt. Set `PI_RECIPES_SUGGESTIONS_SEED` to pin which
382
- three show. The picker never appears on resume, outside the terminal UI,
393
+ four show. The picker never appears on resume, outside the terminal UI,
383
394
  or when Pi starts with a message.
384
395
  - **Starting with one.** Pi expands a template given as the initial message,
385
396
  so `pi --recipe <dir> "/redline nda.docx"` (or
@@ -510,13 +521,13 @@ Besides Pi's own tools (`read`, `bash`, `edit`, `write`, `grep`, `find`,
510
521
  `ls`), Recipes provides these built-in tools, available only to an agent that
511
522
  lists them in `tools`:
512
523
 
513
- | Tool | What it does |
514
- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
515
- | `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). |
516
- | `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). |
517
- | `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). |
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). |
518
529
  | `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). |
519
- | `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)). |
530
+ | `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)). |
520
531
 
521
532
  ```yaml
522
533
  tools: [read, bash, ask_user_question, show_artifact]
@@ -1,6 +1,6 @@
1
1
  # Recipe judge definitions
2
2
 
3
- Recipe judges are optional, recipe-owned LLM grading definitions. Author them
3
+ Recipe judges are optional, recipe-owned grading definitions. Author them
4
4
  as direct children of `judges/` using a lowercase `.yaml` or `.yml` extension:
5
5
 
6
6
  ```text
@@ -18,19 +18,20 @@ sources have no judge diagnostics.
18
18
  The validator behind `introspection check` owns the portable authored YAML
19
19
  specification and its static, file-oriented diagnostics.
20
20
 
21
- Evaluation systems own execution: applicability checks, conversation assembly,
22
- transcript protection, model requests, retries, verdict normalization, and
23
- evaluation identity. Implementations should consume or remain explicitly
24
- compatible with the authored specification defined here. New authored fields
25
- must land in this checker and its contract tests rather than appearing in only
26
- one evaluator.
21
+ `@introspection-ai/recipes/judges` owns execution: applicability checks,
22
+ transcript assembly and protection, model requests, verdict normalization and
23
+ evaluation identity. See [Running judges](judges.md). New authored fields must
24
+ land in the checker and its contract tests as well as in the runner.
27
25
 
28
26
  Validation reports do not contain normalized judge definitions or
29
27
  host-specific registry data.
30
28
 
31
29
  ## Definition shape
32
30
 
33
- The minimal definition is:
31
+ A judge is answered either by a chat model reading `instructions`, or by a
32
+ classifier answering yes-or-no `questions`. It declares exactly one of the two.
33
+
34
+ The minimal LLM judge is:
34
35
 
35
36
  ```yaml
36
37
  name: helpful
@@ -38,19 +39,18 @@ name: helpful
38
39
  instructions: |
39
40
  Determine whether the assistant answered the user correctly.
40
41
 
41
- llm:
42
- model: gpt-5
42
+ ai:
43
+ model: anthropic/claude-sonnet-5-5
43
44
  ```
44
45
 
45
- `name`, `instructions`, and `llm.model` are required and non-empty. Names use
46
- lowercase kebab-case and must be unique across all judge files in one Recipe.
47
- As with `agents/*.yaml`, the filename has no semantic meaning. Evaluators default
48
- `llm.provider` to `openai`.
46
+ `name`, `ai.model` and one of `instructions` and `questions` are required.
47
+ Names use lowercase kebab-case and must be unique across all judge files in one
48
+ Recipe. As with `agents/*.yaml`, the filename has no semantic meaning.
49
49
 
50
50
  Legacy definitions using `judge:` remain accepted as a deprecated input alias.
51
51
  Parsers normalize that field to `name`; a definition cannot declare both.
52
52
 
53
- The canonical expanded definition is:
53
+ The expanded definition is:
54
54
 
55
55
  ```yaml
56
56
  name: helpful
@@ -64,24 +64,95 @@ on:
64
64
  instructions: |
65
65
  Determine whether the assistant answered the user correctly.
66
66
 
67
+ ai:
68
+ model: anthropic/claude-sonnet-5-5
69
+ fallbacks:
70
+ - openai/gpt-6-luna
71
+ thinking_level: low
72
+ options:
73
+ temperature: 0
74
+ ```
75
+
76
+ Unknown fields are errors at every level.
77
+
78
+ ### The older `llm:` block
79
+
80
+ A judge declares its model under `ai:`. The `llm:` block that earlier versions
81
+ read is still accepted in its place, but never beside it: a judge with both, or
82
+ with neither, reports `judge.kind_invalid`. Every reader of the judge
83
+ (the checker, the runner and the hosted platform) sees the `ai:` block it maps
84
+ to:
85
+
86
+ | `llm:` | `ai:` |
87
+ | -------------------------- | ------------------------------------------------------------ |
88
+ | `provider` and `model` | `model: <provider>/<model>`; `provider` defaults to `openai` |
89
+ | `request.max_tokens` | `options.max_tokens` |
90
+ | `request.temperature` | `options.temperature`, unless it is 0 (the model's default) |
91
+ | `request.reasoning_effort` | `thinking_level`; `none` is `off` |
92
+ | `transport` | dropped: the host owns timeouts and retries |
93
+ | `local` | dropped with the warning `judge.llm.local_ignored` |
94
+
95
+ `ai:` cannot name a local endpoint, so a judge that declared `llm.local` runs on
96
+ its provider's hosted model. A `reasoning_effort` that names no thinking level
97
+ is an error.
98
+
99
+ ```yaml
100
+ # Read as ai: { model: anthropic/claude-sonnet-5-5, thinking_level: low }
67
101
  llm:
68
- provider: openai
69
- model: gpt-5
102
+ provider: anthropic
103
+ model: claude-sonnet-5-5
70
104
  request:
71
- temperature: 0
72
- max_tokens: 1024
73
- reasoning_effort: medium
74
- transport:
75
- timeout_ms: 60000
76
- max_retries: 2
77
- max_retry_delay_ms: 5000
78
- local:
79
- base_url: https://api.openai.com/v1
80
- api_key_env: OPENAI_API_KEY
105
+ reasoning_effort: low
106
+ ```
107
+
108
+ ### Model settings
109
+
110
+ `ai:` is the block an agent declares, with the same keys and the same rules:
111
+ `model`, `fallbacks`, `thinking_level`, `options` and `providers`. See
112
+ [Agents](recipe-format.md#agents). A judge has no `session:` block; the host's
113
+ retry settings apply.
114
+
115
+ An LLM judge returns `pass`, `fail` or `not_applicable` with a short reason.
116
+ That contract is the runner's and cannot be authored.
117
+
118
+ ### Classifier judges
119
+
120
+ A classifier judge asks a decision model yes-or-no questions and reads a
121
+ probability for each:
122
+
123
+ ```yaml
124
+ name: polite
125
+
126
+ ai:
127
+ model: typesafe/jev-latest
128
+ fallbacks:
129
+ - openai/gpt-6-luna
130
+
131
+ questions:
132
+ greeted:
133
+ instructions: Did the assistant greet the user?
134
+ criteria:
135
+ "true": The first reply opens with a greeting.
136
+ "false": It does not.
137
+ threshold: 0.8
138
+ apologised:
139
+ instructions: Did the assistant apologise for the delay?
140
+ criteria:
141
+ "true": It says sorry for the wait.
142
+ "false": It does not mention the wait.
81
143
  ```
82
144
 
83
- Unknown fields are errors at every level. The obsolete top-level `model:`
84
- block is rejected.
145
+ - `questions` maps between one and eight lowercase snake_case names to
146
+ questions.
147
+ - `instructions` is non-empty text, and `criteria` describes both `true` and
148
+ `false`.
149
+ - `threshold` is the probability of yes, above 0 and at most 1, that the
150
+ question must reach. It defaults to 0.5.
151
+ - The judge is `pass` when every question reaches its own threshold, and `fail`
152
+ otherwise. A classifier cannot abstain: `not_applicable` comes only from
153
+ `on`.
154
+ - `ai.model` names a classifier model. `thinking_level` and `options` do not
155
+ apply to one.
85
156
 
86
157
  ## Judge types
87
158
 
@@ -123,33 +194,8 @@ questions:
123
194
  describes both `true` and `false` in non-empty text.
124
195
  - `attributes` lists the request attributes the judge sees, and is empty to show
125
196
  them all.
126
- - `on` and `llm` belong to `online` judges and are rejected on a mission
127
- judge; `questions` and `attributes` are rejected on online judges.
128
-
129
- ### LLM settings
130
-
131
- - `provider` is a 1-64 byte lowercase slug containing ASCII letters, digits,
132
- and hyphens. The portable checker does not restrict it to managed platform
133
- providers because custom slugs can be used with an explicit local endpoint.
134
- - `model` is a trimmed, non-empty string of at most 255 bytes.
135
- - `request.temperature` is a finite number from 0 through 2 and defaults to 0.
136
- - `request.max_tokens` is an integer from 1 through 131072 when present;
137
- explicit `null` is treated as omitted.
138
- - `request.reasoning_effort` is a 1-64 byte lowercase slug containing ASCII
139
- letters and hyphens; explicit `null` is treated as omitted.
140
- - `transport.timeout_ms` is an integer from 1 through 600000 and defaults to
141
- 60000.
142
- - `transport.max_retries` is an integer from 0 through 10 and defaults to 0.
143
- - `transport.max_retry_delay_ms` is an integer from 0 through 60000 and
144
- defaults to 5000.
145
- - `local` requires both `base_url` and `api_key_env`. The URL must be HTTP(S),
146
- have a host, contain no embedded credentials, query, or fragment, and use
147
- HTTPS unless it targets `localhost`, `127.0.0.1`, or `::1`. `api_key_env` is
148
- an environment-variable name, not a credential value.
149
-
150
- Transport and local settings affect execution but not authored grading
151
- identity. The evaluator remains responsible for applying defaults, building
152
- requests, and routing execution.
197
+ - `on` and `ai` belong to `online` judges and are rejected on a mission
198
+ judge; `attributes` is rejected on online judges.
153
199
 
154
200
  ## Applicability
155
201
 
@@ -173,10 +219,24 @@ on:
173
219
  sentiment: negative
174
220
  ```
175
221
 
176
- Match keys are non-empty field paths. Regex literals use Rust regex syntax and
177
- support unique `i`, `m`, `s`, and `u` flags. `environment`, `runtime_group`, and
222
+ Match keys are non-empty field paths. Regex literals support unique `i`, `m`,
223
+ `s`, and `u` flags. A pattern must compile both as a Rust regex, which the
224
+ hosted platform evaluates, and as a JavaScript `RegExp`, which the runner
225
+ evaluates. The runner compiles a pattern with the `v` flag and, when that
226
+ refuses it, with the `u` flag, so `[\w-]+` (which only `u` compiles) and
227
+ `[\w--\d]+` (which only `v` compiles) are both valid. The checker reports
228
+ `judge.on.regex_invalid` for a pattern either engine refuses, such as a
229
+ lookahead (`(?=…)`, which Rust refuses) or a Rust named group (`(?P<name>…)`,
230
+ which JavaScript refuses under both flags). `environment`, `runtime_group`, and
178
231
  paths ending in `pattern_id` are platform-owned and cannot appear as authored
179
- match fields. The evaluator owns dotted-path traversal and gate evaluation.
232
+ match fields. The runner owns dotted-path traversal and gate evaluation.
233
+
234
+ The checker compiles the JavaScript side with a Rust implementation of the
235
+ `RegExp` grammar, not with the runner's own engine, and the two differ at the
236
+ edges: the checker accepts `\Afoo\z`, `\-` and `\#`, which the runner refuses,
237
+ and `[[:alpha:]]` is a POSIX class to Rust and a nested class to JavaScript. A
238
+ pattern the checker accepts can therefore still be refused by the runner at
239
+ run time, where it records an error for that judgement.
180
240
 
181
241
  ## Diagnostics
182
242