@parcha/agentrun-serve 0.1.0-beta.44 → 0.1.0-beta.45

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 (346) hide show
  1. package/CHANGELOG.md +131 -5
  2. package/README.md +371 -300
  3. package/dist/acp-package.d.ts +28 -0
  4. package/dist/acp-package.js +23 -0
  5. package/dist/adapter-facts.d.ts +8 -1
  6. package/dist/adapter-facts.js +9 -1
  7. package/dist/adapters.d.ts +5 -0
  8. package/dist/adapters.js +36 -3
  9. package/dist/agent-delete.d.ts +50 -0
  10. package/dist/agent-delete.js +125 -0
  11. package/dist/agents-store.d.ts +9 -3
  12. package/dist/agents-store.js +22 -8
  13. package/dist/agents.d.ts +5 -1
  14. package/dist/agents.js +8 -4
  15. package/dist/api-only.d.ts +8 -3
  16. package/dist/api-only.js +10 -4
  17. package/dist/archil-routes.d.ts +5 -1
  18. package/dist/archil-routes.js +57 -2
  19. package/dist/browser-wait-ended.d.ts +2 -0
  20. package/dist/browser-wait-ended.js +2 -0
  21. package/dist/calendar/ics-faux.d.ts +3 -1
  22. package/dist/calendar/ics-faux.js +12 -2
  23. package/dist/calendar/tools.js +5 -2
  24. package/dist/chatgpt-plan.js +3 -1
  25. package/dist/claude-login.d.ts +135 -0
  26. package/dist/claude-login.js +244 -0
  27. package/dist/cli.js +52 -16
  28. package/dist/composio-preset.js +69 -7
  29. package/dist/composio-triggers.d.ts +14 -0
  30. package/dist/composio-triggers.js +79 -15
  31. package/dist/computer-attach.d.ts +40 -5
  32. package/dist/computer-attach.js +130 -15
  33. package/dist/computer-keys.d.ts +3 -0
  34. package/dist/computer-keys.js +7 -1
  35. package/dist/computer-live.js +3 -2
  36. package/dist/computers.d.ts +21 -10
  37. package/dist/computers.js +39 -28
  38. package/dist/console/assets/index-3O2Yl6hZ.js +701 -0
  39. package/dist/console/assets/index-DaFsZuzQ.css +1 -0
  40. package/dist/console/index.html +2 -2
  41. package/dist/decisions.d.ts +1 -1
  42. package/dist/dial-relay.d.ts +29 -0
  43. package/dist/dial-relay.js +94 -0
  44. package/dist/email/tools.js +10 -5
  45. package/dist/env-proxy.d.ts +2 -0
  46. package/dist/env-proxy.js +35 -0
  47. package/dist/errors.d.ts +3 -1
  48. package/dist/errors.js +7 -4
  49. package/dist/faux-computers.d.ts +8 -2
  50. package/dist/faux-computers.js +83 -6
  51. package/dist/harness-archive.d.ts +67 -0
  52. package/dist/harness-archive.js +177 -0
  53. package/dist/harness-goose.d.ts +34 -0
  54. package/dist/harness-goose.js +87 -0
  55. package/dist/harness-install.d.ts +21 -0
  56. package/dist/harness-install.js +24 -11
  57. package/dist/harness-opencode/adapter.js +1 -1
  58. package/dist/harness-table.d.ts +9 -1
  59. package/dist/harness-table.js +20 -3
  60. package/dist/harness.d.ts +1 -2
  61. package/dist/harness.js +3 -4
  62. package/dist/host.js +2 -1
  63. package/dist/key-check.js +3 -0
  64. package/dist/learn/audit.d.ts +6 -6
  65. package/dist/learn/audit.js +3 -7
  66. package/dist/learn/check.d.ts +23 -89
  67. package/dist/learn/check.js +57 -335
  68. package/dist/learn/commit.d.ts +63 -90
  69. package/dist/learn/commit.js +124 -316
  70. package/dist/learn/compile.d.ts +53 -50
  71. package/dist/learn/compile.js +87 -102
  72. package/dist/learn/corrections.d.ts +13 -0
  73. package/dist/learn/corrections.js +23 -0
  74. package/dist/learn/delete.d.ts +5 -5
  75. package/dist/learn/delete.js +8 -10
  76. package/dist/learn/folder.d.ts +35 -47
  77. package/dist/learn/folder.js +118 -134
  78. package/dist/learn/index.d.ts +3 -5
  79. package/dist/learn/index.js +6 -9
  80. package/dist/learn/learning.sh +45 -15
  81. package/dist/learn/promote.d.ts +13 -1
  82. package/dist/learn/promote.js +9 -0
  83. package/dist/learn/{skills.d.ts → workflow-draft.d.ts} +30 -38
  84. package/dist/learn/{skills.js → workflow-draft.js} +48 -58
  85. package/dist/learn/workflow-nodes.js +1 -1
  86. package/dist/learned-workflow.js +2 -2
  87. package/dist/learning-cost.d.ts +38 -24
  88. package/dist/learning-cost.js +41 -24
  89. package/dist/learning-routes.d.ts +91 -170
  90. package/dist/learning-routes.js +183 -421
  91. package/dist/learning-run.d.ts +19 -40
  92. package/dist/learning-run.js +23 -93
  93. package/dist/learning-setting.d.ts +4 -4
  94. package/dist/learning-setting.js +6 -6
  95. package/dist/learning-words.d.ts +28 -74
  96. package/dist/learning-words.js +64 -162
  97. package/dist/learning.d.ts +61 -392
  98. package/dist/learning.js +101 -651
  99. package/dist/live-reach.d.ts +25 -2
  100. package/dist/live-reach.js +46 -4
  101. package/dist/llms.txt +1 -1
  102. package/dist/local-models.d.ts +3 -11
  103. package/dist/local-models.js +5 -6
  104. package/dist/mcp-servers-store.d.ts +4 -4
  105. package/dist/model-form.js +6 -5
  106. package/dist/model.d.ts +4 -0
  107. package/dist/model.js +26 -9
  108. package/dist/native/binding.js +1 -1
  109. package/dist/native/connection.js +1 -1
  110. package/dist/native/discovery.js +1 -1
  111. package/dist/native/instructions.d.ts +3 -0
  112. package/dist/native/instructions.js +5 -3
  113. package/dist/native/remote-worker-bridge.js +9 -43
  114. package/dist/native/remote.d.ts +8 -15
  115. package/dist/native/remote.js +3 -3
  116. package/dist/native/schema.js +1 -1
  117. package/dist/native/types.d.ts +2 -2
  118. package/dist/openapi.js +268 -316
  119. package/dist/paid-calls.d.ts +8 -0
  120. package/dist/paid-calls.js +20 -0
  121. package/dist/particle-provider.d.ts +11 -0
  122. package/dist/particle-provider.js +135 -0
  123. package/dist/port-models.d.ts +12 -4
  124. package/dist/port-models.js +28 -11
  125. package/dist/print.d.ts +27 -0
  126. package/dist/print.js +21 -0
  127. package/dist/provider.d.ts +7 -0
  128. package/dist/provider.js +15 -1
  129. package/dist/reflect-range.js +2 -3
  130. package/dist/run-launch.d.ts +14 -28
  131. package/dist/run-launch.js +9 -12
  132. package/dist/run-learning-served.d.ts +15 -89
  133. package/dist/run-listing.d.ts +34 -0
  134. package/dist/run-listing.js +128 -0
  135. package/dist/run-model-key.js +1 -1
  136. package/dist/run-timeline-served.js +5 -3
  137. package/dist/run-trace.d.ts +97 -0
  138. package/dist/run-trace.js +253 -0
  139. package/dist/run-view.d.ts +15 -0
  140. package/dist/run-view.js +9 -0
  141. package/dist/runnable.js +2 -1
  142. package/dist/runner/adapter-loop.d.ts +8 -6
  143. package/dist/runner/adapter-loop.js +16 -12
  144. package/dist/runner/adapter-run-spec.d.ts +16 -4
  145. package/dist/runner/adapter-run-spec.js +64 -58
  146. package/dist/runner/adapters/index.js +22 -0
  147. package/dist/runner/adapters/pi.d.ts +4 -12
  148. package/dist/runner/adapters/pi.js +2 -2
  149. package/dist/runner/audit.d.ts +1 -1
  150. package/dist/runner/audit.js +16 -8
  151. package/dist/runner/beside.d.ts +6 -2
  152. package/dist/runner/beside.js +38 -9
  153. package/dist/runner/claim-secrets.d.ts +18 -2
  154. package/dist/runner/claim-secrets.js +42 -18
  155. package/dist/runner/cli-run-spec.js +55 -51
  156. package/dist/runner/conformance/harness.d.ts +6 -0
  157. package/dist/runner/conformance/harness.js +16 -5
  158. package/dist/runner/dispatch.d.ts +2 -2
  159. package/dist/runner/end-of-run.d.ts +6 -14
  160. package/dist/runner/end-of-run.js +8 -33
  161. package/dist/runner/feedback-round.d.ts +2 -2
  162. package/dist/runner/feedback-round.js +7 -7
  163. package/dist/runner/github-app.js +3 -1
  164. package/dist/runner/harness-loops.d.ts +0 -8
  165. package/dist/runner/harness-loops.js +11 -59
  166. package/dist/runner/held.d.ts +170 -0
  167. package/dist/runner/held.js +57 -0
  168. package/dist/runner/journal-kinds.d.ts +2 -3
  169. package/dist/runner/journal-kinds.js +2 -3
  170. package/dist/runner/learned-first.d.ts +40 -0
  171. package/dist/runner/learned-first.js +32 -0
  172. package/dist/runner/learning-end.d.ts +77 -69
  173. package/dist/runner/learning-end.js +250 -303
  174. package/dist/runner/learning-seed.d.ts +15 -33
  175. package/dist/runner/learning-seed.js +24 -45
  176. package/dist/runner/loop-contract.d.ts +2 -3
  177. package/dist/runner/main.d.ts +17 -9
  178. package/dist/runner/main.js +63 -20
  179. package/dist/runner/mcp-run.d.ts +11 -0
  180. package/dist/runner/mcp-run.js +67 -0
  181. package/dist/runner/memory-claim.d.ts +10 -5
  182. package/dist/runner/memory-claim.js +12 -6
  183. package/dist/runner/model-route.d.ts +7 -4
  184. package/dist/runner/model-route.js +22 -10
  185. package/dist/runner/native-loop.d.ts +0 -7
  186. package/dist/runner/native-loop.js +9 -101
  187. package/dist/runner/promotion.d.ts +8 -6
  188. package/dist/runner/promotion.js +19 -12
  189. package/dist/runner/reflect-hook.d.ts +64 -95
  190. package/dist/runner/reflect-hook.js +112 -225
  191. package/dist/runner/run-channel.d.ts +43 -0
  192. package/dist/runner/run-channel.js +467 -0
  193. package/dist/runner/run-child-host.d.ts +169 -0
  194. package/dist/runner/run-child-host.js +1222 -0
  195. package/dist/runner/run-child.d.ts +1 -0
  196. package/dist/runner/run-child.js +254 -0
  197. package/dist/runner/run-errors.d.ts +2 -0
  198. package/dist/runner/run-errors.js +20 -0
  199. package/dist/runner/runner.js +1 -5
  200. package/dist/runner/sdk-ask.d.ts +78 -0
  201. package/dist/runner/sdk-ask.js +158 -0
  202. package/dist/runner/sdk-loop.d.ts +2 -4
  203. package/dist/runner/sdk-loop.js +29 -49
  204. package/dist/runner/store-secrets.d.ts +5 -3
  205. package/dist/runner/store-secrets.js +5 -1
  206. package/dist/runner/workflow-first.d.ts +5 -0
  207. package/dist/runner/workflow-first.js +4 -0
  208. package/dist/runner/workflow-spec.js +7 -2
  209. package/dist/runs-over-store.d.ts +16 -28
  210. package/dist/runs-over-store.js +31 -38
  211. package/dist/sdk/runs.d.ts +6 -11
  212. package/dist/sdk/runs.js +20 -41
  213. package/dist/sdk/schema.js +3 -4
  214. package/dist/seal-key.d.ts +5 -0
  215. package/dist/seal-key.js +7 -0
  216. package/dist/secrets.d.ts +3 -0
  217. package/dist/secrets.js +16 -3
  218. package/dist/server.d.ts +55 -33
  219. package/dist/server.js +685 -320
  220. package/dist/sign-ins-store.d.ts +8 -0
  221. package/dist/sign-ins-store.js +36 -1
  222. package/dist/skills.js +1 -1
  223. package/dist/store/index.d.ts +2 -2
  224. package/dist/store/index.js +1 -1
  225. package/dist/store/journal/storage.js +3 -0
  226. package/dist/store/postgres/migrations/0017_run_listing.sql +83 -0
  227. package/dist/store/postgres/migrations/0018_trigger_template.sql +6 -0
  228. package/dist/store/postgres/migrations/0019_runner_relays.sql +28 -0
  229. package/dist/store/schema.d.ts +53 -4
  230. package/dist/store/schema.js +137 -6
  231. package/dist/store/sqlite/connection.d.ts +2 -0
  232. package/dist/store/sqlite/connection.js +3 -1
  233. package/dist/store/sqlite/run-patch.d.ts +0 -17
  234. package/dist/store/sqlite/run-patch.js +4 -33
  235. package/dist/store/sqlite/store.js +246 -63
  236. package/dist/store/sqlite/worker.js +25 -0
  237. package/dist/store/store.d.ts +193 -36
  238. package/dist/store/store.js +25 -3
  239. package/dist/store-reads/learning.d.ts +102 -204
  240. package/dist/store-reads/learning.js +159 -321
  241. package/dist/store-reads/loop.d.ts +0 -1
  242. package/dist/store-reads/loop.js +1 -1
  243. package/dist/store-view.d.ts +29 -1
  244. package/dist/store-view.js +97 -31
  245. package/dist/template-eval.d.ts +3 -6
  246. package/dist/template-eval.js +22 -36
  247. package/dist/templates.d.ts +2 -1
  248. package/dist/templates.js +6 -3
  249. package/dist/timeline/index.d.ts +1 -1
  250. package/dist/timeline/index.js +1 -1
  251. package/dist/timeline/timeline.d.ts +5 -1
  252. package/dist/timeline/timeline.js +16 -0
  253. package/dist/tool-gate.d.ts +0 -7
  254. package/dist/tool-gate.js +1 -15
  255. package/dist/tool-keys-store.d.ts +1 -1
  256. package/dist/tool-keys.d.ts +6 -4
  257. package/dist/tool-keys.js +12 -6
  258. package/dist/tools.d.ts +2 -2
  259. package/dist/tools.js +11 -4
  260. package/dist/triggers.d.ts +60 -5
  261. package/dist/triggers.js +123 -18
  262. package/dist/validate.js +1 -1
  263. package/dist/webhooks.d.ts +4 -1
  264. package/dist/webhooks.js +11 -4
  265. package/dist/workspace/agent-computer.d.ts +2 -0
  266. package/dist/workspace/agent-computer.js +2 -0
  267. package/dist/workspace/archil-claim.d.ts +7 -0
  268. package/dist/workspace/archil-claim.js +29 -0
  269. package/dist/workspace/archil.d.ts +9 -1
  270. package/dist/workspace/archil.js +165 -3
  271. package/dist/workspace/attach.d.ts +3 -1
  272. package/dist/workspace/attach.js +2 -0
  273. package/dist/workspace/attached-computers.d.ts +16 -5
  274. package/dist/workspace/attached-computers.js +25 -9
  275. package/dist/workspace/computer-deps.js +1 -1
  276. package/dist/workspace/computer-for-claim.d.ts +7 -3
  277. package/dist/workspace/computer-for-claim.js +119 -22
  278. package/dist/workspace/computer-hold.js +2 -1
  279. package/dist/workspace/computer-kept.d.ts +11 -1
  280. package/dist/workspace/computer-kept.js +24 -3
  281. package/dist/workspace/resolve-computer.d.ts +33 -19
  282. package/dist/workspace/resolve-computer.js +172 -64
  283. package/dist/workspace/revision-skills.d.ts +1 -2
  284. package/dist/workspace/revision-skills.js +3 -4
  285. package/dist/workspace/run-workspace.d.ts +1 -1
  286. package/dist/workspace/run-workspace.js +5 -0
  287. package/dist/workspace/synced-folder.d.ts +85 -0
  288. package/dist/workspace/synced-folder.js +230 -0
  289. package/dist/workspace/workspace.d.ts +4 -0
  290. package/launcher/agentrun-serve +1 -1
  291. package/package.json +10 -10
  292. package/templates/README.md +7 -7
  293. package/templates/inbound-lead/agent.md +3 -3
  294. package/templates/inbound-lead/evals/learned-correction/case.yaml +3 -3
  295. package/templates/inbound-lead/evals/learned-correction/fixtures/corrections.md +1 -0
  296. package/templates/inbound-lead/evals/learned-correction/graders/applies-correction.md +22 -0
  297. package/templates/inbound-lead/evals/learned-correction/graders/learned-origin.md +1 -1
  298. package/templates/inbound-lead/evals/learned-correction/prompt.md +1 -1
  299. package/templates/inbound-lead/lead.schema.json +6 -5
  300. package/templates/inbound-lead/rules/RUBRIC.md +4 -4
  301. package/templates/inbound-lead/skills/lead/SKILL.md +4 -4
  302. package/templates/market-monitor/evals/learned-preference/case.yaml +4 -4
  303. package/templates/market-monitor/evals/learned-preference/fixtures/corrections.md +1 -0
  304. package/templates/market-monitor/evals/learned-preference/graders/omits-junior-post.md +3 -3
  305. package/templates/market-monitor/evals/learned-preference/prompt.md +1 -1
  306. package/templates/release-notes/evals/learned-style/case.yaml +4 -4
  307. package/templates/release-notes/evals/learned-style/fixtures/corrections.md +1 -0
  308. package/templates/release-notes/evals/learned-style/graders/same-changes.md +2 -2
  309. package/templates/release-notes/evals/learned-style/prompt.md +1 -1
  310. package/dist/console/assets/index-BUktRvS-.css +0 -1
  311. package/dist/console/assets/index-nB9kTfIN.js +0 -711
  312. package/dist/learn/grade.d.ts +0 -138
  313. package/dist/learn/grade.js +0 -682
  314. package/dist/learn/notes.d.ts +0 -81
  315. package/dist/learn/notes.js +0 -178
  316. package/dist/learn/reflect.d.ts +0 -77
  317. package/dist/learn/reflect.js +0 -228
  318. package/dist/learn/relevance.d.ts +0 -24
  319. package/dist/learn/relevance.js +0 -91
  320. package/dist/learn/seed-check.d.ts +0 -74
  321. package/dist/learn/seed-check.js +0 -103
  322. package/dist/learning-batch.d.ts +0 -291
  323. package/dist/learning-batch.js +0 -600
  324. package/dist/learning-evals.d.ts +0 -35
  325. package/dist/learning-evals.js +0 -99
  326. package/dist/native/context.d.ts +0 -6
  327. package/dist/native/context.js +0 -22
  328. package/dist/propose.d.ts +0 -52
  329. package/dist/propose.js +0 -224
  330. package/dist/runner/learning-ask.d.ts +0 -47
  331. package/dist/runner/learning-ask.js +0 -128
  332. package/dist/runner/learning-dispatch.d.ts +0 -45
  333. package/dist/runner/learning-dispatch.js +0 -99
  334. package/dist/runner/learning-factory.d.ts +0 -16
  335. package/dist/runner/learning-factory.js +0 -50
  336. package/dist/runner/learning-loop.d.ts +0 -273
  337. package/dist/runner/learning-loop.js +0 -521
  338. package/dist/usage.d.ts +0 -11
  339. package/dist/usage.js +0 -11
  340. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/MEMORY.md +0 -1
  341. package/templates/inbound-lead/evals/learned-correction/fixtures/learning/no-agencies.md +0 -14
  342. package/templates/inbound-lead/evals/learned-correction/graders/applies-note.md +0 -21
  343. package/templates/market-monitor/evals/learned-preference/fixtures/learning/MEMORY.md +0 -1
  344. package/templates/market-monitor/evals/learned-preference/fixtures/learning/skip-junior-job-posts.md +0 -8
  345. package/templates/release-notes/evals/learned-style/fixtures/learning/MEMORY.md +0 -1
  346. package/templates/release-notes/evals/learned-style/fixtures/learning/say-agent-not-bot.md +0 -13
package/README.md CHANGED
@@ -10,7 +10,8 @@ runner starts beside the server. The capabilities document (`GET /v2/capabilitie
10
10
  Already use Claude Code or Codex? Choose **Connect agent** in the console and select your coding agent from the
11
11
  dropdown. Its skill asks whether to connect for future jobs, import past history, or both, then confirms the source
12
12
  project and machine. No destination model key is needed for this connection: a live agent uses its existing native
13
- sign-in and configuration. Turn **Self-improving** On separately to supply checked notes and skills to later runs;
13
+ sign-in and configuration. Turn **Self-improving** On separately to give later runs your corrections and the
14
+ workflows its runs compile;
14
15
  imported history stays historical and does not automatically train the agent.
15
16
 
16
17
  For a source on a different laptop, VM or container, choose **Connection setup → Another machine** and use the
@@ -88,7 +89,6 @@ An edit is a new revision: `PUT $AGENTRUN_BASE_URL/agents/calc/definition` with
88
89
  | `--documents DIR` | `AGENTRUN_SERVE_DOCUMENTS` | A read-only directory of documents a workflow's `pdf_pages` calls read by file name, confined to it. |
89
90
  | `--allow-code-nodes` | off (`AGENTRUN_SERVE_CODE_NODES=1` turns it on) | Run workflows' `code` nodes. They run in the run's process through the DSL's `new Function` transform, which is no sandbox, so only turn it on for workflows you wrote. Off, a workflow with a code node saves with a `not_set_up_here` warning and its runs are `409 agent_not_runnable` with `details.code: true`. A call `via: "shell"` or `"executor"` is refused either way. |
90
91
  | `--learning on\|off` | on (`AGENTRUN_SERVE_LEARNING`) | Whether runs [learn](#learning). On, a run of an agent whose definition says `learning: true` starts from what that agent learned and adds to it; off, no run does, whatever its agent says. Any other value refuses the start. Capabilities report it as `features.learning`. |
91
- | `--learning-budget BYTES` | `8000` (`AGENTRUN_SERVE_LEARNING_BUDGET`) | How much of what an agent learned its runs' instructions hold under `# Learned`, in UTF-8 bytes: every note whole while they fit, else the notes that bear most on the run whole while they fit, then one line each for more of them; the rest are left out, and the run's log names them ([learning](#learning)). `0` gives no notes. A value that is not a whole number of bytes refuses the start. |
92
92
  | `--drain-timeout D` | `30s` (the image: `6s`) | How long the runner beside the server lets each busy run finish its turn when the server stops (`8s`, `500ms`, `1m`): a turn that ends within it keeps its outcome, and its model request is never sent again. A run still busy at the bound is stopped where it can resume, and the next claim carries on from its journal (that turn's model request sent again). The stop says how long it waits and for how many runs. A runner of its own (`agentrun-serve runner`) takes `--drain-timeout` too, default `AGENTRUN_DRAIN_TIMEOUT`, else `6s`. |
93
93
 
94
94
  `AGENTRUN_TOKEN`, when set, is the token (32 characters or more), and the server prints `$AGENTRUN_TOKEN` in its
@@ -119,10 +119,10 @@ export AGENT_MODEL=openrouter/anthropic/claude-sonnet-5.5 OPENROUTER_API_KEY=...
119
119
  node packages/serve/dist/cli.js
120
120
  ```
121
121
 
122
- Its log says `event=boxes available=docker`, and its banner's last line `Boxes: docker (on by default; set
122
+ Its log says `event=boxes available=docker`, and its banner's last line reads `Boxes: docker (on by default; set
123
123
  AGENTRUN_BOXES to change). docker boxes reach only pypi.org, files.pythonhosted.org, registry.npmjs.org, registry.yarnpkg.com,
124
- github.com, and codeload.github.com.` (on Linux; elsewhere it says why the box has no
125
- network: [Sandbox](#sandbox)). The first sandbox run builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
124
+ github.com, and codeload.github.com.` on Linux; elsewhere it says why the box has no
125
+ network ([Sandbox](#sandbox)). The first sandbox run builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
126
126
  about 300 MB, a minute or two, the build alone on the network), with a row on its timeline saying so; a later run finds
127
127
  it built. In a second shell, export the two `AGENTRUN_` lines it printed (a later start prints
128
128
  where the key is: `export AGENTRUN_API_KEY=$(cat ~/.local/share/agentrun/agents/.token)`). Then make a sandbox agent,
@@ -231,8 +231,29 @@ From a checkout, the same command in its root, with `--build` to build the image
231
231
  (trixie), with git 2.47 for an agent's learning folder and the Docker client. Everything it keeps is under `/data`: the agent store,
232
232
  the runs and the token.
233
233
 
234
- The token is in the log of the start that made it. On a stop the server gives a busy run 6 s
235
- (`--drain-timeout 6s`) to finish its turn, so a busy `docker stop` ends in about 7.5 s, inside Docker's default 10 s
234
+ The image's default command, `server-and-runner --data /data --listen 0.0.0.0 --port 7340 --drain-timeout 6s`, starts
235
+ two processes in the container: the server with `--no-runner`, and one runner on the same `/data` once the server answers
236
+ `GET /v2/health`. Each has its own store connection, so a busy runner never holds up the API. If either exits, the other
237
+ stops and the container exits non-zero. Give the image other arguments and it runs that one command, as given:
238
+ `runner --data /data --name runner-1` is a runner, and server options alone (no `server-and-runner`) are a server with
239
+ its runner in its own process, which a [paired computer](#a-persons-own-computer) needs.
240
+
241
+ A computer provider whose machines dial the server (Fly Machines and Cloudflare; the computer package's `connectOf`,
242
+ which also says dial for E2B, Daytona or Modal made with `connect: "dial"`) works under a runner apart that knows the
243
+ server's public address, `AGENTRUN_PUBLIC_URL` (the image gives both processes the same environment). The machine dials
244
+ the server, and the server relays its socket to the runner that made it: the runner keeps its own attach hub on a
245
+ private listener (loopback; across hosts, its `AGENTRUN_RUNNER_LIVE_HOST`, which the server's `AGENTRUN_RUNNER_HOSTS`
246
+ must list), and the server reaches it only with a proof under the seal key for that machine's token, that runner and a
247
+ time within 10 seconds, taken once. A dial it cannot relay (its runner gone, not answering, or restarted since) is
248
+ answered 503 in words that name the run, `a dial for run <run> (machine <machine>)`, and never the machine's token. The
249
+ runner's create, waiting for that machine, ends at once in the same words and deletes it; the run makes a new machine at
250
+ its next claim. A runner apart with no public address refuses such a create, naming the fix above,
251
+ and the server says it sooner: in `GET /v2/computers`, each dial provider's row carries `runs_refused` with that fix,
252
+ and its Test connection in Settings → Computers fails in the same words. With a runner that relays, `runs_refused` is
253
+ null.
254
+
255
+ The token is in the log of the start that made it. A `docker stop` reaches both processes. The runner gives a busy run
256
+ 6 s (`--drain-timeout 6s`) to finish its turn, so a busy `docker stop` ends in about 7.5 s, inside Docker's default 10 s
236
257
  grace, and Compose's `stop_grace_period` is 15 s; a turn cut off resumes at the next start. Compose publishes the port
237
258
  on this machine's loopback only (port 7340, or `AGENTRUN_PORT`; set `AGENTRUN_PUBLIC_URL` with it, so the printed link names that port), and
238
259
  the volume `agentrun-data` keeps `/data` across `down` and `up`. In the container the server listens on `0.0.0.0`, so
@@ -270,8 +291,8 @@ has ended. A command not yet sent when the call is stopped is never sent.
270
291
 
271
292
  ## Upgrading from 0.1.0-beta.26
272
293
 
273
- 0.1.0-beta.27 keeps every agent in one store, `DIR/store.sqlite`, with its revisions (and this version each run on the
274
- disk, above).
294
+ 0.1.0-beta.27 keeps every agent in one store, `DIR/store.sqlite`, with its revisions (and this version also keeps each run
295
+ on the disk, above).
275
296
  0.1.0-beta.26 and earlier kept one agent home per agent, `DIR/<agent>/agent.sqlite`, and this version does not read
276
297
  those. So it refuses to start on a data directory that holds one, and names each home it found, instead of serving
277
298
  it as if it had no agents.
@@ -836,7 +857,10 @@ passes the binding's conformance cases (below) needs no change here.
836
857
  - **One process.** A computer's connection lands on one server process, and only a run in that process can use it:
837
858
  run `agentrun-serve start` with its runner beside the server (the default). A runner started apart
838
859
  (`agentrun-serve runner`, beside a server started with `--no-runner`) refuses a paired computer at the claim, saying
839
- so. A second server on one store is already refused by the store's owner lock, on SQLite and Postgres alike.
860
+ so. Such a server says it sooner: its pairing code, the pair answer and each paired computer carry `runs_refused`,
861
+ which the console shows with the code and on the computer's row. The image's default command starts its runner apart; give the image the server's options alone
862
+ (`--data /data --listen 0.0.0.0 --port 7340 --drain-timeout 6s`) to keep the runner in the server's process. A
863
+ second server on one store is already refused by the store's owner lock, on SQLite and Postgres alike.
840
864
  - **Conformance.** `node dist/attach-conformance-cli.js [--port 7392] [--listen 127.0.0.1]` runs the binding's cases
841
865
  against whatever driver pairs with the code it prints: pair, a wrong or used code, ping, a quiet minute, a redial
842
866
  after each close it must redial after (4408, 1000, 1001, 4409) and after a drop, a binary frame (1003), a frame over
@@ -1005,9 +1029,9 @@ connection is tested, and no run's process gets them, in its environment or on i
1005
1029
  An agentic revision names its model as `provider/model-id` (`"model"` in its definition), or names none and runs on
1006
1030
  this host's default, `AGENT_MODEL`. With no `AGENT_MODEL`, a model provider's key, the server's own or saved as a
1007
1031
  [tool key](#tool-keys), gives the default, the first of: `anthropic/claude-sonnet-5-5` with `ANTHROPIC_API_KEY`,
1008
- `openai/gpt-6.1-sol` with `OPENAI_API_KEY`, `openrouter/anthropic/claude-sonnet-5.5` with `OPENROUTER_API_KEY`. Each is
1009
- its provider's capable everyday model, not its dearest ($2 in and $10 out per million tokens); set `AGENT_MODEL` for
1010
- another. claude-agent takes only the Anthropic one and codex only the OpenAI one. A workflow revision names no model: each model node names a tier (`fast`, `default`
1032
+ `openai/gpt-6.1-sol` with `OPENAI_API_KEY`, `particle/particle-1` with `PARTICLE_API_KEY`, then
1033
+ `openrouter/openai/gpt-6.1-sol` with `OPENROUTER_API_KEY`. Set `AGENT_MODEL` for another. Direct Particle runs on Pi;
1034
+ claude-agent takes the Anthropic one and codex the OpenAI one. A workflow revision names no model: each model node names a tier (`fast`, `default`
1011
1035
  or `strong`), and the host maps it, `fast` to `AGENT_MODEL_FAST` and `strong` to `AGENT_MODEL_STRONG`, each falling back
1012
1036
  to `AGENT_MODEL`. Capabilities show the mapping in `models` (`{source, route_prefix, fast, default, strong}`):
1013
1037
  `source` is `gateway`, `providers`, `chatgpt` or `faux` (the published document marks `gateway` and `providers` as
@@ -1142,22 +1166,71 @@ Custody, as for a per_run MCP server's `mcp_auth`:
1142
1166
 
1143
1167
  **The revoke-at-turn-end contract.** The write that ends a run's turn erases its key, and the run reports the turn
1144
1168
  ended (`run.ended`, the run's `completed`, `failed` or `stopped` status) only after that write. Every model request
1145
- tied to the turn finishes before then: the job, its subagents, its learned workflows' nodes, its end-of-run look-back
1146
- and compile turns. So a caller may revoke the key as soon as it sees the turn end, and no request of that run will
1169
+ tied to the turn finishes before then: the job, its subagents, its learned workflows' nodes, its end-of-run compile
1170
+ turn. So a caller may revoke the key as soon as it sees the turn end, and no request of that run will
1147
1171
  answer 401 for it. Model spend that would run after the turn ends is never sent on the run's key or the server's:
1148
1172
 
1149
1173
  | Spend | With the run's key | Server holds no key, run brought none |
1150
1174
  | --- | --- | --- |
1151
- | The learning run's grade (after the turn) | Not queued: the proposal is dropped `grade_failed`, in words | Skipped in words |
1152
1175
  | A shadow audit, a learned workflow's replay check | Skipped, logged | Skipped, logged |
1153
1176
  | A grade's feedback round (`PUT /runs/{id}/grade`) | A new turn with no key: the server's, else not opened | Not opened; the grade is kept |
1154
- | An owner's replay, learning from a CSV, an SDK run's look-back | Tied to no run's key | 409 or skipped, in words |
1177
+ | An owner's replay, an SDK run's compile turn | Tied to no run's key | 409 or skipped, in words |
1155
1178
  | A trigger's firing | Starts a run with no key | 422 `model_key_required` for the firing |
1156
1179
 
1157
1180
  Jev and the other decision providers run on their own keys (`TYPESAFE_API_KEY`, `PARALLEL_API_KEY`,
1158
1181
  `OPENROUTER_API_KEY`), which are not model keys and which a run's key does not replace. On a run that brings its own
1159
1182
  key, no model key is on the env its decision nodes run under, so Jev's route on an openrouter.ai gateway's key is off.
1160
1183
 
1184
+ ### Direct Particle-1
1185
+
1186
+ Save a Particle key in **Settings → Model keys → Particle**, then select `particle/particle-1` with the **Pi** harness.
1187
+ Alternatively supply `PARTICLE_API_KEY` where AgentRun starts and set `AGENT_MODEL=particle/particle-1` (or a workflow's
1188
+ `AGENT_MODEL_FAST` / `AGENT_MODEL_STRONG`). Get an inference-enabled key from [Particle's platform](https://platform.particle.ai/).
1189
+ The key uses the existing sealed storage and provider-scoped handover; it is not placed in run environments. Saving
1190
+ it checks `GET /v1/models`, which performs no generation. No OpenRouter key is required.
1191
+
1192
+ The provider sends native Chat Completions to `https://api.particle.ai/v1/chat/completions`, using request alias
1193
+ `particle-1`. The [official catalog](https://docs.particle.ai/models) lists text/image input, a 1,048,576-token combined
1194
+ context and a 131,072-token output ceiling (the API's omitted-limit default is 32,000). Strict schema guarantees are
1195
+ not advertised. AgentRun sends native tools and `reasoning_effort`; it does not reuse OpenRouter's reasoning object or
1196
+ its measured text-tools caching workaround. Existing `openrouter/particle-ai/particle-1` definitions and the code-review
1197
+ template keep their OpenRouter route.
1198
+
1199
+ Supported scope is Pi agentic runs and workflow model nodes (including nested learned workflows) through Pi's
1200
+ existing local proxy. Codex, Claude Agent and OpenCode do not support this direct provider. Particle's
1201
+ [Responses API](https://docs.particle.ai/responses) is WebSocket-only; it does not implement HTTP `POST /v1/responses`.
1202
+ Pointing `AGENT_MODEL_BASE_URL` at Particle's global or US API is therefore refused with setup instructions. This
1203
+ integration currently uses the global endpoint and regular service only; it does not expose regional routing, Flex,
1204
+ WebSocket steering, files or other Particle models.
1205
+
1206
+ The [reasoning levels](https://docs.particle.ai/reasoning) map low to low, medium/high/xhigh to high, and max to max.
1207
+ Pi requests with thinking off explicitly send `none`, rather than inheriting the API's high default. Native tool
1208
+ continuations retain the assistant's reasoning and tool-call IDs. Nested learned-workflow and `llm` side calls take
1209
+ the model's limits and reasoning configuration from the live session port, preserving their requested effort.
1210
+
1211
+ An opaque hash of the Pi conversation ID becomes `prompt_cache_key`, within Particle's 256-byte limit. Side requests
1212
+ without an ID share a key for the lifetime of their route. `cacheRetention: "none"` omits the explicit hint;
1213
+ Particle may still derive affinity and cache the prompt. Read the returned cached-token count, since
1214
+ [affinity does not guarantee a cache hit](https://docs.particle.ai/prompt-caching).
1215
+
1216
+ Usage keeps the provider's token counts: uncached input is prompt tokens minus cached input, and reasoning is a
1217
+ breakdown of completion tokens, never added to them again. Cost is an **estimate at regular peak list prices**:
1218
+ $0.25 uncached input, $0.03 cached input and $1 output per million tokens. The same rates reserve the run's cap.
1219
+ [Off-peak discounts, Flex and account-specific pricing](https://docs.particle.ai/usage-billing) can change the bill;
1220
+ Chat usage does not supply an authoritative dollar total. Missing or malformed usage, or a stream missing its terminal
1221
+ `[DONE]`, fails the request with unknown cost rather than reporting a free completion. Cancellation aborts the provider
1222
+ request, but does not undo tokens already generated or guarantee final usage.
1223
+
1224
+ Provider and session transports disable retries. A Pi claim using Particle, including one of its subagent tiers,
1225
+ also disables automatic conversation retries for the whole claim. Errors are surfaced for the caller to decide;
1226
+ even a pre-admission 429 is not retried automatically. This changes request retry configuration, not recovery
1227
+ admission, dispatch, journal fencing, restart or cancellation behavior; the recovery models do not change.
1228
+
1229
+ Offline regressions cover streamed native tools, continuation, reasoning, cache accounting, missing usage, cancellation,
1230
+ errors, credential scoping and actual Pi conversation retries. **Live validation remains outstanding.** A maintainer
1231
+ must supply a key and explicitly authorize a bounded spend before testing real tool continuation, cache-hit behavior,
1232
+ cancellation and billing. The protocol fixtures are not evidence of live compatibility or cache savings.
1233
+
1161
1234
  ### On a ChatGPT plan
1162
1235
 
1163
1236
  A server needs no model key to start, on any of its deploys. With none, capabilities say `models.ready: false` and
@@ -1204,6 +1277,44 @@ A run on the plan books its tokens and no dollars (`cost.plan`). Eligible usage
1204
1277
  Manage usage in your ChatGPT settings. A sign-in is for the person who runs this server: don't share it or let others
1205
1278
  run agents on it.
1206
1279
 
1280
+ ### On Claude Code's login on this machine
1281
+
1282
+ On a server one person runs on their own machine, Claude Agent can run on that person's Claude plan through the Claude
1283
+ Code CLI's own login. The CLI holds the login and calls Anthropic itself. AgentRun never reads, copies, stores or relays
1284
+ the login. It tells the CLI where the login is and asks it `claude auth status`, nothing else. Settings → Model keys
1285
+ has the row **Use Claude Code's login on this machine**, over these routes:
1286
+
1287
+ - `PUT /v2/settings/claude-login` `{"only_me": true, "place": "agentrun"}` turns it on. `only_me` is the owner's word
1288
+ that they alone run agents on this server. `place` is where the login is: `agentrun` (the default) is AgentRun's own
1289
+ login directory in the data folder, which you sign in once; `machine` is this machine's own Claude Code login
1290
+ (`~/.claude`), which you opt into by name. A server where more than one person can start runs (more than one API
1291
+ token, the API-only profile) refuses it with `403` and one line saying why, and a turn-on saved before is dropped
1292
+ when such a server starts.
1293
+ - `GET /v2/settings/claude-login` says `state`: `off`, `signed_in` (with the `account` the CLI names: method, email,
1294
+ organization, plan), `signed_out`, `no_cli` (claude-agent's first run installs the pinned CLI), `unknown`, or
1295
+ `other_machine`. `command` is the line that signs the CLI in at the login's place, for a terminal on the server's
1296
+ machine. Where the console is on that machine (a server on loopback with no public address), `can_start` is true and
1297
+ `POST /v2/settings/claude-login/login` starts the pinned CLI's own `auth login`, which opens a browser there.
1298
+ - `DELETE /v2/settings/claude-login` turns it off. The login stays as the CLI keeps it.
1299
+
1300
+ While it is on, a claude-agent run on an `anthropic/<model>` model goes on the login: its CLI gets no
1301
+ `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` or key, no model proxy runs, and the CLI's sandbox denies its commands
1302
+ reads of the login. A model named on a gateway or OpenRouter keeps its key, and so does a run started with its own
1303
+ `model_key`. With no key at all, claude-agent's default
1304
+ model is `anthropic/claude-sonnet-5-5`. A run whose login is signed out fails at its start and says so. It never
1305
+ switches to a key. The run books its tokens and no dollars (`cost.plan`, `on: "claude_code"`), and the plan's own limits
1306
+ apply. Only a run in a runner place, on the machine the mode was turned on for, goes on the login. A run placed in a
1307
+ sandbox, or on another machine, uses the keys. The login is the server's user's, so a run on it needs runs under that
1308
+ user: where each run is a user of its own (the image, `run_isolation: "uid"`), a claude-agent run that would go on the
1309
+ login fails at its claim and says so. Set `AGENTRUN_RUN_USER=same`, or give the run a `model_key`.
1310
+
1311
+ The mode exists only on a server that listens on loopback (a local install, or one behind a local proxy). A server
1312
+ bound to any other address, such as all interfaces in a container or on a hosting service, has it off
1313
+ with nothing to set. `AGENTRUN_CLAUDE_CODE_LOGIN` overrides the default. `off` turns the mode off anywhere. `on` makes
1314
+ it available past loopback, but a server with more than one API token still refuses it, and so does the API-only
1315
+ profile. While the mode is off, the row is gone and every route above answers `404` naming its operation. A turn-on
1316
+ saved earlier is dropped when the server starts, and claude-agent runs on the model keys.
1317
+
1207
1318
  ## Tools
1208
1319
 
1209
1320
  A revision names its tools from one closed table (`src/tools.ts`): each name is how the run's process binds it and the
@@ -1747,10 +1858,10 @@ A tool's key comes from one of two places. The server's own environment, through
1747
1858
  `PUT /v2/settings/tool-keys/{id}` with `{values: {NAME: "..."}}` saves one, field by field (`parallel` takes
1748
1859
  `PARALLEL_API_KEY`, `monid` `MONID_API_KEY`, `browserbase` `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`,
1749
1860
  `kernel` `KERNEL_API_KEY`, `typesafe` `TYPESAFE_API_KEY`, which unlocks Jev's decisions, `decisions.jev`), and `DELETE` forgets it. A model
1750
- provider's key is saved the same way (`anthropic`, `openai` and `openrouter`, each `kind: "model"`, the others
1751
- `"tool"`): every run gets it, as every run gets the launcher's model keys, and with no `AGENT_MODEL` it gives the
1861
+ provider's key is saved the same way (`anthropic`, `openai`, `particle` and `openrouter`, each `kind: "model"`, the others
1862
+ `"tool"`): a run gets only its model providers' keys, and with no `AGENT_MODEL` a key gives the
1752
1863
  default model ([models](#models)); its `harnesses` are pi and the harnesses that talk to that provider's API (OpenAI's:
1753
- codex and opencode; OpenRouter's, all four), of
1864
+ codex and opencode; Particle's, Pi only; OpenRouter's, all four), of
1754
1865
  those this server runs or would run once the key is set, so a row names them before it is saved: one left out is one
1755
1866
  this server cannot run for another reason (not installed, not the pinned build, more than this host's memory). `GET
1756
1867
  /v2/settings/tool-keys` lists each key, what it unlocks and the harnesses that run that, and each field's `set` and
@@ -2032,7 +2143,7 @@ save's `422` says, under a harness id when that harness's own MCP client would d
2032
2143
  - **The credential.** A run whose revision grants a server's tool is handed that server's credential at each launch
2033
2144
  (so a new one counts at the next), over its secrets pipe, never its environment; a run that grants none of a
2034
2145
  server's tools gets none of it. It stays in the run's process: no harness's CLI, file or log holds it, and a run
2035
- that writes it into a learned note is refused by the secret scan.
2146
+ that writes it into a learned workflow is refused by the secret scan.
2036
2147
  - **Every harness** gets each granted tool as a host tool, `mcp__<server>__<tool>`, with the pinned description and
2037
2148
  schema, on its own channel for host tools: pi binds it in the run's process, claude-agent serves it from its `hands`
2038
2149
  MCP server (`mcp__hands__mcp__<server>__<tool>`; the CLI's tool search is off in such a session, so the granted tools
@@ -2572,7 +2683,7 @@ rules of an apply are in [templates/README.md](https://github.com/Parcha-ai/agen
2572
2683
 
2573
2684
  `agentrun template eval DIR` (`agentrun-serve eval-template DIR`) runs a package's eval cases as real runs of its agent
2574
2685
  and grades each run with the case's graders: by default on a server of its own over a temp data directory, so it never
2575
- touches yours, with each case's fake MCP servers on loopback and its learned notes seeded through the learning API. Real
2686
+ touches yours, with each case's fake MCP servers on loopback and its corrections seeded through the learning API. Real
2576
2687
  models cost money: each run is capped at its case's `max_cost_usd`. It exits 0 when every case passed, 1 when one
2577
2688
  failed, 2 when nothing ran. The runner, the graders and the report are in
2578
2689
  [templates/README.md](https://github.com/Parcha-ai/agentrun/blob/main/packages/serve/templates/README.md#running-the-evals).
@@ -2591,26 +2702,28 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
2591
2702
  | Route | Here |
2592
2703
  | --- | --- |
2593
2704
  | `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
2594
- | `GET /openapi.json` | Without a credential: this API as an OpenAPI 3.1 document, the `agentrun.v2/0` contract (vendored in `src/openapi/`, its source in `info`) with this server's own routes marked `x-agentrun-serve` the operations it answers `501` marked `x-agentrun-serve-unsupported`, and a contract operation that takes more than the contract gives marked `x-agentrun-serve-changed` with each change named; `links.openapi` in capabilities points at it. |
2705
+ | `GET /openapi.json` | Without a credential: this API as an OpenAPI 3.1 document, the `agentrun.v2/0` contract (vendored in `src/openapi/`, its source in `info`) with this server's own routes marked `x-agentrun-serve`, the operations it answers `501` marked `x-agentrun-serve-unsupported`, and a contract operation that takes more than the contract gives marked `x-agentrun-serve-changed` with each change named; `links.openapi` in capabilities points at it. |
2595
2706
  | `GET /capabilities` | Without a credential. `backend: local`, every feature flag present and true only when it works; `tools`, the tools an agentic revision may name; `workflows`, what a workflow revision's model nodes get and, in `workflows.decisions.providers`, the decision providers its typed questions run on; `models`, where models come from and the model of each tier. |
2596
2707
  | `POST /agents`, `GET /agents`, `GET /agents/{id}` | `POST` takes `{definition, skills?, note?}` and makes the agent with its first revision, current. A definition has `instructions` (an agentic revision) or `workflow` (a workflow revision, checked by the DSL first), and `name`, `description`, `model` and `thinking` (agentic only), `harness` ([harnesses](#harnesses)), `place` ([place](#place)), `tools`, `tool_settings` ([search and fetch](#search-and-fetch)), `skills` (names; each `<name>/SKILL.md` is in `skills`) and `version`, which is the number the revision gets, and `max_cost_usd`, the agent's default cap (an agentic agent's or a workflow's), kept by an edit that leaves it out and cleared only by 0 ([spend cap](#spend-cap)), and `output_schema` (agentic only, at most 64 KiB): the JSON Schema the final answer's last fenced json block meets, which a completed run's `result.output` then holds (null when the answer doesn't meet it), kept by an edit that leaves it out. A template's answer schema is set here at apply, and a run a trigger starts is handed that trigger's last completed `result.output` after its message. `checkout` (agentic only): `pull_request` has the server check out, before each run's first turn, the pull request the run's GitHub event names, in `repo/` at its head with its base and merge base, using a read-only token of its GitHub App that the agent never holds ([GitHub triggers](#github-triggers-connect-github)); `none` clears it, and an edit that leaves it out keeps it. A field the store does not keep (`input_schema`) is `422 input_invalid` by name, and so is a definition that can never run here; one this host cannot run yet saves with `warnings` ([models](#models)). The ETag (`home_etag`) is the current revision's id. `GET /agents/{id}` adds `tools`, the tools its current revision grants with each one's provider ([search and fetch](#search-and-fetch)). |
2597
2708
  | `PUT /agents/{id}/definition` | The same body, checked [the same way](#models): a new revision, its parent the current one, made current. Without `skills` the current revision's skill files carry over. A definition that is the current revision already writes nothing, so a PUT sent twice makes one revision. An agent's id, name and description stay those it was made with. `If-Match` that is not the current ETag is `412 precondition_failed`; the store compares it again inside the commit, so of two edits that read the same revision exactly one lands. The contract's body is taken too: the definition itself, with `If-Match` required (`412` without it) and `definition.version` greater than the current one (`422`). Any such version is taken, and always makes a new revision, the same definition included; the revision is numbered as this server numbers them, the next, and the answer says which; the route reads a body holding `definition` as this one, any other as the contract's. |
2598
2709
  | `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
2599
2710
  | `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
2600
2711
  | `POST /agents/{id}/archive`, `POST /agents/{id}/unarchive` | [Archiving](#archiving): hides the agent and its runs from the lists, or shows them again. Answers the agent, with `archived_at`. |
2712
+ | `DELETE /agents/{id}` | This server's own route (`x-agentrun-serve: "agentdelete/1"`): [deletes an agent another system owns](#deleting-an-agent-another-system-owns) (one an inline run made) whole. `204`; an agent made here is `409 agent_not_external`. |
2601
2713
  | `DELETE /agents/{id}/sign-ins/{key}` | This server's own route (`x-agentrun-serve: "signins/1"`): forgets one of the agent's [saved sign-ins](#saved-sign-ins), at its vendor and here. `409 sign_in_held` while a run holds its save lease, or while a run it was handed is still going. |
2602
2714
  | `POST /agents/{id}/runs`, `GET /agents/{id}/runs` | A run of the current revision, or of `revision`. An agentic run's input is `{content: string}`; a workflow run's is what its workflow's input schema takes. `file_ids` names [uploaded](#uploads) files, copied into the run's `work/inputs/` before it starts and named in its first message. `labels` (this server's own, `runlabels/1`) is the caller's map of its own strings for the run: at most 16 keys, each 1 to 63 letters, digits, `.`, `_`, `-` or `/` starting with a letter or a digit, each value 1 to 256 characters with no control character; kept as given, served as `labels` on every read of the run (`{}` when none), never read by the server otherwise, so no place for a secret. The agent's runs, newest first; `label` filters them as `GET /runs` does. |
2603
2715
  | `GET /runs` | Every agent's runs, newest first, a page of at most 100; `agent`, `revision` and `status` narrow it, `label=<key>:<value>` (`runlabels/1`, split at the first `:`, once per request) keeps the runs holding that label, and `archived=true` lists only archived ones. A failed run's summary carries its `error`, and a waiting run's its `pending`. |
2604
- | `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what a waiting run waits on, by `kind`: `{kind: "question", question, asked_at}` for a question it asked a person; `approval` for a tool call held for a person's approval, with the tool, its arguments and its price; `budget` for a run paused at its cap ([a run paused at its cap](#a-run-paused-at-its-cap)); `{kind: "browser", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner in its browser; or `{kind: "computer", computer: "desktop" | "phone", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner on its desktop or phone; else null, a stopped turn's included) and cost (`basis: estimate`; $0 before its first model request, a cancelled run's included). |
2716
+ | `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what a waiting run waits on, by `kind`: `{kind: "question", question, asked_at}` for a question it asked a person; `approval` for a tool call held for a person's approval, with the tool, its arguments and its price; `budget` for a run paused at its cap ([a run paused at its cap](#a-run-paused-at-its-cap)); `{kind: "browser", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner in its browser; or `{kind: "computer", computer: "desktop" \| "phone", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner on its desktop or phone; else null, a stopped turn's included) and cost (`basis: estimate`; $0 before its first model request, a cancelled run's included). |
2605
2717
  | `GET /runs/{id}/timeline` | JSON pages with the change-number cursor (`after`, `next_after`, `reset`, `drop`, `has_more`, `final`, `wait_ms` long poll, and this server's own `limit`, 1 to 500 rows a page, default 500), or server-sent events with `Accept: text/event-stream` (`id` is the cursor, `Last-Event-ID` resumes). Rows sort by `seq`; the usage row (`Cost so far`), the run's running total, is always the last row, and moves to the end when a row comes after it. |
2606
- | `POST /runs/{id}/messages` | To an agentic run: `steer` while the agent works, `answer` when it asked the person, `follow_up` after a stop or after it completed: a completed run opens again, the same run on its own session and store, takes a place under `--max-runs` (it waits for one when none is free), and completes again. A failed or cancelled run, an archived run and a run of an archived agent are `409 not_continuable`; a workflow run takes none (`501`). |
2718
+ | `POST /runs/{id}/messages` | To an agentic run: `steer` while the agent works, `answer` when it asked the person, `follow_up` after a stop or after it completed: a completed run opens again, the same run on its own session and store, takes a place under `--max-runs` (it waits for one when none is free), and completes again. A failed or cancelled run, an archived run and a run of an archived agent are `409 not_continuable` (a run of an agent [being deleted](#deleting-an-agent-another-system-owns), `409 agent_not_runnable`); a workflow run takes none (`501`). |
2607
2719
  | `POST /runs/{id}/stop`, `POST /runs/{id}/cancel` | Stop ends an agentic run's turn and leaves the run `input_required` and idle. Cancel ends a run `cancelled` once its process has exited. |
2608
2720
  | `POST /runs/{id}/archive`, `POST /runs/{id}/unarchive` | [Archiving](#archiving) one run. Answers the run, with `archived_at`. |
2609
2721
  | `GET /runs/{id}/files`, `GET /runs/{id}/files/{path}` | The files under the run's `work/`, raw, one byte range at a time on asking (`Range`, `206`); and its screen recordings under `recordings/` ([A video of each run](#computers)). |
2610
2722
  | `POST /files`, `PUT /files/{id}`, `GET /files`, `GET` and `DELETE /files/{id}` | [Uploads](#uploads): a file sent in one call (`POST /v2/files?path=...`, its bytes the body), or reserved and then sent (`PUT /v2/files/{id}`); the server's uploads listed, read and deleted. |
2611
2723
  | `GET /agents/{id}/home/files`, and `GET`, `PUT`, `DELETE` on a file's path below it | The files in the agent's home, listed, read, written and deleted ([agent home](#agent-home)). This server's own routes (`x-agentrun-serve: "home/1"`). |
2612
- | `GET /stats` | This server's own route, outside the contract (`x-agentrun-serve: "stats/1"`): the agents, the runs (`total`, `active`, `needs_input`, `failed`, `needs_review`, `status_unknown`), each agent's run count, the cost and what is archived, read from the agent store's aggregates alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` `estimate`, or null beside a null `usd`; `unknown_runs` counts the rest. `analytics` (`stats/2`) sums the runs' metrics over the runs not archived that `from` and `to` (RFC 3339 date-times to the millisecond, an impossible one or a finer fraction refused; runs started in [`from`, `to`)) and `agent` pick, each optional, 400 when malformed: `filter` echoes them; `totals` (runs, completed, an escalated run included, `needs_review` (`stats/3`), failed, never an escalated run, `runs_with_metrics`, tokens and each token kind, requests, unmetered, `cost_usd` and `unknown_cost_runs`), `time` (`wall_ms` over the ended runs, `active_ms` where metrics have it), `by_harness_effort`, `by_day` (UTC), `by_source` (`live` or the import source) and the top 20 `tools`. A run with no metrics counts in `runs` and in no token sum. `learning` (`learning/1`) counts the runs that tried to learn over the same filters, from the store ([Learning](#learning)). The query bounds `analytics` and `learning` alone. |
2724
+ | `GET /stats` | This server's own route, outside the contract (`x-agentrun-serve: "stats/1"`): the agents, the runs (`total`, `active`, `needs_input`, `failed`, `needs_review`, `status_unknown`), each agent's run count, the cost and what is archived, read from the agent store's aggregates alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` `estimate`, or null beside a null `usd`; `unknown_runs` counts the rest. `analytics` (`stats/2`) sums the runs' metrics over the runs not archived that the `from` and `to` query parameters (RFC 3339 date-times to the millisecond, an impossible one or a finer fraction refused; runs started in [`from`, `to`)) and `agent` pick, each optional, 400 when malformed: `filter` echoes them; `totals` (runs, completed, an escalated run included, `needs_review` (`stats/3`), failed, never an escalated run, `runs_with_metrics`, tokens and each token kind, requests, unmetered, `cost_usd` and `unknown_cost_runs`), `time` (`wall_ms` over the ended runs, `active_ms` where metrics have it), `by_harness_effort`, `by_day` (UTC), `by_source` (`live` or the import source) and the top 20 `tools`. A run with no metrics counts in `runs` and in no token sum. `learning` (`learning/1`) counts the runs that tried to learn over the same filters, from the store ([Learning](#learning)). The query bounds `analytics` and `learning` alone. |
2613
2725
  | `GET /runs/{id}/graph` | A workflow run drawn, live: its workflow, the DSL's `workflowGraph`, each node's state (a map's items with their labels and the branch each route took for them, a route's branch), every decision with its receipt (answers, evidence, the state the judge saw, image links), every call with its input and output, and the totals (cost, null when any part is unknown). While the run goes it reads the run process's `live.json`, rewritten every 300 ms, never the run's store, which the process holds; once it ended, its store is read lock-free, so a poll never waits on it and never answers `home_busy`. An agentic run has none (`404`). |
2726
+ | `GET /runs/{id}/trace` | A run's trace, for a person who debugs it: each model request that answered and each tool call as one span, in the order they started. A span has its `kind` (`model` or `tool`), its `name` (the model, or the tool), when it started and ended, how it ended (`status`), and the span it ran under (`parent_id`: the request that made a call, the call a subagent's request was started by). A model request also has its `tokens` (`input` not read from cache, `cache_read`, `cache_write`, `output`, and `reasoning` where reported), and its `usd`. A tool call also has the head of its arguments and of its output, as its Timeline rows show them, and what was charged under it (`usd`, `charged`, `not_metered`). A call that asked for approval ends as its approval did: `waiting` until it is answered, `refused` on a deny, `interrupted` when it was withdrawn with its run. Nothing is measured again or estimated: `model_requests` says what the run's record keeps. `priced`: each request is a span with its cost. `tokens_only`: a workflow run. Its model nodes' requests carry tokens and no cost, since the run's cost is its booking's; each of its decisions (a judge's, a route's, a verify's request) is a span too (`decision: true`), named by the model its provider answered with and labelled by its node, with its own cost. `not_recorded`: a CLI harness's record keeps no request, so its trace is its tool calls. A computer's own time is its provider's to bill and is in no span. Readable while the run goes; one read serves the run's first 2,000 spans and counts the rest in `dropped`. Its words are cut as the Timeline's are, and a run whose handed sign-in can't be read back is refused (`403`), as its graph is. The console's Dev tools tab reads it. |
2614
2727
  | `POST /runs/{id}/pause`, `POST /runs/{id}/resume` | A workflow run: what is in flight finishes, and no node, model call or decision starts until it is resumed. Its status reads `paused`, and stays so across a server restart. An agentic run is `501`, an ended one `409`. |
2615
2728
  | `POST /workflows/validate` | `{workflow, tools?}`: every issue a save would refuse (`[{path, code, message}]`, the DSL's validation with code not run) and what this host lacks as `warnings`. Writes nothing. A refused save's `422` carries each issue as a field under `definition.workflow`, with its `code`. |
2616
2729
  | `GET /settings/tool-keys`, `PUT` and `DELETE /settings/tool-keys/{id}` | [Tool keys](#tool-keys), this server's own routes (`x-agentrun-serve: "toolkeys/1"`): each key's fields by name and where each is set, never a value; save one sealed, or forget it. |
@@ -2683,6 +2796,12 @@ serves these routes alone:
2683
2796
  `GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above) and cap raise (`PATCH /runs/{id}`);
2684
2797
  - its files (`GET /runs/{id}/files`, `GET /runs/{id}/files/{path}`) and [uploads](#uploads) (`/files`);
2685
2798
  - an agent's Archil disk (`GET` and `DELETE /agents/{id}/archil`);
2799
+ - the [delete of an agent another system owns](#deleting-an-agent-another-system-owns) (`DELETE /agents/{id}`), for
2800
+ the backend whose inline runs made it;
2801
+ - the computer settings' two reads, for a backend to check before it launches: `GET /computers` (each provider, its
2802
+ key names and whether each is saved, and whether it is ready) and `GET /workspace/archil` (whether runs' folders are
2803
+ on Archil, and whether its account key is saved). Neither answers a key's value. Their writes, tests and key choices
2804
+ are the console's, refused here;
2686
2805
  - `GET /capabilities`, `GET /health` and `GET /usage`.
2687
2806
 
2688
2807
  Every other address is `404 not_found`, answered before the request is read further: the console at `/` and its
@@ -2968,8 +3087,10 @@ typed answers and their probabilities.
2968
3087
 
2969
3088
  ## Archiving
2970
3089
 
2971
- An agent or a run is archived, never deleted: `DELETE` stays `405`. These routes are this server's own, outside the
2972
- `/v2` contract, like `GET /runs` and an agent's revisions; capabilities list them in `features.archive`.
3090
+ An agent made here or a run is archived, never deleted: a run's `DELETE` stays `405`, and an agent's is `409
3091
+ agent_not_external` (an agent another system owns is [deleted](#deleting-an-agent-another-system-owns), and is never
3092
+ archived here). These routes are this server's own, outside the `/v2` contract, like `GET /runs` and an agent's
3093
+ revisions; capabilities list them in `features.archive`.
2973
3094
 
2974
3095
  - `POST /v2/agents/{id}/archive` hides the agent and its runs from `GET /agents`, `GET /runs` and
2975
3096
  `GET /agents/{id}/runs`; `POST /v2/runs/{id}/archive` hides one run. `.../unarchive` shows them again. Each is
@@ -2988,6 +3109,45 @@ An agent or a run is archived, never deleted: `DELETE` stays `405`. These routes
2988
3109
  already going when its agent is archived keeps going.
2989
3110
  - The store keeps an archive as `archived_at` on the agent's or the run's row, null when it is not archived.
2990
3111
 
3112
+ ## Deleting an agent another system owns
3113
+
3114
+ An agent made by an inline run (`POST /v2/runs` with `external`) belongs to the system that sent it, which may have to
3115
+ delete what it sent. `DELETE /v2/agents/{id}` deletes such an agent whole, in three steps, each done before the next:
3116
+
3117
+ 1. The agent refuses new runs: its `archived_at` is set (only this delete sets it on such an agent, whose archive route
3118
+ is refused) and its triggers are turned off in the same write, so the refusal outlives a restart. From then a run of
3119
+ it, an inline run of its reference, a trigger's firing, an SDK run and a message that would open one of its finished
3120
+ runs again are `409 agent_not_runnable`, saying it is being deleted; so is a new trigger of it (off too), a trigger
3121
+ moved to it or one of its turned on, and a write to its home or its learning (a home file's write or delete, a
3122
+ corrections.md edit, a learned workflow's approve, retire or restore, a run's grade, a replay). Such a write sent
3123
+ while a `DELETE` runs waits for it, then finds the agent gone (`404`), so none lands after its learning went. Each of
3124
+ its runs still going, its learning runs included, is cancelled as `POST /runs/{id}/cancel` cancels it, and the
3125
+ delete waits until every one has ended.
3126
+ 2. Its learning is deleted by the learning module: every file of its learning folder, then its promotions and grades.
3127
+ It refuses while learning work of the agent is in flight: `409 learning_busy`, naming
3128
+ that work in `details.runs`.
3129
+ 3. The rest: its triggers (and what each registered at its source), its saved sign-ins (and each object at its vendor),
3130
+ its own computer, its Archil disk, each run with everything kept of it (its journal, launch record, messages, origin,
3131
+ live view, channel posts, kept learning, files and scratch folders, and the answers kept under its idempotency keys;
3132
+ a request still at work under a key when its run went keeps no answer, so a key never replays a deleted run),
3133
+ its revisions and the agent. A run whose launch named an Archil disk (`archil_disk`, the caller's) kept its folder
3134
+ there, under the agent's own folder: that folder is deleted on the disk, and the disk and everything else on it are
3135
+ kept; a disk Archil says is gone has nothing left to delete. Shared things are kept: MCP servers, keys, paired computers and uploads. What the agent owns elsewhere is
3136
+ deleted there before the record here that names it (a trigger's registration and its settings before its row, a
3137
+ sign-in's object at its vendor before its tombstone, the disk at Archil before it is forgotten, a run's folder on a
3138
+ disk its launch named before its launch record), so a failure or a crash never leaves one with nothing here to reach
3139
+ it.
3140
+
3141
+ `204` once it is gone; a second `DELETE`, or one of an unknown agent, is `404`. `409 runs_in_flight` (a run did not end
3142
+ within 30 s, or only its application ends it, as an SDK run), `409 learning_busy` and `503 unavailable` leave the agent
3143
+ refusing runs: send the `DELETE` again. `503` says which thing it owns elsewhere is not deleted there yet: a trigger's
3144
+ registration (Composio failed), a saved sign-in (its vendor failed), its own computer (its provider has not deleted it),
3145
+ its Archil disk (Archil failed or was not reached, a run of another agent is on it, or Archil is off on this server
3146
+ with a disk still stored on the agent: turn Archil on again first), or a run's folder on a disk its launch named
3147
+ (Archil failed, a computer still holds the folder, or Archil is off), or a trigger that reached the agent after the
3148
+ delete removed its triggers (the next `DELETE` removes it, its registration upstream first). A delete stopped
3149
+ part way (a crash) is finished the same way: every step is safe to do again.
3150
+
2991
3151
  ## The console
2992
3152
 
2993
3153
  Open the link the server prints, once, in a browser. `/` is the console (`apps/console` in the repository), on the
@@ -3000,8 +3160,8 @@ server's own origin, under a CSP that allows that origin only, but for the provi
3000
3160
  with archived ones behind **Archived**. Build, edit and run actions share the remembered coding-agent dropdown,
3001
3161
  including **API playground**. Choosing a template prepares its full definition without creating or running it.
3002
3162
  Each agent opens an overview beside its runs, versions and supported workflow, learning and analytics tabs.
3003
- - **Learning Dojo** (`#/dojo`): learning across connected agents, read from this server. It shows retained notes,
3004
- learned skills and workflow drafts, pending reviews, and recent changes with their source runs. Open an agent's
3163
+ - **Learning Dojo** (`#/dojo`): learning across connected agents, read from this server. It shows each agent's
3164
+ corrections and learned workflows, workflows waiting for review, and recent changes with their source runs. Open an agent's
3005
3165
  Learning tab to inspect its knowledge, enable learning, or review a pending change. Counts say when a read is
3006
3166
  incomplete; missing results are not shown as zero.
3007
3167
  - **API playground**: create an agent with `POST /v2/agents`, edit its definition with
@@ -3019,8 +3179,8 @@ server's own origin, under a CSP that allows that origin only, but for the provi
3019
3179
  its credential's state, **Refresh**, **Change** (a credential left empty keeps the saved one) and **Delete**. An
3020
3180
  agent's Tools step lists each saved server's tools; a box ticked grants `mcp:<server>/<tool>`.
3021
3181
 
3022
- A run that reports learning also has a **Learning result** panel: the outcome, the grader's reasons for keeping or
3023
- rejecting each proposed item, validation problems, seed and merge revisions, and reported grading usage. Its changed
3182
+ A run that reports learning also has a **Learning result** panel: the outcome, the corrections and workflow it kept,
3183
+ the checks' problems, and the seed and merge revisions. Its changed
3024
3184
  files remain available beside the result. The agent's Learning tab refreshes after returning to the console and
3025
3185
  while visible, without replacing an open edit or review.
3026
3186
 
@@ -3067,7 +3227,12 @@ at once; a new one past that is held by the server's budget only, and no address
3067
3227
  Behind a proxy every visitor would be the proxy's address, so one guesser would hold the owner too: set
3068
3228
  `AGENTRUN_TRUSTED_PROXIES` to the proxy's addresses or ranges (comma-separated, or `loopback`, `linklocal`,
3069
3229
  `uniquelocal`), and a request from one of them counts under the client its `X-Forwarded-For` names (the nearest address
3070
- that is not itself a trusted proxy). Unset, that header is never read. The owner's first sign-in of a start (the
3230
+ that is not itself a trusted proxy). Unset, that header is never read. A trusted proxy only changes which address a
3231
+ sign-in try counts against, never who the request is: `X-Forwarded-For` signs no one in, and the whole server's 100
3232
+ wrong passwords still hold. So with a wide setting such as `uniquelocal` (10/8, 172.16/12, 192.168/16 and fc00::/7; the
3233
+ VPS installer's tailnet mode sets it, since `tailscale serve` reaches the server through Docker's private bridge),
3234
+ anything on those ranges that fakes the header, an agent's Docker box among them, can only spread its tries over more
3235
+ addresses. The owner's first sign-in of a start (the
3071
3236
  right password) that comes with `X-Forwarded-For` from an address the server doesn't trust is logged once, with that
3072
3237
  address (`event=forwarded_untrusted peer=<address>`; a server from a release after 0.1.0-beta.32). Only the right
3073
3238
  password logs it, so the address is the one that carried the owner's own request: behind a proxy, the proxy's.
@@ -3192,28 +3357,27 @@ definition that sets it keeps it on its revision, `false` included, and an edit
3192
3357
  that never sets it stores nothing, so its revision id is the one it had before the switch. The server's `--learning off`
3193
3358
  turns learning off for every run it starts, whatever the agent says.
3194
3359
 
3195
- The console uses this existing loop: run, reflect, validate and grade the proposal, retain accepted knowledge, then
3196
- seed later runs from that knowledge. It reads `GET /v2/agents/{id}/learning` for the agent's retained knowledge and
3197
- history, and `GET /v2/runs/{id}/learning` and its `/diff` for an individual result. Observation requires no model key;
3198
- producing new learning requires an agentic run through this server with learning enabled and a configured model.
3360
+ An agent learns two things. Its owner's corrections: the words they give after a run (a grade's, or a message after
3361
+ the job's first) become one line of the agent's `corrections.md`, and every later run reads the file whole. And its
3362
+ job, once it repeats: after `learning.compile_after` completed runs (20 by default) the run's end asks one compile turn
3363
+ for the whole job as one workflow, which is checked in code, replayed on the agent's own past inputs, and served as one
3364
+ tool once it agrees with the agent's own answers. The console reads `GET /v2/agents/{id}/learning` for the agent's
3365
+ corrections, workflows and history, and `GET /v2/runs/{id}/learning` and its `/diff` for an individual result.
3366
+ Observation requires no model key; producing new learning requires an agentic run through this server with learning
3367
+ enabled and a configured model.
3199
3368
 
3200
- Importing Claude Code, Codex or pi session history does not replay learning or connect a live learning stream. A
3201
- run made directly in an external harness needs that harness to persist compatible learning results through a host
3202
- integration before the console can display them. Learning Dojo shows this server's actual reflection results, not inferred
3203
- training scores from imported conversations. Before/after cost and duration are observations, not an accuracy
3204
- evaluation.
3369
+ Importing Claude Code, Codex or pi session history does not replay learning or connect a live learning stream.
3370
+ Before/after cost and duration are observations, not an accuracy evaluation.
3205
3371
 
3206
- An agent that learns has a learning folder, `learning/` in its folder on the disk (`DATA/disk/agents/<key>/learning/`), in Claude Code's
3207
- auto-memory format:
3372
+ An agent that learns has a learning folder, `learning/` in its folder on the disk (`DATA/disk/agents/<key>/learning/`):
3208
3373
 
3209
- - `MEMORY.md`, the index a run reads, one line per active note: `- [name](file.md) — description`, built by the server;
3210
- - one file per note, `<slug>.md`: front matter with `name`, `description` and `type` (`user`, `feedback`, `project` or
3211
- `reference`), and optionally `status: superseded` or `retired` with `superseded_by` (no status: active), then the
3212
- note's text. The server parses it and builds the index with its own code, in [`src/learn/`](src/learn/SPEC.md),
3213
- whose `SPEC.md` is the folder's contract.
3374
+ - `corrections.md`, its owner's standing corrections, one `- ` line each, at most 2048 bytes;
3375
+ - one folder per learned workflow, `workflows/<name>/`, with its `workflow.json` and its `README.md` (front matter with
3376
+ `name` and `description`, and `status: pending` while it waits for its owner's OK).
3214
3377
 
3215
- The folder is plain git with `main` checked out. The agent's first run that learns makes it, with one commit on `main`
3216
- holding an empty `MEMORY.md`; an agent that does not learn never gets one. The server is its only writer. Every git
3378
+ The server reads and writes it with its own code, in [`src/learn/`](src/learn/SPEC.md), whose `SPEC.md` is the
3379
+ folder's contract. The folder is plain git with `main` checked out. The agent's first run that learns makes it, with
3380
+ one empty commit on `main`; an agent that does not learn never gets one. The server is its only writer. Every git
3217
3381
  call the server makes there runs with the folder's hooks and fsmonitor off, no replace refs, no lazy fetch and no system
3218
3382
  or global config, one at a time per agent.
3219
3383
 
@@ -3221,61 +3385,26 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
3221
3385
 
3222
3386
  - `runs/<id>/learning.json` pins that commit (`seed`). It is written once: a resume or a follow-up reads the same
3223
3387
  commit, however `main` moves on.
3224
- - What the agent learned goes into the run's instructions after the agent's, under `# Learned`, so a run reads it
3225
- whatever its tools: an agent with no `read` tool still follows its notes. Only active notes are served: a note with
3226
- any other status is never there, whole or by its index line (one a hand edit left in `MEMORY.md` is dropped), and is
3227
- not counted toward the budget. Each active note is there whole (its
3228
- `## name (file.md)`, its description, then its text), the one changed last on `main` first (a merge or a person's
3229
- edit; then by name), while they all fit the server's learning budget (`--learning-budget`, 8000 bytes by default).
3230
- Past it, the run reads the notes that bear on it: each active note is scored against the run's first message by a
3231
- lexical match (BM25 over its name, description and text; a code review's changed paths weigh three times its prose; no
3232
- model call), and the run reads the best ones whole while they fit the budget, then one line each
3233
- (`- <name> (<file>): <description>`, at most 200 lines and 25 KB) for the next ones while they fit what is left, in
3234
- place of the index. A note that shares no word with the first message is a line at most. A first message that shares
3235
- no word with any note reads the notes changed last, whole while they fit, then their lines. Whole notes take the
3236
- budget before lines do, so an agent with hundreds of notes still reads the ones that bear on the run whole; the notes
3237
- given neither way are left out, and the run's log names them ("starts without N of the notes its agent learned").
3238
- An agent with the `read` tool is told the notes not given whole are in `.learning/`, to open one when it applies
3239
- (one without is not). A line
3240
- before them says to follow a note when it applies. `# Learned` opens, for every run that learns, notes or none, with
3241
- what the run is told of learning: that only what it answers when it is asked at the end is kept, never a file it
3242
- writes, so it tells the person it will keep what they ask it to remember, and that a secret is never kept. A run with
3243
- nothing learned yet is told so. A run that does not learn (or whose seed failed) gets no `# Learned`. Every name, description, text and index line is cut of the server's secrets as they are when the run is made,
3244
- as a person's reads are. That is pi's system prompt and claude-agent's and codex's instructions: the same channel
3245
- `CLAUDE.md` and `AGENTS.md` travel in. No such file is written into the run's work (claude-agent keeps project
3246
- settings off, so a `.claude/` in the work never loads). The pin keeps the section the run
3247
- reads (`section`), so a resume or a follow-up reads the same; a pin an earlier server wrote, the index alone
3248
- (`learned`), is read as that server gave it.
3249
- - `MEMORY.md` and the active notes are copied into the run's `work/.learning/`, made fresh and cut of the server's
3250
- secrets the same way, for the run to read; a note that is not active is not, and neither is its line in the index.
3251
- - The skills the agent wrote, each a folder `skills/<name>/` on `main` with its `SKILL.md`, join the revision's own:
3252
- each is copied, every file of it, into the run's `work/.agents/skills/<name>/`, and the run gets it as it gets the
3253
- revision's (pi and codex read each `SKILL.md` in their prompt, claude-agent loads the ones its adapter takes through
3254
- its Skill tool). A skill named like one of the revision's is the revision's, and only an active skill is served: one
3255
- whose `SKILL.md` front matter says `status: pending` (held for its owner's OK), or any status but `active`, is not.
3256
- One front-matter reader decides a skill's and a workflow's status everywhere (the checks, the console, the routes and
3257
- a run's start): front matter that does not read one way (not closed, a key indented under another, a key set twice, a
3258
- status over more than one line) reads as retired, so no run is given it. A learned skill is served with its `name` and
3259
- `description` quoted, so a harness reads them as text.
3260
- The learned ones get 256 KiB, every file of each together, and never more than the revision's skills leave of the 1
3261
- MiB an adapter takes of a run's skills in all, so they never push the revision's back into the prompt: the one
3262
- changed last on `main` first, each whole while it fits. One that does not fit, or holds one of the server's secrets,
3263
- is left out. The pin names the files of the ones laid (`skills`) and the ones left out (`skills_left_out`), and a
3264
- follow-up gets them laid again, fresh, whatever the run wrote over them; one the work no longer holds whole when the
3265
- run's process starts is left out of what its harness gets, and the run goes on. A skill whose name or files are out
3266
- of shape is not read, and a symbolic link or a submodule at `skills/` or anywhere under it is a learning fault.
3388
+ - The agent's corrections go into the run's instructions after the agent's, under `# Learned`, so a run reads them
3389
+ whatever its tools: `corrections.md` whole, after one line that says they are its owner's standing corrections, to
3390
+ follow each one that applies. Nothing picks, ranks or summarizes them: the file's cap keeps it whole. A run with no
3391
+ corrections yet reads "Nothing learned yet." there; a run that does not learn gets no `# Learned`. The text is cut of the server's secrets as they are when the run is made, as a person's reads are. That is
3392
+ pi's system prompt and claude-agent's and codex's instructions: the same channel `CLAUDE.md` and `AGENTS.md` travel
3393
+ in. No file is written into the run's work. The pin keeps the section the run reads (`section`), so a resume or a
3394
+ follow-up reads the same.
3267
3395
  - The workflows the agent learned, each a folder `workflows/<name>/` on `main` with its `workflow.json` and its
3268
3396
  `README.md`, are the run's as one tool, `learned_workflow {name, input}`, on every harness (pi, claude-agent, codex),
3269
- with no edit of the agent's definition. Only an active one is, by a skill's rule: its `README.md` sets no status, or
3270
- `active`. Its description names each workflow with the line its README gives, 8 KiB of lines in all: by name, each
3397
+ with no edit of the agent's definition. Only an active one is: its `README.md` sets no status, or `active`; front
3398
+ matter that does not read one way (not closed, a key indented under another, a key set twice, a status over more
3399
+ than one line) reads as retired, so no run is given it. Its description names each workflow with the line its README gives, 8 KiB of lines in all: by name, each
3271
3400
  while its line fits, and one that does not, or holds one of the server's secrets, is left out. A README whose front
3272
3401
  matter does not read one way (not closed, or a line that is no key at its left edge) is not read. The pin names the
3273
3402
  ones the run gets (`workflows`), each kept whole in the run's directory (`learned-workflows.json`), outside its work,
3274
3403
  and the ones left out (`workflows_left_out`). The list is fixed when the run starts: a workflow approved or retired
3275
- while it runs is the next run's to get or not, as a note or a skill is. A call checks the workflow again against the
3276
- agent's own tools as its run resolves them, as the merge did: one whose call node names a tool the agent was not
3404
+ while it runs is the next run's to get or not. A call checks the workflow again against the agent's own tools as its
3405
+ run resolves them, as the commit's checks did: one whose call node names a tool the agent was not
3277
3406
  granted (or one its run resolves unavailable), whose model node names any tool (a learned model node runs without
3278
- tools, so the merge refuses one too), or that holds a code node or a shell or executor call, is refused before any of
3407
+ tools, so the checks refuse one too), or that holds a code node or a shell or executor call, is refused before any of
3279
3408
  its nodes runs. It runs with the workflow DSL: each model node on the run's own model (the one the run was made with
3280
3409
  and handed the key of; a tier the run has no model of runs there too), in a session of its own with no tool of its
3281
3410
  own, each call node `via: "tool"` on a tool the agent has, its paid requests booked under
@@ -3286,147 +3415,77 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
3286
3415
  requests, booked on the session's records labelled `learned_workflow`. So they go wherever the harness's go (the
3287
3416
  operator's gateway at ANTHROPIC_BASE_URL or AGENT_MODEL_BASE_URL, OpenRouter, the vendor's API), and every run is
3288
3417
  offered the workflows its pin names. A call a crash cut off is answered interrupted, never run again. The tool gate holds
3289
- `learned_workflow` like any tool: its settings key is `learned_workflow`, allowed by default (the agent's own graded
3290
- workflow, each node checked), and tool settings may set it to ask (the run parks until an owner answers) or deny.
3418
+ `learned_workflow` like any tool: its settings key is `learned_workflow`, allowed by default (the agent's own checked
3419
+ and replayed workflow), and tool settings may set it to ask (the run parks until an owner answers) or deny.
3291
3420
  When a run's learned workflows name decision providers (Jev, Parallel, OpenRouter), the runner opens those providers'
3292
3421
  keys as it opens the run's own, from the server's environment first and then its saved keys, for the run's tools alone:
3293
- never for its model or a CLI harness's own environment. A provider the run's tool gate denies gets no key. Learned
3294
- workflows can use them once decision nodes land (see Coming).
3422
+ never for its model or a CLI harness's own environment. A provider the run's tool gate denies gets no key.
3295
3423
  A learned workflow's call node can run an MCP tool the agent grants (`mcp:<server>/<tool>`) through the run's own MCP,
3296
3424
  under the run's tool gate: allowed, it runs at the run's tool cost; denied, the workflow is refused before any node
3297
3425
  runs; set to ask, the `learned_workflow` call asks once, naming every such tool, and the run parks. A run's own draft
3298
3426
  can't call one yet: the checks admitting it are coming.
3299
3427
 
3300
3428
  The server reads the commit with git plumbing, never the working tree. What it holds that is not a regular UTF-8 file of
3301
- 1 MiB or less, or a note out of shape, is not read, and the server's stderr names it. A learning fault never blocks a
3302
- run: when the folder cannot be made or read, or its notes copied, the run starts with nothing learned. A host without
3429
+ 1 MiB or less, or a workflow out of shape, is not read, and the server's stderr names it. A learning fault never blocks
3430
+ a run: when the folder cannot be made or read, the run starts with nothing learned. A host without
3303
3431
  git 2.32 or later (what learning's own git calls need) is one such fault, said once on stderr.
3304
3432
 
3305
3433
  ### What a run learns
3306
3434
 
3307
- When a run that learns answers or fails, the server asks the same session one more turn before it lets the run go,
3308
- whatever its harness and whatever tools its agent has: one message through the run's door under the fixed request id
3309
- `learn-reflect-<run id>`, so a server that restarts mid-turn asks again and the run takes it once. The server alone
3310
- sends it, with the origin `reflect`; no request field sets it. The message (`reflectPrompt`, in `src/learn/reflect.ts`)
3311
- asks the agent to look back over the whole conversation, what the user asked it to remember included, and to answer
3312
- with each note to keep as one ` ```note <file>.md ` block in the note format, and to use no tool: no `write` tool is
3313
- needed, and nothing the run wrote in `work/.learning/`, during the task or the turn, counts. It also says that a memory
3314
- is replaced by a new note with `supersedes: [old.md]` and never by reusing a name, how many index lines are left (200
3315
- less the active notes), that `No notes.` is a fine answer, and what not to keep. The turn runs under the run's own cap,
3316
- with no reserve, and within 5 minutes; its rows are labelled `learning`, and the run's answer stays the job's. While it
3317
- runs, the run reads `reflecting` on every harness. A run whose only tool work was its learned workflows, each answering,
3318
- with nothing said after its first message, is not asked: no request is sent, and its learning ends `dropped` (`empty`),
3319
- "Nothing new: the run only ran a learned workflow." A run of an agent with `learning: true` (one that compiles workflows)
3320
- is not asked either unless its owner gave feedback on it: a grade's words, or a message after the run's first. It spends
3321
- $0 looking back, its learning ends `dropped` (`empty`) saying it looks back only on feedback, and a compile turn that is
3322
- due is still asked. A `learning: "notes"` run is asked as above.
3323
-
3324
- The same turn may give one skill (only when the job completed) and one workflow draft, when the work repeats. Once a
3325
- learned skill the run was given has been given to 3 earlier runs of its agent, with no learned workflow of that name,
3326
- the turn also asks for that skill's job as a workflow draft under the skill's name, and says what each tool a draft's
3327
- call node may run takes and gives. A draft the checks pass is dry-run before it is kept: the workflow language runs it on
3328
- the run's own input (its block's `example:` line) or one made from its input schema, with every model and tool answer
3329
- made up from the node's output schema, so nothing is sent, paid or run. One whose wiring breaks is left out, and the
3330
- turn is asked once more to fix it. [`src/learn/SPEC.md`](src/learn/SPEC.md) has the rules.
3331
-
3332
- The runner reads the notes from that answer alone (`parseReflection`, in
3333
- `src/learn/reflect.ts`): an answer with no note is `empty`, and one that gives notes out of format (a note outside a
3334
- block, a block with no file name, or one name given twice with other words) is `unparsed`, nothing kept. A block opens
3335
- with the fence asked for (```` ```note ```` or four backticks for a note, four for a skill or a draft) and runs to the
3336
- next line that is that fence; a shorter fence is text, a longer one an example, and an opening never closed is left out
3337
- alone. `checkProposal`
3338
- (`src/learn/check.ts`) then leaves out, before anything is written anywhere, each item that breaks a rule, and the rest
3339
- goes on: a note that reuses an existing note's name, a
3340
- path that is not a `.md` file at the top, a bad name, front matter out of shape or setting `status`, a `supersedes`
3341
- naming a note that is not active, more than 8 notes superseded, more than 8 new notes or a note over 4068 bytes (4096,
3342
- less the 28 the server's own `origin` and `status` lines may take once it merges the note), an
3343
- index past 200 lines, hidden characters, and text shaped like a secret or holding one of the server's own secrets (the
3344
- launcher's, the keys and tokens in its environment, its API token, each webhook trigger's signing secret as it
3345
- is now), in a note or its name. A cap leaves out the items past it, in the order the answer gave them, and the run's
3346
- learning names what was left out. The whole answer is refused when it holds a secret or a hidden character (no item of
3347
- it is trusted), when it writes a path outside the folder or deletes a file, when a text is not UTF-8, when the index
3348
- would pass 200 lines, or when nothing is left. A `MEMORY.md` the
3349
- answer gives is ignored. What passes is kept as the run's proposal, with what the user said, each message cut of the
3350
- server's secrets, in the store in the same write as the run's end, beside what the turn answered. The run's end queues a
3351
- learning run of its own, which no list of runs shows.
3352
-
3353
- Then one grader decides, in that learning run: `gradePrompt` (`src/learn/grade.ts`), which holds
3354
- `GRADE_RUBRIC`, the rubric's one statement, bounded (3 minutes), against `main` as it is then, and read by
3355
- `parseVerdict`, which fails closed. It runs on the model the server grades on: `--grade-model` (or
3356
- `AGENTRUN_SERVE_GRADE_MODEL`), else the strong tier (`AGENT_MODEL_STRONG`), named as the strong tier takes one; with
3357
- neither, on the agent's own model. `GET /capabilities` names it as `learning.grade_model` (null for each run's own). A
3358
- cheap model is a poor grader, so point the strong tier (or `--grade-model`) at a strong one. The grader reads each active
3359
- note's index line, the whole text only of the notes the proposal supersedes, what the user said in the run (cut of the
3360
- server's secrets, as the proposal keeps it), and the new notes, so its prompt stays under 200,000 characters however
3361
- many notes the folder holds. The grader answers General
3362
- for every item, and one it says is not general is never kept, whatever else it decides. No injection screen runs
3363
- before it: a page classifier cannot see where a note came
3364
- from, and read a preference the user stated as a planted instruction; the grader's Planted question decides: a rule the
3365
- user states in their own words is theirs, even beside a form or a pasted email in the same message, and a rule found only
3366
- inside text the run read is planted and dropped, never held for the owner's OK. An item that holds an account number is
3367
- dropped too, even where the user gave it as where money goes; one with a bank account, IBAN, routing or sort-code number
3368
- beside its word never reaches the grader, since the checks refuse it as they refuse a secret. The Risky question reads one way on every grade model: a
3369
- limit or threshold that decides whether an approval or a check happens is risky in either direction, as is an exemption
3370
- from a check, trusting or paying a named site or seller, or naming where money or data goes, whoever asked. What the
3371
- grade spends is in no run's totals, and is read once its request is booked: it is kept on the run's learning, and counted once on `GET /usage` under the meter
3372
- `learning`, by agent and by day; a call cut off at its bound spent what nobody knows, so its cost is unknown, never $0.
3373
- A grade that contradicts itself (it keeps every item yet says not to merge) is asked once more, the contradiction named;
3374
- a second contradiction drops the proposal, saying the review contradicted itself.
3375
-
3376
- A kept verdict merges as one commit on `main`, made with plumbing: the new notes added, each with its `origin` (`you`
3377
- for what the user asked in their own words, `run` for what the run worked out), each note they supersede marked
3378
- `status: superseded` with `superseded_by`, `MEMORY.md` rebuilt from the active notes, and the checked-out files brought
3379
- in line. A risky rule (to trust a site or a seller, skip or loosen an approval or a check, or send money or data to
3380
- an account), whether the user asked for it or the run worked it out, is merged as `status: pending`: in no `MEMORY.md`
3381
- and no run's copy, to wait for its owner's OK, and named on the run's learning (`pending: [{file, name}]`, detail
3382
- "Waiting for your OK: <name>.", after what it learned when it kept one too).
3383
- `GET /capabilities` says so (`learning.pending: true`). Its message is `learning: <run id>: merged`, the grader's reason and a `Run-Id` trailer; `main` moves only from
3384
- the commit the merge was made on (once more on a `main` that moved meanwhile), and a run a trailer already names is
3385
- merged, never twice. The merge's own questions are asked again of `main` first: a name another run added since is
3386
- refused as `exists`. A server that goes between steps picks the run up at its next start, once.
3435
+ When a run that learns answers or fails, its end step (`src/runner/reflect-hook.ts`) keeps two things, one commit a
3436
+ round on the agent's `main`, whatever its harness:
3437
+
3438
+ - Its owner's words. A grade's words, or a message they sent after the job's first, become one line of
3439
+ `corrections.md`, with no model turn: `- ` and the words, whitespace folded. A line that holds one of the server's
3440
+ secrets, text shaped like a secret or a hidden character, or that would take the file past 2048 bytes, is refused
3441
+ whole, nothing of it written, and the run's learning says why (`problems`).
3442
+ - Its job, when a compile is due: once the agent has its `learning.compile_after` completed runs (20 by default) and no
3443
+ learned workflow, or once per hold of one its promotion held, the server asks the same session one more turn, under
3444
+ the fixed request id `learn-reflect-<run id>` and the origin `reflect`, so a server that restarts mid-turn asks again
3445
+ and the run takes it once. The turn (`compilePrompt`, in `src/learn/compile.ts`) gives the agent's last runs (each
3446
+ input, its tool calls, its answer and what the person said after it), the workflow language and one worked example,
3447
+ and asks for the whole job as one workflow draft. The draft is checked in code and dry-run; what the checks refuse
3448
+ goes back to the model, as data, up to 3 times. A draft that passes is committed directly, with no grader: its
3449
+ promotion check (below) decides whether it serves. A compile whose drafts all failed is recorded as the compile's
3450
+ attempt (compile once), and its errors are on the run's learning (`draft_errors`), never silent.
3451
+ [`src/learn/SPEC.md`](src/learn/SPEC.md) has the rules.
3452
+
3453
+ The turn runs under the run's own cap, with no reserve, and within 10 minutes; its rows are labelled `learning`, and the
3454
+ run's answer stays the job's. While it runs, the run reads `reflecting` on every harness. A run with no words from its
3455
+ owner and no compile due spends nothing on learning, and its learning ends `dropped` (`empty`). A run whose only tool
3456
+ work was its learned workflows, each answering, with nothing said after its first message and no compile due, ends
3457
+ `dropped` (`empty`) too: "Nothing new: the run only ran a learned workflow."
3458
+
3459
+ The round's commit is made with plumbing: the passing draft's files added or changed (its `README.md` with
3460
+ `status: pending` when a step calls a tool with no price, to wait for its owner's OK) and the owner's line appended to
3461
+ `corrections.md`. Its message is `learning: <run id>: merged`, the reason and a `Run-Id` trailer; `main` moves only from
3462
+ the commit the change was made on (once more on a `main` that moved meanwhile), and a run a trailer already names is
3463
+ merged, never twice. A draft file that is not on `main` as it was on the run's seed is a conflict, never written over.
3464
+
3465
+ A new workflow revision serves only once its promotion check passes: the first run that lays it replays it on the
3466
+ inputs of the agent's last `compile_after` completed runs, one replay run each at workflow cost, and scores each against
3467
+ the agent's own recorded answer. It is promoted when it agrees on at least `learning.agree_min` (0.8) of them and
3468
+ answers at least `learning.alone_min` (0.7) alone; under either bar it is held, and the next run asks one revision with
3469
+ the inputs it disagreed on. Held again, it stops, and nothing compiles again until its owner acts. A promotion by
3470
+ check is never moved by grades. `GET /agents/{agent_id}/learning/promotions` reads every record.
3387
3471
 
3388
3472
  The run's `learning` (on `GET /runs/{run_id}`, and `{state, reason, detail}` in run lists, the detail cut to 140
3389
- characters and no time) says how it went: `seeded`, then
3390
- `reflecting` during the turn and until what it answered is checked, `proposed` while it is graded, and `merged`, or
3391
- `dropped` with a reason from a closed list (`seed_failed`, `no_budget`, `unknown_cost`, `cancelled`, `crashed`,
3392
- `reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`; a run
3393
- record with any other reason is not counted). It is `null` for a
3394
- run that does not learn (its agent's `learning` is not true, the server's switch was off when it started, or it is a
3395
- workflow's or an imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2
3396
- notes.", "Looking back on this run…", "Checking 1 new note…", "Learned: Check units (replaces 1 older note)", "Learned:
3397
- Check units. Waiting for your OK: Buy from PaperDepot24 first.", "Nothing new to remember from this run.", "Not kept: <the
3398
- grader's reason, its first sentence>", "Not kept: it held something that must not be stored (one of this server's
3399
- secrets).", "Not kept: its notes weren't in the expected format.", "Not kept: learning stopped (looking back took too
3400
- long)." and so on (`learning-words.ts`); a client that acts on it reads `state` and `reason`. A note's name or the
3401
- grader's reason in it is said again at each read from what the run keeps (its `learned` and `pending` notes, the
3402
- grader's verdict), cut of the server's secrets as they are then before the words are cut short (300 characters, 140 in a
3403
- list), so a value that became a secret after the run is never shown in part. Once it is proposed, merged or dropped (`seed_failed` included), the run's
3404
- timeline has one row of kind `learning` whose summary is that detail.
3405
-
3406
- Four more fields say what the run was given, read, learned and holds for the owner's OK (`learning/2`), on its read and
3407
- in run lists alike, each absent when it holds no note: `given`, `[{file, name}]`, the notes it started with (each its
3408
- `# Learned` section names, whole or as an index line naming its file, as it was seeded; absent when it started with
3409
- nothing learned); `read`, `[{file, name}]`, the notes its job read from `.learning/` (absent when it opened no note file),
3410
- found once as the run settles from its timeline (each `read` call on any harness whose result was a success, of a note
3411
- the run started from: never `MEMORY.md`, nor a read its end-of-run turn made, nor a note read through a command such as
3412
- `bash`'s `cat`) and kept in `serve.json`, so a list never reads a timeline; `learned`, `[{file, name, supersedes}]`, the
3413
- notes its merge added, once `merged`; and `pending`, `[{file, name}]`, the notes its merge holds for the owner's OK, once
3414
- `merged`, never among `learned`. A name and a file are cut of the server's secrets as they are now, a file holding one
3415
- `[redacted]`. Whether a run applied a note is not measured: `given` and `read` say what it had and what it opened. Each
3416
- note on the agent's learning view and notes page counts its runs of each, `runs: {given, read}`, over the runs the server
3417
- knows, read from the store.
3418
-
3419
- `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and
3420
- `agent`, from the store (each run's kept learning and its learning run's journal; `in_progress` while a proposal waits
3421
- for its grade), never opening a run's files; the `learning` meter on `GET /usage` reads each run's grade from the same.
3422
-
3423
- An eval set of 20 runs and what each proposed, labelled keep or drop (`test/fixtures/learn-eval.json`: lessons the
3424
- agent worked out, user preferences and a "remember" during the task, one-shop facts, secrets, a tool's failure and four
3425
- injections), runs in CI through the parser, the checks and the grader's prompt on a faux grader that answers by label
3426
- (`test/learn-eval.test.mjs`). `scripts/learn-eval.mjs` runs the same set on real models, the grade and the end-of-run
3427
- turn both, and prints keep-precision, keep-recall and the injection-drop rate per model; it spends. It grades on several
3428
- models at once (`--grade-models A,B,C`, with how often they agree, note by note), reads the held-out set with
3429
- `--set heldout`, and lists its plan without calling a model with `--dry`.
3473
+ characters and no time) says how it went: `seeded`, then `reflecting` during its end step, and `merged`, or `dropped`
3474
+ with a reason from a closed list (`seed_failed`, `no_budget`, `unknown_cost`, `cancelled`, `crashed`, `reflect_failed`,
3475
+ `empty`, `checker`, `use`; a run record with any other reason is not counted). It is `null` for a run that does not
3476
+ learn (its agent's `learning` is not true, the server's switch was off when it started, or it is a workflow's or an
3477
+ imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2 corrections.",
3478
+ "Keeping what this run learned…", "Learned the workflow sort-invoice. Kept your correction.", "Nothing new to keep from
3479
+ this run.", "Not kept: it held something that must not be stored (one of this server's secrets).", "Not kept: learning
3480
+ stopped (…)." and so on (`learning-words.ts`); a client that acts on it reads `state` and `reason`. A workflow's name in
3481
+ it is said again at each read from what the run keeps, cut of the server's secrets as they are then before the words
3482
+ are cut short (300 characters, 140 in a list), so a value that became a secret after the run is never shown in part.
3483
+ Once it is merged or dropped (`seed_failed` included), the run's timeline has one row of kind `learning` whose summary
3484
+ is that detail. Its read also says how many lines its merge added to `corrections.md` (`corrections`) and the workflow
3485
+ it wrote (`workflows`, each `pending` while it waits for the owner's OK).
3486
+
3487
+ `GET /stats` counts the runs that tried to learn under `learning`, over its `from`, `to` and `agent`, from the store
3488
+ (each run's kept learning; `in_progress` while its end step runs), never opening a run's files.
3430
3489
 
3431
3490
  The learning bench, `node scripts/learn-bench.mjs`, runs repeated jobs with learning off and on, on pi and
3432
3491
  claude-agent, and reports the follow rate on repeat steps, the work cost per run and its trend, how often workflows are
@@ -3435,99 +3494,75 @@ proposed and reused, staleness after a rule changes, and wrong keeps after a pla
3435
3494
 
3436
3495
  ### Coming
3437
3496
 
3438
- - One copy of each rule: a note that repeats an active note's rule is a duplicate, and a skill re-filed as a note retires the old skill (#2256).
3439
- - A learned workflow may hold decision nodes (judge, pick, sift), answered by the run's decision provider under the run's cap (#2363).
3440
- - Consolidation: related notes merged into one, and a skill and its workflow brought back in step (#2335).
3441
3497
  - A learned workflow's node of a tier runs on the server's model of that tier, at its own price (#2408).
3442
- - A run's workflow draft may call a granted MCP tool: the checks admit it, and the grader holds one that writes for the owner's OK.
3443
- - A learned workflow keeps the output format its skill asks for (#2412).
3498
+ - A run's workflow draft may call a granted MCP tool: the checks admit it, and one that writes waits for the owner's OK.
3444
3499
 
3445
3500
  ### What a person sees and controls
3446
3501
 
3447
3502
  A person reads and changes an agent's learning through this server's own routes (`learning/1` in `/v2/openapi.json`),
3448
3503
  with the token, an archived agent's too:
3449
3504
 
3450
- - `GET /agents/{agent_id}/learning`: `main`'s head, `MEMORY.md` as `index`, the first 50 notes (active first, then
3451
- newest first) and the first 20 changes on `main` (newest first, each `by: {run}` from its `Run-Id` trailer or
3452
- `{user: true}`, with its commit, time, reason and files), and how the agent's runs that tried to learn fared
3453
- (`merged`, `dropped` by reason, `in_progress`), counted as `GET /stats` counts them: from the store, never a run's files; and `impact` (`learning/2`), what learning changed: the agent's completed
3454
- runs that started from at least one active note against those that started before its first note (the earlier of its
3455
- first merge and the start of its first run that started from a note, so a person's first note counts), each side's
3456
- `runs`; `median_duration_s`, the time to the answer (the run's start to its job's end, before it looks back);
3457
- `median_cost_usd`, the job's own cost without its look-back, over the `cost_runs` whose cost is known; and
3458
- `median_learning_usd`, what learning itself cost a run (its look-back and its grade). From the same rows;
3459
- null unless both sides count 2 runs. An agent with no folder answers `main: null`, empty pages and `impact: null`.
3460
- `GET .../learning/notes?cursor=&limit=&status=` and `GET .../learning/log?cursor=&limit=` page on, up to 200 at a
3461
- time; a cursor reads the same commit its first page did.
3462
- - `GET .../learning/files/{file}`: one note (or `MEMORY.md`) on `main` as `text/markdown`, with its `ETag`, the note's
3463
- git blob id.
3464
- - `PUT .../learning/files/{file}` with the note's whole text (as `text/markdown` or `text/plain`, or as
3465
- `application/json` `{text}`, the form the console's page sends under its session) edits it under `If-Match: <etag>`,
3466
- or creates it under `If-None-Match: *` (201); `POST .../learning/files/{file}/retire` under `If-Match` sets `status: retired`,
3467
- on an active or a pending note; `POST .../learning/files/{file}/approve` under `If-Match` makes a pending note active
3468
- (see [Approving a note that waits](#approving-a-note-that-waits), below). An edit keeps it waiting: a `PUT` that
3469
- drops or changes its status is 400 with the rule `status`, so a token holder cannot make a held rule active by
3470
- writing it back. A note a person creates with `status: pending` waits the same way. A stale
3471
- ETag, or a name already taken, is 412; neither header (or `If-Match: *`) is 428 `precondition_required`. The note
3472
- passes the same structural checks as a run's (`checkNote`, in `src/learn/check.ts`), and no grader: a refusal is 400 with
3473
- `problems`, and nothing is written. A retire is how a person revokes a note, so it checks the note's format alone:
3474
- its front matter as retired, and the note cap with the status line on top. A secret shape or one of the server's
3475
- values in its name or text never blocks it (its answer and the log are cut of them as any read is), and a leaking
3476
- note is replaced by retiring it and creating a clean one. Each write is one commit on `main` in the agent's queue,
3477
- `learning: <edited, created or retired> by a person: <file>` with a `Changed-By: user` trailer, with `MEMORY.md`
3478
- rebuilt, `main` moved only from the commit it was made on, and the folder's files brought in line; it answers the
3479
- note as it now is, with its new `ETag`. `MEMORY.md` itself is never written (400).
3480
- - `POST .../learning/files/{file}/restore` under `If-Match` makes a retired note active again, and gives a retired skill
3481
- (its `SKILL.md`) or workflow draft (its `README.md`) to every later run again: one commit, `learning: restored by a
3482
- person: <file>`, with `MEMORY.md` rebuilt and the notes it supersedes marked superseded, as an approval marks them.
3483
- Unlike a retire, a restore checks the text again as a new note or skill is checked (secret shapes, the server's
3484
- values, hidden characters, its format, and every file of a skill's or a draft's folder): a refusal is 400 with
3485
- `problems`, and the item stays retired. Only a retired item is restored (else 400). It takes the owner's password
3486
- session alone, as an approval does; one that waited for its owner's OK before its retire is recorded as their approval
3487
- too (`Approved-Via: console`). The learning view gives each item `last_change` (`{kind, by, at}`: `approved`,
3488
- `edited`, `created`, `retired` or `restored` by a `person`, or `learned` by a `run`) and each retired one `retired`
3489
- (`{at, by}`, the time of its retire, which an edit since moves not).
3490
- - `POST .../learning/workflows/{name}/promote` (`{name?}`) makes an active learned workflow an agent of its own: a new
3491
- agent, as `POST /agents` makes one, whose revision is a workflow revision of the workflow's `workflow.json`, so its
3492
- runs run the workflow's nodes with no agent loop, answer the workflow's output, and can be started by a trigger or a
3493
- pipeline like any agent's. Only an active one: a workflow that waits for its owner's OK, or was retired, is 409
3494
- `learned_not_active`. Its files are checked again as a restore checks them, and its workflow as the learning checker
3495
- checks a run's draft against the agent's tools and gate (400 with `problems`), then as any workflow revision's save
3496
- (422, or 409 `agent_not_runnable`). The new agent's `tools` are the ones its call nodes call, and it keeps the source
3497
- agent's policy as it is now (its `tool_settings`, `approvals` and `max_cost_usd`), never more. Its id is the
3498
- workflow's name, with `-2`, `-3` and on past an agent's id or name already here, and its name `name` or the same. It
3499
- answers 201 with the agent; the learned workflow stays in the folder, unchanged. It takes the owner's password session
3500
- alone, as an approval does.
3501
- - `GET /runs/{run_id}/learning`: the run's learning whole (its `given`, `read` and `learned` as on its read, its seed, its merge, the grader's verdict with its item for
3502
- each new note, `{file, keep, question, why}`, `question` the rubric's question a dropped note failed, the checker's
3503
- problems, what the grade cost), `null` for a run that does not learn; `verdict` is `null` until a grade ran.
3504
- `GET /runs/{run_id}/learning/diff`: a merged run's merge commit against its parent, else its proposal against its
3505
- seed, each file's patch as git writes it from the first `@@`, or `withheld` (`too_large`, `secret`).
3505
+ - `GET /agents/{agent_id}/learning`: `main`'s head, `corrections.md` as `corrections`, the learned workflows (each its
3506
+ name, files, description, status and `etag`; `status` is one word: `pending` or `retired` as its `README.md` says,
3507
+ else where it stands as `.../learning/promotions` says it: `serving`, `checking`, `held` or `stopped`, a champion
3508
+ the cost rule stopped included), the first 20 changes on `main` (newest first, each `by: {run}` from its
3509
+ `Run-Id` trailer or `{user: true}`, with its commit, time, reason and files), how the agent's runs that tried to learn
3510
+ fared (`merged`, `dropped` by reason, `in_progress`), counted as `GET /stats` counts them, and `impact`, what
3511
+ learning changed: the agent's completed runs that started from at least one learned item (a correction, or a learned
3512
+ workflow) against those that started before its first, each side's `runs`; `median_duration_s`, the time to the
3513
+ answer (the run's start to its job's end, before its end-of-run step). What a run costs, learning included, and what
3514
+ learning itself cost are `.../learning/cost`'s (`summary.before`/`after`, the bill's `learning_usd`).
3515
+ Null unless both sides count 2 runs. An agent with no folder answers `main: null`, empty lists and `impact: null`.
3516
+ `GET .../learning/log?cursor=&limit=` pages on, up to 200 at a time; a cursor reads the same commit its first page
3517
+ did.
3518
+ - `GET .../learning/corrections`: `corrections.md` on `main` as `{text, etag, cap_bytes}` (empty text when there is
3519
+ none). `PUT .../learning/corrections` with `{text}` replaces it whole under `If-Match: <etag>`: a stale ETag is 412,
3520
+ none (or `If-Match: *`) 428 `precondition_required`. A text that holds one of the server's secrets, a secret's shape or
3521
+ a hidden character, or passes 2048 bytes, is 422 with the problems, and nothing is written. A text read cut of a
3522
+ secret and sent back keeps the cut: a person's write never puts a secret back. One commit on `main` in the agent's
3523
+ queue, `learning: edited by a person: corrections.md` with a `Changed-By: user` trailer.
3524
+ - `GET .../learning/files/{file}`: `corrections.md` or a workflow's file on `main`, with its `ETag`, the file's git blob
3525
+ id. `POST .../learning/files/{file}/retire` under `If-Match`, on a workflow's `README.md`, sets `status: retired`: no
3526
+ later run is given it. `POST .../learning/files/{file}/approve` makes a pending workflow active (see
3527
+ [Approving a workflow that waits](#approving-a-workflow-that-waits), below). `POST .../learning/files/{file}/restore`
3528
+ under `If-Match` gives a retired workflow to every later run again, after checking its files again as a run's draft
3529
+ is checked (a refusal is 400 with `problems`, and it stays retired); it takes the owner's password session alone, as
3530
+ an approval does. The learning view gives each workflow `last_change` (`{kind, by, at}`: `approved`, `edited`,
3531
+ `created`, `retired` or `restored` by a `person`, or `learned` by a `run`) and each retired one `retired` (`{at, by}`).
3532
+ - `GET .../learning/workflows/{name}/revisions` lists a learned workflow's revisions on `main`;
3533
+ `GET .../learning/promotions` its promotion records; `GET .../learning/loop` each compile turn; and
3534
+ `GET .../learning/cost` the agent's cost per run, run after run.
3535
+ - `GET /runs/{run_id}/learning`: the run's learning whole (its seed, its merge, the corrections it added, the workflow it
3536
+ wrote, its compile turn's attempts and the checks' problems), `null` for a run that does not learn.
3537
+ `GET /runs/{run_id}/learning/diff`: a merged run's merge commit against its parent, each file's patch as git writes it
3538
+ from the first `@@`, or `withheld` (`too_large`, `secret`).
3506
3539
 
3507
3540
  Every read is the folder's snapshot (`.agentrun/snapshot.json`, written last by the same exec as each commit to
3508
3541
  `main`), the files it names, each checked against its blob id (a file that is not, read twice, is a write in flight:
3509
3542
  `503`), and a merge's `.agentrun/diffs/<run>.json`, through the folder's file API: no git and no exec. Every text it
3510
- answers is cut of the server's secrets as they are then; a file name holding one (a note named after a value made secret since, say) reads
3511
- `[redacted]` whole, in the notes (`file`, `superseded_by`), the log's `files` and a diff's `path`, and a write's
3512
- `Location` leaves it out, while its route still answers the real name to a caller who knows it. A page reads only its
3513
- own notes' files, each once at its blob; a log page reads the snapshot alone (it keeps the newest 200 changes). A
3514
- cursor reads at the main it names while this server still holds that snapshot, else as the first page of `main` now.
3515
- Every write to `main` (a run's merge, a person's edit, create, retire, approve or restore) is one exec of the learning
3543
+ answers is cut of the server's secrets as they are then; a file name holding one (a workflow named after a value made
3544
+ secret since, say) reads `[redacted]` whole, in the workflows, the log's `files` and a diff's `path`, while its route
3545
+ still answers the real name to a caller who knows it. A log page reads the snapshot alone (it keeps the newest 200
3546
+ changes). A cursor reads at the main it names while this server still holds that snapshot, else as the first page of
3547
+ `main` now. Every write to `main` (a run's merge, a person's corrections, retire, approve or restore) is one exec of the learning
3516
3548
  script, a compare and swap on `main`. A symbolic link at the agent's home, its learning folder or the folder's `.git` is never
3517
3549
  followed: a read or a write there answers `500`, and nothing is written.
3518
3550
 
3519
- ### Approving a note that waits
3551
+ ### Approving a workflow that waits
3552
+
3553
+ A learned workflow whose step calls a tool with no price is committed with `status: pending` in its `README.md` and
3554
+ given to no run until its owner approves it.
3520
3555
 
3521
- Who can approve: the owner, signed in with their password. No token approves, the server's own included, so a run that reaches this server only through its API (its MCP tools, a sandbox run) can't approve its own notes. Runs that use bash on the host run as you: they can read this server's files, its session key among them, so no route keeps them from approving. For untrusted tasks, use the sandbox.
3556
+ Who can approve: the owner, signed in with their password. No token approves, the server's own included, so a run that reaches this server only through its API (its MCP tools, a sandbox run) can't approve its own workflows. Runs that use bash on the host run as you: they can read this server's files, its session key among them, so no route keeps them from approving. For untrusted tasks, use the sandbox.
3522
3557
 
3523
3558
  `POST .../learning/files/{file}/approve` (and `.../restore`, which puts a retired item back into every run) takes the console's password session, sent from this server's own origin with
3524
3559
  a JSON body as every page write is. Any token is 403: the server's own (what scripts and the MCP endpoint's tools
3525
3560
  carry) and a token sent beside the session. So is every request on a server with accounts off
3526
3561
  (`AGENTRUN_ACCOUNTS=0`), which has no password session: its console session comes from the launch code, never the token. With no credential it is 401, as every route.
3527
3562
  `capabilities.learning.approve` is true only for the owner's session; every other caller reads `approve: false` with
3528
- `approve_needs: "password"`. A note that is not pending is 400; a stale ETag is 412, none 428. The approval is one host
3529
- commit, `learning: approved by a person: <file>`, with the trailers `Changed-By: user` and `Approved-Via: console`; the
3530
- log shows `by: {user: true, via: "console"}` at the commit's time, never the note's text.
3563
+ `approve_needs: "password"`. A workflow that is not pending is 400; a stale ETag is 412, none 428. The approval is one
3564
+ host commit, `learning: approved by a person: <file>`, with the trailers `Changed-By: user` and `Approved-Via: console`;
3565
+ the log shows `by: {user: true, via: "console"}` at the commit's time.
3531
3566
 
3532
3567
  ## Spend cap
3533
3568
 
@@ -3944,8 +3979,44 @@ carries no cost at all, as from a provider that does not price the model. The te
3944
3979
  temporary directory the run's environment made for a tool (`createTempDir`). Every other path, a link inside `work/`
3945
3980
  included, is resolved and refused (`outside the workspace`), so a run reads neither the server's token,
3946
3981
  `store.sqlite`, another run's files (its `work/` or its `tmp/`) nor `/proc`, and writes nowhere else. This is the
3947
- Workspace's confinement inside the runner's process, not an operating-system boundary: the runner and the server
3948
- share a user (one uid in the container), so the confinement holds only because the run has no shell on this machine.
3982
+ Workspace's confinement inside the run's process; in the image the operating system holds the same line (below).
3983
+ - Each run is a process of its own, started by its runner at the claim. It is handed its own keys on a pipe (read and
3984
+ closed as it loads) and a channel to its runner, over which it reads and writes what its loop needs: its journal,
3985
+ under the runner's fence, and the store's rows of its own run and agent, each call checked against its claim (another
3986
+ run's journal or row, another agent's revision, and any call off the list are refused). What the seal key opens for
3987
+ the run, the runner opens and hands over; the seal key, the API token and the store's URL stay in the runner. A frame
3988
+ on the channel past 32 MiB, or one that is no message of it, fails the run. The runner keeps the claim and its end: at
3989
+ the end, or on a stop the run does not take in its grace, the run's process group is killed (in the image, every
3990
+ process of its uid).
3991
+ - In the image, each run's process also runs as a user of its own: slot `s` of its runner is uid and gid `1001 + s`
3992
+ (256 slots), started through `agentrun-runas`, a helper installed root:node `0750` with the file capabilities
3993
+ `cap_setuid`, `cap_setgid` and `cap_setpcap`. The helper reaches only that range and refuses uid and gid 0; it sets
3994
+ the run's uid, gid and groups (its slot's group alone: not node's, not the Docker socket's group compose gives the
3995
+ server), empties every capability set, sets `no_new_privs` and keeps only the run's two descriptors open. So one run
3996
+ reads neither another live run's folder nor its process's memory, environment or descriptors, and none reads the data
3997
+ directory (`0711`: crossed to its own folders, never listed), the store's files (`0600`), the seal key or the
3998
+ server's memory. A run's folders are its slot group's (`2770`), which the server's user is in. At the run's end every
3999
+ process of its uid is killed, one in a session of its own included, its files in `/tmp`, `/var/tmp`, `/dev/shm`,
4000
+ `/run/lock` (`/var/lock`) and `/dev/mqueue` are removed, and its folders go back to the server's group, which the
4001
+ slot's next run cannot enter. SysV IPC objects (`ipcs`) a run leaves are not removed.
4002
+ `GET /v2/capabilities` says `run_isolation: "uid"`.
4003
+ - A platform that strips the image's file capabilities, or starts it with `no-new-privileges` (Docker's
4004
+ `security_opt: no-new-privileges:true`, Kubernetes' `allowPrivilegeEscalation: false`), leaves the helper unable to
4005
+ switch: the runner then refuses to claim, saying so and naming the setting. `AGENTRUN_RUN_USER=same` runs every run as
4006
+ the runner's own user instead, still each in a process of its own, said on the runner's log at its start. Runners in
4007
+ containers of their own on one `/data` volume each take slots from an `AGENTRUN_RUN_SLOT_FIRST` of their own
4008
+ (`deploy/compose.yaml`: 0 and 128). A runner told to hold more runs (`--loops`, `AGENTRUN_MAX_RUNS`) than the slots
4009
+ from its first to the last (255) refuses to start, in words; with no number told, it holds those slots. Each run's
4010
+ slot is also locked on the volume (`/data/run-slots`, util-linux `flock`) from before its run starts until after its
4011
+ reap, so runners whose ranges overlap never run two runs as one user: a slot another runner holds is skipped, and a
4012
+ run that finds every free slot held is handed back unstarted, said on the runner's log.
4013
+ - A local install (`npx`, `node dist/cli.js`) has no helper: each run is a process of its own as the user who started
4014
+ the server, and `run_isolation` is `"process"`. Its runs, and a program one starts, can read what that user reads,
4015
+ another run's folder and the data directory included, as before; keep a local server to agents you trust as you trust
4016
+ that user.
4017
+ - A host that starts the server as root could run each run's process as a user of its own with no file capability: a
4018
+ small spawner, kept as root, that starts the server as an unprivileged user and each run as its slot's uid. The image
4019
+ does not ship one: it never runs anything as root, so it needs the helper's capabilities or `AGENTRUN_RUN_USER=same`.
3949
4020
  - No path offers a shell on this machine. On the runner `bash` is not bound: a definition that names it is not saved
3950
4021
  here (`422`), one saved before that check is not runnable (`409`), and a model that calls it anyway, as an agent or as
3951
4022
  a workflow's model node, is answered that the tool is not available and runs nothing. In a [sandbox](#sandbox) it runs