@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -0
- package/README.md +564 -97
- package/dist/adapters.d.ts +35 -6
- package/dist/adapters.js +152 -26
- package/dist/agents.d.ts +11 -5
- package/dist/agents.js +16 -10
- package/dist/app.js +80 -20
- package/dist/background.d.ts +28 -0
- package/dist/background.js +376 -0
- package/dist/box-egress.d.ts +98 -0
- package/dist/box-egress.js +259 -0
- package/dist/box-image.d.ts +1 -1
- package/dist/box-image.js +9 -7
- package/dist/box-relay-vm.d.ts +80 -0
- package/dist/box-relay-vm.js +389 -0
- package/dist/box-relay.d.ts +8 -5
- package/dist/box-relay.js +14 -9
- package/dist/boxes.d.ts +21 -3
- package/dist/boxes.js +14 -7
- package/dist/browser-cost.d.ts +41 -0
- package/dist/browser-cost.js +158 -0
- package/dist/cap.d.ts +129 -21
- package/dist/cap.js +338 -67
- package/dist/coding-tools.d.ts +7 -3
- package/dist/coding-tools.js +16 -10
- package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
- package/dist/console/assets/index-34jfpIbQ.js +481 -0
- package/dist/console/assets/index-DUHbWcIP.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-rows.d.ts +11 -3
- package/dist/decision-rows.js +18 -11
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -2
- package/dist/files.d.ts +6 -1
- package/dist/files.js +7 -2
- package/dist/grade.d.ts +7 -10
- package/dist/grade.js +31 -51
- package/dist/graph-served.d.ts +23 -0
- package/dist/graph-served.js +75 -0
- package/dist/graph-view.d.ts +7 -5
- package/dist/graph-view.js +10 -3
- package/dist/harness-app.d.ts +4 -2
- package/dist/harness-app.js +101 -19
- package/dist/harness-opencode/adapter.d.ts +45 -0
- package/dist/harness-opencode/adapter.js +272 -0
- package/dist/harness-opencode/binary.d.ts +18 -0
- package/dist/harness-opencode/binary.js +87 -0
- package/dist/harness-opencode/config.d.ts +24 -0
- package/dist/harness-opencode/config.js +61 -0
- package/dist/harness-opencode/harness.d.ts +77 -0
- package/dist/harness-opencode/harness.js +620 -0
- package/dist/harness-opencode/host/mcp.d.ts +40 -0
- package/dist/harness-opencode/host/mcp.js +208 -0
- package/dist/harness-opencode/host/policy.d.ts +71 -0
- package/dist/harness-opencode/host/policy.js +419 -0
- package/dist/harness-opencode/host/server.d.ts +55 -0
- package/dist/harness-opencode/host/server.js +165 -0
- package/dist/harness-opencode/index.d.ts +9 -0
- package/dist/harness-opencode/index.js +6 -0
- package/dist/harness-opencode/verify.d.ts +32 -0
- package/dist/harness-opencode/verify.js +75 -0
- package/dist/harness-opencode/versions.d.ts +33 -0
- package/dist/harness-opencode/versions.js +64 -0
- package/dist/harness.d.ts +4 -1
- package/dist/harness.js +5 -2
- package/dist/host-tools.d.ts +12 -2
- package/dist/host-tools.js +26 -12
- package/dist/host.js +6 -2
- package/dist/hosted-search.js +5 -1
- package/dist/import.d.ts +2 -2
- package/dist/import.js +4 -3
- package/dist/key-check.d.ts +3 -2
- package/dist/key-check.js +7 -3
- package/dist/key-refusal.js +8 -4
- package/dist/learn/check.d.ts +10 -1
- package/dist/learn/check.js +19 -1
- package/dist/learn/grade.d.ts +3 -2
- package/dist/learn/grade.js +25 -13
- package/dist/learn/index.d.ts +2 -2
- package/dist/learn/index.js +2 -2
- package/dist/learn/notes.js +2 -1
- package/dist/learn/reflect.d.ts +2 -2
- package/dist/learn/reflect.js +51 -5
- package/dist/learn/secrets.js +28 -8
- package/dist/learn/skills.d.ts +17 -4
- package/dist/learn/skills.js +79 -6
- package/dist/learned-workflow.d.ts +59 -0
- package/dist/learned-workflow.js +191 -0
- package/dist/learning-run.d.ts +7 -5
- package/dist/learning-run.js +45 -23
- package/dist/learning-words.d.ts +6 -3
- package/dist/learning-words.js +8 -5
- package/dist/learning.d.ts +44 -3
- package/dist/learning.js +148 -3
- package/dist/mcp-servers.d.ts +7 -4
- package/dist/mcp-servers.js +5 -0
- package/dist/mcp.js +5 -5
- package/dist/model.d.ts +13 -11
- package/dist/model.js +11 -10
- package/dist/openapi/agentrun-v2.openapi.json +1 -0
- package/dist/openapi.js +358 -48
- package/dist/paid-calls.d.ts +5 -1
- package/dist/paid-calls.js +1 -1
- package/dist/pause.d.ts +2 -0
- package/dist/place.d.ts +27 -4
- package/dist/place.js +42 -10
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +38 -8
- package/dist/request-start.d.ts +12 -4
- package/dist/request-start.js +139 -15
- package/dist/run-box.d.ts +56 -4
- package/dist/run-box.js +173 -23
- package/dist/runnable.d.ts +5 -2
- package/dist/runnable.js +12 -4
- package/dist/runs.d.ts +258 -36
- package/dist/runs.js +830 -89
- package/dist/secrets.d.ts +12 -0
- package/dist/secrets.js +18 -0
- package/dist/server.d.ts +131 -35
- package/dist/server.js +467 -105
- package/dist/sign-ins.d.ts +99 -0
- package/dist/sign-ins.js +288 -0
- package/dist/skills.d.ts +16 -4
- package/dist/skills.js +35 -7
- package/dist/stats.d.ts +7 -2
- package/dist/stats.js +28 -7
- package/dist/tool-gate.d.ts +266 -0
- package/dist/tool-gate.js +554 -0
- package/dist/tool-keys.d.ts +46 -10
- package/dist/tool-keys.js +44 -2
- package/dist/tool-plane.d.ts +112 -27
- package/dist/tool-plane.js +205 -47
- package/dist/tools.d.ts +69 -14
- package/dist/tools.js +143 -24
- package/dist/trigger-secrets.d.ts +32 -0
- package/dist/trigger-secrets.js +143 -0
- package/dist/triggers.d.ts +439 -0
- package/dist/triggers.js +863 -0
- package/dist/turn-end.d.ts +3 -2
- package/dist/turn-end.js +3 -2
- package/dist/usage-lines.d.ts +26 -0
- package/dist/usage-lines.js +28 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +11 -2
- package/dist/webhooks.d.ts +11 -4
- package/dist/webhooks.js +17 -1
- package/launcher/agentrun-serve +1 -1
- package/package.json +19 -13
- package/dist/console/assets/index-BN7oVcO4.js +0 -445
- package/dist/console/assets/index-By-jkqki.css +0 -1
package/README.md
CHANGED
|
@@ -86,9 +86,11 @@ AGENTRUN_BOXES=docker node packages/serve/dist/cli.js
|
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
Its log says `event=boxes available=docker`, and its banner's last line `Boxes: docker is ready, so sandbox agents run
|
|
89
|
-
their tools there
|
|
89
|
+
their tools there. docker boxes reach only pypi.org, files.pythonhosted.org, registry.npmjs.org, registry.yarnpkg.com,
|
|
90
|
+
github.com, and codeload.github.com.` (on Linux; elsewhere it says why the box has no
|
|
91
|
+
network: [Sandbox](#sandbox)). The first start builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
|
|
90
92
|
about 300 MB, a minute or two, the build alone on the network): its banner then says `Boxes: docker is preparing
|
|
91
|
-
(building the box image (python, git, curl, node, rg)).`, and the log `event=box_image ... state=preparing`, then
|
|
93
|
+
(building the box image (python, git, curl, node, npm, rg)).`, and the log `event=box_image ... state=preparing`, then
|
|
92
94
|
`state=ready` with how long it took; a later start finds it built. A run that needs its box sooner waits for it, with a
|
|
93
95
|
row on its timeline saying so. In a second shell, export the two `AGENTRUN_` lines it printed (a later start prints
|
|
94
96
|
where the key is: `export AGENTRUN_API_KEY=$(cat ~/.local/share/agentrun/agents/.token)`). Then make a sandbox agent,
|
|
@@ -102,6 +104,9 @@ curl -sN "$AGENTRUN_BASE_URL/runs/$run/timeline" -H "$H" -H 'accept: text/event-
|
|
|
102
104
|
curl -s "$AGENTRUN_BASE_URL/runs/$run/files" -H "$H"; curl -s "$AGENTRUN_BASE_URL/runs/$run/files/out.txt" -H "$H"
|
|
103
105
|
```
|
|
104
106
|
|
|
107
|
+
The `place` above is what a new agent gets anyway on a server with docker, so a definition that names only its name and
|
|
108
|
+
instructions lands in the box too, with `bash` as its one tool ([Place](#place)).
|
|
109
|
+
|
|
105
110
|
The timeline ends when the run does. `out.txt` names the image's Debian, whatever this machine runs, and it is in
|
|
106
111
|
the run's `work/`, the one directory the container binds. No key? Start the server with `--faux box.mjs`, a
|
|
107
112
|
[faux model](#the-faux-model) that makes one `bash` call and then answers, and run the same commands:
|
|
@@ -114,8 +119,9 @@ JS
|
|
|
114
119
|
AGENTRUN_BOXES=docker node packages/serve/dist/cli.js --faux box.mjs
|
|
115
120
|
```
|
|
116
121
|
|
|
117
|
-
The box has python 3.12, git, curl, node and rg
|
|
118
|
-
|
|
122
|
+
The box has python 3.12, git, curl, node, npm and rg. On Linux it reaches Python's and npm's package registries and
|
|
123
|
+
GitHub, and nothing else: `pip install` and `npm install` work in it. [The box's image](#the-boxs-image) says how to give
|
|
124
|
+
it more. The rest is under [Sandbox](#sandbox).
|
|
119
125
|
|
|
120
126
|
## Logs
|
|
121
127
|
|
|
@@ -214,14 +220,16 @@ container's limit when it has one (cgroup), else the machine's, less the server'
|
|
|
214
220
|
| pi | 128 MiB | up to 106 MB |
|
|
215
221
|
| codex | 192 MiB | up to 143 MB |
|
|
216
222
|
| claude-agent | 288 MiB | up to 215 MB |
|
|
223
|
+
| opencode | 704 MiB | up to 524 MB |
|
|
217
224
|
|
|
218
225
|
The measure is a short task (write a file, read it back, answer) on a real server in a container of its own; the table
|
|
219
226
|
in `src/harness.ts` says how it was taken. So a 512 MB instance holds 3 pi runs, 2 codex runs or 1 claude-agent run at
|
|
220
|
-
once (or 1 codex and 1 pi), 1 GB holds 7, 4 or 3, and 8 GB 63, 42 or 28
|
|
227
|
+
once (or 1 codex and 1 pi), 1 GB holds 7, 4 or 3, and 8 GB 63, 42 or 28; an opencode run, OpenCode's own process with
|
|
228
|
+
it, needs a 1 GB instance for one and 2 GB for two. A start that does not fit in what is left is
|
|
221
229
|
`429 rate_limited` with `retry-after`, its message naming the harness and the memory, and nothing starts: there is no
|
|
222
230
|
queue, so the client tries again once a run ends. A harness whose one run needs more than all the memory for runs (claude-agent
|
|
223
|
-
on a host under 416 MB) is unavailable: capabilities say why in its `harnesses` entry, and
|
|
224
|
-
agent_not_runnable` with that reason. pi always has one place, however small the host.
|
|
231
|
+
on a host under 416 MB, opencode under 832 MB) is unavailable: capabilities say why in its `harnesses` entry, and
|
|
232
|
+
its runs are `409 agent_not_runnable` with that reason. pi always has one place, however small the host.
|
|
225
233
|
|
|
226
234
|
`--max-runs N` or `AGENTRUN_MAX_RUNS` caps the count as well (by default, as many as pi runs fit), and both limits
|
|
227
235
|
apply. Capabilities report pi's count in `limits.max_concurrent_runs`, and each harness's own in its `harnesses` entry
|
|
@@ -248,8 +256,9 @@ of a process that is gone is not trusted.
|
|
|
248
256
|
## Sandbox
|
|
249
257
|
|
|
250
258
|
A sandbox agent's `bash` runs in a box, a machine apart from this server: today a Docker container made for each run,
|
|
251
|
-
which binds the run's `work/` and nothing else, or a Daytona sandbox, which gets a copy of it
|
|
252
|
-
|
|
259
|
+
which binds the run's `work/` and nothing else, or a Daytona sandbox, which gets a copy of it. Neither holds a key. A
|
|
260
|
+
Docker box on Linux reaches the package registries and GitHub through a proxy, and nothing else; a Daytona box reaches
|
|
261
|
+
them through Daytona's domain list. Its `read`, `write` and `edit` work on that same `work/`: on this server, where the box binds it and this server
|
|
253
262
|
holds directory handles (Docker on Linux), else in the box. The agent's loop, its log, its model calls and every key stay
|
|
254
263
|
on the server. An agent says so in its [place](#place); the server says which [boxes](#boxes) it has; [a run in a Docker
|
|
255
264
|
box](#a-run-in-a-docker-box) is what the container gets, and [a run in a Daytona box](#a-run-in-a-daytona-box) what a
|
|
@@ -263,11 +272,26 @@ A definition may name where its runs execute: `{"mode": "runner"}` or `{"mode":
|
|
|
263
272
|
the ids under [Boxes](#boxes). A runner has no shell. In a sandbox the agent's `bash` runs in the named box and its
|
|
264
273
|
file tools (`read`, `write`, `edit`) work on the `work/` the box has ([a run in a Docker box](#a-run-in-a-docker-box)),
|
|
265
274
|
while the agent's loop, its log and every key stay on the server, whatever its harness. Any other shape is `422 input_invalid` on `definition.place`, whose `fix` is the change to make: the field to
|
|
266
|
-
remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox", "box": "docker"}`).
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
275
|
+
remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox", "box": "docker"}`). One that names a
|
|
276
|
+
place keeps it, `runner` included. An edit that names no place keeps the agent's.
|
|
277
|
+
|
|
278
|
+
The box is a new agent's default machine. A new agentic agent whose definition names no place is saved in the Docker box
|
|
279
|
+
(`{"mode": "sandbox", "box": "docker"}`) wherever this server has docker, ready or still preparing its image (its first
|
|
280
|
+
run then waits for the image, with one timeline row). The place is written on the agent's first revision, so its answers
|
|
281
|
+
show it. If that definition names no `tools` either, it gets `["bash"]`, so the agent has a shell. A definition that
|
|
282
|
+
names its tools keeps exactly those, an empty list included. Where docker is unavailable, a new agent is saved as before,
|
|
283
|
+
with no place, and runs on the runner. So is one whose tools name one the box refuses (`browser`, runner-only for now). A
|
|
284
|
+
workflow is never given a box.
|
|
285
|
+
|
|
286
|
+
`capabilities.places` says both sides. `default_place` is the place a new agent gets here. When that is the runner,
|
|
287
|
+
`default_reason` says why in docker's own words, such as `new agents run on the runner, because the docker box is
|
|
288
|
+
unavailable here: not enabled on this server: start AgentRun with AGENTRUN_BOXES=docker`. `default` stays `runner`,
|
|
289
|
+
because it means where a revision that names no place runs. An agent saved with no place (before this, where docker was
|
|
290
|
+
unavailable, or a workflow) keeps running on the runner, whatever the server has now. The default is never worked out
|
|
291
|
+
again at run time. The console's new-agent form starts on `default_place`, with bash ticked when that place is a sandbox.
|
|
292
|
+
What a person picks or unticks there is what is sent.
|
|
293
|
+
|
|
294
|
+
A run runs in its revision's place, else on the runner. A run request names no place: `POST /agents/{id}/runs`
|
|
271
295
|
with `place` is `422 input_invalid`, as with any field the body does not keep. The run keeps the place it resolved to,
|
|
272
296
|
and `GET /v2/runs/{id}` shows it as `place`. A harness's own tools in the box, when they come, will be an option of
|
|
273
297
|
`sandbox` (such as `native_tools: true`), never a third mode.
|
|
@@ -277,11 +301,11 @@ the sandbox place as its `fix`), and a workflow's place is `runner` or none (`42
|
|
|
277
301
|
its `fix`). In `capabilities.tools`, `bash` is `available: false` with a `reason` (`no box is set up on this server: …`,
|
|
278
302
|
each box's own reason) when no box this server has can run it.
|
|
279
303
|
|
|
280
|
-
`GET /v2/capabilities` lists `places`: the modes, the default, and each box with `available`, its `state` (`ready`,
|
|
304
|
+
`GET /v2/capabilities` lists `places`: the modes, the default, a new agent's place, and each box with `available`, its `state` (`ready`,
|
|
281
305
|
`preparing` while the server builds or pulls its image, or `unavailable`) and, when it is not ready, the `reason`.
|
|
282
306
|
A definition naming a box this server does not have saves with a warning on `definition.place`, and a run of it is
|
|
283
307
|
`409 agent_not_runnable` with `details.box`. `GET /v2/openapi.json` marks `definition.place`, the run's `place` and
|
|
284
|
-
`capabilities.places` `x-agentrun-serve: "place/1"`.
|
|
308
|
+
`capabilities.places` `x-agentrun-serve: "place/1"`, and `default_place` and `default_reason` `"place/3"`.
|
|
285
309
|
|
|
286
310
|
### A run in a Docker box
|
|
287
311
|
|
|
@@ -307,7 +331,44 @@ go through `work/` by path.
|
|
|
307
331
|
one); any other (another path of this machine, `..` out of it, `~`) is refused as outside the workspace, and their
|
|
308
332
|
errors name the box's paths, never this machine's. A mount source that is, or passes through, a link below the data directory is
|
|
309
333
|
refused: the tool call fails, and no container is made. The data directory is resolved to its real path once, at start.
|
|
310
|
-
- It has no network (`--network none`)
|
|
334
|
+
- It has no network of Docker's (`--network none`). On Linux, with a Docker daemon of this machine's own, it reaches a
|
|
335
|
+
list of hosts alone, on ports 80 and 443, through the run's egress proxy. The list, by default: `pypi.org`,
|
|
336
|
+
`files.pythonhosted.org`, `registry.npmjs.org`, `registry.yarnpkg.com`, `github.com` and `codeload.github.com`.
|
|
337
|
+
`AGENTRUN_BOX_ALLOW` replaces it with a comma list of host names, such as
|
|
338
|
+
`pypi.org,files.pythonhosted.org,registry.npmjs.org,registry.yarnpkg.com,github.com,codeload.github.com,deb.debian.org`
|
|
339
|
+
to add one (`*.example.com` names the hosts below `example.com`); `AGENTRUN_BOX_ALLOW=none` is the box offline, as it
|
|
340
|
+
was: no proxy, no network at all. `*`, an address or a CIDR refuses the start.
|
|
341
|
+
- How: the run's process starts the proxy with the list on a Unix socket in a directory of its own under
|
|
342
|
+
`/tmp/agentrun-egress-<uid>/`, bound into the box read-only at `/run/agentrun/egress/`. A `socat` in the box relays
|
|
343
|
+
`127.0.0.1:3128` to it, and `HTTP_PROXY` and `HTTPS_PROXY` (and their lowercase twins) name that port, with
|
|
344
|
+
`NO_PROXY` for loopback. pip, npm, git and curl read them. A program that skips them has no route out.
|
|
345
|
+
- A host off the list, an address and any other port are refused before any lookup, in words: `403 example.com is
|
|
346
|
+
not on this box's network list: use web_fetch for web pages, or ask the operator to add it to AGENTRUN_BOX_ALLOW`.
|
|
347
|
+
So is a listed name whose address is private, this machine's or a cloud's metadata. The proxy holds no key and adds
|
|
348
|
+
none. Its decisions are in the run's process log (`box_egress`: host, port, address, class).
|
|
349
|
+
- Only a Docker daemon on this same Linux machine can reach the proxy's socket. The server checks it once, at start,
|
|
350
|
+
and fails closed: the box has the list only when this machine is Linux, the docker CLI's endpoint is a local unix
|
|
351
|
+
socket, and `docker info` answers within 5 s with Linux containers on this machine's own kernel, keeping its data
|
|
352
|
+
in a directory this server sees. The kernel is the evidence, not the runtime's name:
|
|
353
|
+
- a Docker whose kernel differs from this server's (Docker Desktop on a Mac, OrbStack, Colima) sees a socket bound
|
|
354
|
+
in from the host but cannot connect to it, so its box has no network;
|
|
355
|
+
- a Docker on this server's kernel passes whatever it calls itself, if its data directory is one this server sees:
|
|
356
|
+
Docker Desktop with WSL2 shares the kernel string, but keeps its data outside the distro, so it gets none unless
|
|
357
|
+
the distro has that directory (`/var/lib/docker`); where it passes, the proxy enforces the list as anywhere;
|
|
358
|
+
- a server in a container given the host's docker socket shares the host's kernel but not its files (docker
|
|
359
|
+
info's `DockerRootDir` is not there), so its box has no network rather than every tool call failing.
|
|
360
|
+
|
|
361
|
+
Capabilities and the banner say why, naming what was found: `docker boxes have no network: this Docker (OrbStack)
|
|
362
|
+
runs in a VM (its kernel is "6.15.11-orbstack-…", this machine's "6.1.0-…") that can't reach this server's egress
|
|
363
|
+
proxy yet`. At each start the server removes the proxy directories of runs that are gone (a socket that refuses a
|
|
364
|
+
connect, over a minute old); a live run's, of any server of this user's, stays.
|
|
365
|
+
- Capabilities give the list as `places.allow`, and each box's `network`: `allowlist` or `none`, with
|
|
366
|
+
`network_reason` when an available box has none. An image with no `socat` gets no network, and the run's timeline
|
|
367
|
+
says so once.
|
|
368
|
+
- What it allows, and what it does not: a box reaches no cloud metadata address, nothing of this machine or its
|
|
369
|
+
network, and no resolver, so no name leaves this machine but a listed one. It can send what its run has to a listed
|
|
370
|
+
host with the agent's own credentials (an `npm publish`, a `git push`), as `web_fetch` can send to any public host.
|
|
371
|
+
Docker still binds its copies of this machine's
|
|
311
372
|
`/etc/resolv.conf`, `/etc/hostname` and `/etc/hosts` into it, read-only, so a box's command can read this machine's
|
|
312
373
|
resolver settings (its nameservers and search domains), with no network to use them. Its environment is
|
|
313
374
|
`LANG=C.UTF-8` and `HOME=/tmp` and the image's own: never this server's, so no key or token is in it. It runs as this
|
|
@@ -321,6 +382,8 @@ go through `work/` by path.
|
|
|
321
382
|
- `bash` takes pi's `{command, timeout?}`, `timeout` in seconds, 300 when the call names none; a timeout kills the
|
|
322
383
|
command's process group in the container. Its answer is its output's last 2,000 lines or 50 KB. Each call is a fresh
|
|
323
384
|
shell in `work/`.
|
|
385
|
+
- A command that should outlive one call (a server, a watcher, a long build) goes in the background instead
|
|
386
|
+
([background processes](#background-processes)).
|
|
324
387
|
- It has no capability and can gain none (`--cap-drop ALL`, `--security-opt no-new-privileges`), so even as root (a
|
|
325
388
|
server run as uid 0) it cannot make a device node in `work/`. Its Docker daemon must be this machine's: where
|
|
326
389
|
`DOCKER_HOST`, or the docker context, names another machine (tcp://, ssh://), no box is made, since that daemon would
|
|
@@ -331,6 +394,45 @@ go through `work/` by path.
|
|
|
331
394
|
`work/`) and when the run is archived. A start destroys every such container whose run has ended or is archived; one
|
|
332
395
|
of a run this data directory does not know is left to its 24-hour lifetime.
|
|
333
396
|
|
|
397
|
+
### Background processes
|
|
398
|
+
|
|
399
|
+
An agent whose place is a sandbox may also name `bash_background`, `bash_output`, `bash_input`, `bash_signal` and
|
|
400
|
+
`bash_list`, to run a command that outlives one call: a dev server, a watcher, a long build, a program that reads its
|
|
401
|
+
input as it goes. Each call is one short command in the run's box, on the same path as `bash`, so they work on every box
|
|
402
|
+
`bash` runs on, the permission gate takes each call as it takes `bash`'s, and nothing new runs on this server.
|
|
403
|
+
|
|
404
|
+
- `bash_background {command}` starts the command from `work/`, in a fresh shell (`bash`, else `sh`) under a session of
|
|
405
|
+
its own (`setsid`, its runner under `nohup`), and answers its id (`"1"`, then `"2"`, and on) at once. Its stdout and
|
|
406
|
+
stderr go together to `work/background/<id>/output.log`, beside `command`, `started`, `pid` (its process group) and,
|
|
407
|
+
once it ends, `exit` (its code; 128 + n for signal n). The run's files show them (`GET /v2/runs/{id}/files`), so the
|
|
408
|
+
console and the API show each log, during the run and after it.
|
|
409
|
+
- Those files are for people to read: the run's own file tools can write anything in `work/`, so no call trusts one.
|
|
410
|
+
The group a signal goes to, the exit code, the start time, the command and the run's-end mark are kept in the box's
|
|
411
|
+
own directory (its `TMPDIR`, else `/tmp`), out of `work/`; a copy in `work/` is written in that directory and moved
|
|
412
|
+
over its name from inside `work/background/<id>`, entered and checked by its real path, so a link planted at the name
|
|
413
|
+
or at the directory is never followed (a failed check skips the copy). `output.log` is opened first and then checked as opened
|
|
414
|
+
(through `/proc`: the file reached is `work/background/<id>/output.log` itself, by its real path, and a regular file),
|
|
415
|
+
and every read is of that open file, so a link swapped in after the check is never read. A link planted at it is
|
|
416
|
+
refused, saying so; so is any log in a box with no `/proc` to check it by. A directory made in `work/background/` that this box
|
|
417
|
+
did not start reads as gone, and is never signalled.
|
|
418
|
+
- A process runs until no live process of its group is left: a child the command starts with `&` (a server, its
|
|
419
|
+
output sent elsewhere) keeps it running, counted against the cap, signalled with it and ended at the run's end; its
|
|
420
|
+
exit code is the shell's.
|
|
421
|
+
- At most 8 run at once in a run's box: a ninth start is refused, saying so, until one ends. Each log keeps the first
|
|
422
|
+
16 MiB of the output; later output is dropped while the process runs on, and `bash_output` says so.
|
|
423
|
+
- `bash_output {id, offset?, max_bytes?}` reads the log from a byte offset (0 when absent), at most 48 KiB a call (the
|
|
424
|
+
default), never splitting a character (a page too small for the character it starts at is refused, saying so): whether the process still runs, its exit code once it ended, the log's size,
|
|
425
|
+
and the offset to read from next. Once it says the process ended, the log is whole.
|
|
426
|
+
- `bash_input {id, text, close?}` writes `text` to the process's stdin as given (end a line with `\n`), at most 64 KiB a
|
|
427
|
+
call; `close: true` closes its stdin after it, so the process reads the end of its input. The stdin is a fifo in the
|
|
428
|
+
box's `TMPDIR` (else `/tmp`), never in `work/`.
|
|
429
|
+
- `bash_signal {id, signal}` sends the process's group `TERM`, `INT` or `KILL`, and answers its state after up to 2 s.
|
|
430
|
+
- `bash_list` names each process: running or how it ended, its output's size, when it started and its command's start
|
|
431
|
+
(every running one, then the newest that ended, 40 at most).
|
|
432
|
+
- The run's end ends them: before its box is copied back and destroyed, the server sends each running group `TERM`,
|
|
433
|
+
then `KILL` after 3 s, and marks each with `ended` beside its log, which stays in the run's files; the server's log says
|
|
434
|
+
`background_ended` with how many. A follow-up's box starts with none running, and its ids go on from the last.
|
|
435
|
+
|
|
334
436
|
### A run in a Daytona box
|
|
335
437
|
|
|
336
438
|
With `AGENTRUN_BOXES=daytona` and `DAYTONA_API_KEY`, a run whose place is `{"mode": "sandbox", "box": "daytona"}` gets one
|
|
@@ -344,9 +446,25 @@ since nothing binds `work/` there):
|
|
|
344
446
|
the key to the calls a run's tools make of their own sandbox (a read of it, and its toolbox's programs and files). It
|
|
345
447
|
refuses every other call (a create, a listing, a stop, a delete, another run's sandbox or token, any other host), and
|
|
346
448
|
it never follows a redirect, nor does the server's own Daytona client: a redirect would carry the key.
|
|
347
|
-
-
|
|
348
|
-
|
|
349
|
-
|
|
449
|
+
- It reaches the hosts `AGENTRUN_BOX_ALLOW` names, and no other: Daytona's domain list (`domainAllowList`), which
|
|
450
|
+
Daytona's egress proxy enforces. Unset or empty, the list is the package registries and GitHub: `pypi.org`,
|
|
451
|
+
`files.pythonhosted.org`, `registry.npmjs.org`, `registry.yarnpkg.com`, `github.com` and `codeload.github.com`. A
|
|
452
|
+
comma list of hosts (a `*.` wildcard allowed, at most 100) replaces it, so to add one, copy this list and extend it.
|
|
453
|
+
`AGENTRUN_BOX_ALLOW=none` blocks its network (`networkBlockAll`), as before the list. `*`, an IP address, a CIDR, a
|
|
454
|
+
port or a URL refuses the start. Capabilities show the hosts in `places.allow`, and the box's `network` (`allowlist` or
|
|
455
|
+
`none`) in its `places.boxes` entry. Daytona's proxy re-signs each TLS connection with Daytona's own CA, which the
|
|
456
|
+
sandbox's environment names to pip, npm, git and curl (`REQUESTS_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`, `GIT_SSL_CAINFO`,
|
|
457
|
+
`CURL_CA_BUNDLE`, `SSL_CERT_FILE`).
|
|
458
|
+
- A sandbox whose own read does not carry the list it was asked for is deleted. Daytona takes a domain list on its tier 3
|
|
459
|
+
and 4 only: where it keeps none, or refuses it, the server makes the run's box again with its network blocked, never
|
|
460
|
+
open, and makes every later Daytona box that way until it starts again. The log says so once, with Daytona's own
|
|
461
|
+
words (`event=box_network box=daytona network=none refused=<code> message="…"`), and capabilities show the box's
|
|
462
|
+
`network` as `none` with its `network_reason`. A box the server finds is kept when it has no network, or the list the
|
|
463
|
+
setting names now (the same hosts, in any order, as Daytona reads them back); any other (a wider or narrower list, a
|
|
464
|
+
list when the setting is `none`) is destroyed and made again, so a changed list holds for a run's box after a restart.
|
|
465
|
+
- A sandbox Daytona does not report blocked, when blocked was asked, is deleted, and the tool call fails saying so. An
|
|
466
|
+
organization on Daytona's tier 1 or 2 keeps its own network policy, which a sandbox cannot override, so a run there
|
|
467
|
+
gets no Daytona box unless that policy blocks it.
|
|
350
468
|
- A sandbox cannot bind `work/`. The server copies `work/` into it at `/run/agentrun/run/work` when it makes it, and
|
|
351
469
|
copies what changed back at each turn's end (a read of the run's files waits for that copy) and once more before the
|
|
352
470
|
run's end is recorded. Daytona's answer is never trusted: the copy back writes regular files and directories only,
|
|
@@ -373,22 +491,52 @@ since nothing binds `work/` there):
|
|
|
373
491
|
what only it holds stays.
|
|
374
492
|
- The sandbox is Daytona's default snapshot, made as its user, with `sudo -n` making `/run/agentrun/run/work`.
|
|
375
493
|
|
|
494
|
+
### A run in a Modal sandbox
|
|
495
|
+
|
|
496
|
+
With `modal` listed in `AGENTRUN_BOXES`, its token set and its SDK installed, a run whose place is
|
|
497
|
+
`{"mode": "sandbox", "box": "modal"}` gets one Modal sandbox, made on its first `read`, `write`, `edit` or `bash` call. It
|
|
498
|
+
is Modal's default sandbox runtime (gVisor), not a virtual machine: the server does not ask Modal for its VM runtime. It works like a
|
|
499
|
+
[Daytona box](#a-run-in-a-daytona-box): the same tools, path rules, environment and labels, and its `read`, `write` and
|
|
500
|
+
`edit` run in the sandbox too. What differs:
|
|
501
|
+
|
|
502
|
+
- The token and the SDK's client are this server's alone. The server makes the sandbox, copies `work/` into it at
|
|
503
|
+
`/run/agentrun/run/work`, copies what changed back at each turn's end and once more before the run's end is recorded,
|
|
504
|
+
and ends it after that last copy, at the run's end, a cancel included, and at an archive. The copy rules (no link,
|
|
505
|
+
nothing outside `work/`, a file this server changed stays as it has it) are Daytona's.
|
|
506
|
+
- The run's process holds no token. Its calls to its sandbox go through the server's box relay, on loopback, with that
|
|
507
|
+
run's own door token. The relay makes only the calls a run's tools make of their own sandbox, with the server's
|
|
508
|
+
client: finding it, reading its state and tags, and starting a program in it with that program's input, output and
|
|
509
|
+
exit. It refuses everything else: a create, a listing, an end, a tag change, or another run's sandbox or program.
|
|
510
|
+
- It has no network, whatever `AGENTRUN_BOX_ALLOW` names. The provider takes a domain list when a sandbox is made, but
|
|
511
|
+
its SDK cannot read a sandbox's list back, so this server cannot check that a box holds the list it asked for (as it
|
|
512
|
+
does for Daytona). Each box is made with its network blocked, never with the provider's open default. Capabilities
|
|
513
|
+
show the box's `network` as `none`, with `network_reason`, unless the setting is `none`.
|
|
514
|
+
- A sandbox that is gone (it ended, or its lifetime ran out) is made again on the run's next tool call and seeded
|
|
515
|
+
with the run's `work/`. The call that met the gone box fails, saying so.
|
|
516
|
+
- Each Modal sandbox reserves 2 CPUs and 4 GiB of memory by default, which the provider bills for while the box lives:
|
|
517
|
+
the Docker box's defaults, asked of the provider as the sandbox's CPU and memory. `AGENTRUN_BOX_CPUS` and
|
|
518
|
+
`AGENTRUN_BOX_MEMORY` change both boxes alike (such as `AGENTRUN_BOX_CPUS=1 AGENTRUN_BOX_MEMORY=1g`). The provider has
|
|
519
|
+
no process limit, so `AGENTRUN_BOX_PIDS` does not apply. Its lifetime is 24 hours, as every box's is.
|
|
520
|
+
- A start copies back, then ends, the sandbox of every run that has ended or is archived.
|
|
521
|
+
|
|
376
522
|
### The box's image
|
|
377
523
|
|
|
378
524
|
A Docker box starts from this server's own image by default: `agentrun-box`, python 3.12 (`python:3.12-slim`, pinned by
|
|
379
|
-
its digest) with git, curl, node (Debian's `nodejs
|
|
525
|
+
its digest) with git, curl, node and npm (Debian's `nodejs` and `npm`), rg (`ripgrep`), `socat` (the relay to the box's
|
|
526
|
+
network proxy, when it has one) and their certificates, about 360 MB. Its
|
|
380
527
|
recipe is `BOX_RECIPE` in `src/box-image.ts`, its base `BOX_BASE` there. The server builds it on first use
|
|
381
528
|
(`docker build`, at most 10 minutes, its context a private directory under `TMPDIR` holding the recipe alone as its
|
|
382
529
|
`Dockerfile`, removed after), tags it with the recipe's hash (`agentrun-box:<12 hex>`) and labels it with the whole hash
|
|
383
530
|
(`agentrun.box-image`), and builds again only when the recipe changes: a start that finds the image with this recipe's
|
|
384
531
|
hash uses it. To move the base, read the tag's index digest again from Docker Hub (the comment beside `BOX_BASE` says
|
|
385
532
|
how) and put it there: the recipe's hash changes, and so does the image's tag, so the next start builds it. The build
|
|
386
|
-
reaches the network, for the base image and apt; a box made from it never does (`--network none`). A build that fails
|
|
533
|
+
reaches the network, for the base image and apt; a box made from it never does through Docker's (`--network none`). A build that fails
|
|
387
534
|
leaves the box unavailable with the reason ([Boxes](#boxes)). Images of older recipes stay until you remove them:
|
|
388
535
|
`docker image ls --filter label=agentrun.box-image` lists them all, and `docker image rm agentrun-box:<12 hex>` removes
|
|
389
536
|
one.
|
|
390
537
|
|
|
391
|
-
A box
|
|
538
|
+
A box reaches its package registries (on Linux), so `pip install` and `npm install` work in it, but not `apt-get`: the
|
|
539
|
+
box runs as this server's user, with no root. For other tools, name another image
|
|
392
540
|
in `AGENTRUN_DOCKER_IMAGE`: the server then pulls it when Docker has none (at most 10 minutes) and builds nothing.
|
|
393
541
|
This image, its build and the wait for it are the Docker box's alone: a Daytona box is made by the server from
|
|
394
542
|
Daytona's own image, and a Daytona run never waits on this one.
|
|
@@ -414,7 +562,7 @@ inside the image itself (bwrap, on Linux) comes in a later release.
|
|
|
414
562
|
|
|
415
563
|
### Boxes
|
|
416
564
|
|
|
417
|
-
A box is a machine apart from this one where a run's tools run. Runs execute in `docker` and `
|
|
565
|
+
A box is a machine apart from this one where a run's tools run. Runs execute in `docker`, `daytona` and `modal` boxes
|
|
418
566
|
([place](#place)); the others are set up and probed, and say runs in them are not available yet. `AGENTRUN_BOXES` lists the boxes to set up, as a comma list of the ids below
|
|
419
567
|
(`AGENTRUN_BOXES=docker,daytona`). The server never probes a box the list does not name, and a name that is no box
|
|
420
568
|
refuses the start. At start the server probes each listed box once. The probes run at once, each within 5 s. Then one
|
|
@@ -433,9 +581,9 @@ provider's answer.
|
|
|
433
581
|
Then the server asks Docker for [the box's image](#the-boxs-image) (`docker image inspect`). When Docker has it (the
|
|
434
582
|
default with this recipe's hash), the box is `ready`. When not, the server builds the default, or pulls the image
|
|
435
583
|
`AGENTRUN_DOCKER_IMAGE` names, once, in the background, for at most 10 minutes. Meanwhile the box is available and
|
|
436
|
-
`preparing` (`building the box image (python, git, curl, node, rg)`, or `pulling <image>`), and a sandbox run whose
|
|
584
|
+
`preparing` (`building the box image (python, git, curl, node, npm, rg)`, or `pulling <image>`), and a sandbox run whose
|
|
437
585
|
first box comes then waits for the image, with one row on its timeline (`Preparing the box image: building it (python,
|
|
438
|
-
git, curl, node, rg)…`), instead of a first tool call that pulls it silently. A build or pull that fails is tried once
|
|
586
|
+
git, curl, node, npm, rg)…`), instead of a first tool call that pulls it silently. A build or pull that fails is tried once
|
|
439
587
|
more, 5 seconds later, the box `preparing` meanwhile with what failed (`trying once more: the build of the box image
|
|
440
588
|
could not reach the network (…)`). One that fails again, or takes longer, makes the box unavailable with the reason
|
|
441
589
|
(the build could not reach the network, pull its base or install a package, ran out of disk; the registry refused the
|
|
@@ -448,7 +596,7 @@ provider's answer.
|
|
|
448
596
|
The probe makes one authenticated read, of a box that does not exist. If Daytona refuses the key, the box is unavailable.
|
|
449
597
|
- `modal`: needs `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` and the SDK, which the host installs (`npm install modal`).
|
|
450
598
|
Its sandboxes live in the app that `AGENTRUN_BOX_APP` names (default `agentrun`). The probe checks that the SDK loads
|
|
451
|
-
and the token is set. It asks nothing of the provider.
|
|
599
|
+
and the token is set. It asks nothing of the provider. Runs execute in it: [a run in a Modal sandbox](#a-run-in-a-modal-sandbox).
|
|
452
600
|
- `bwrap` is not in this release yet.
|
|
453
601
|
|
|
454
602
|
The boxes come from `@parcha/pi-transport`, an optional peer of this package; install it beside the server to use any.
|
|
@@ -535,17 +683,22 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
|
|
|
535
683
|
| `write` | Write a file in the run's `work/` | nothing | yes, no |
|
|
536
684
|
| `edit` | Edit a file in the run's `work/` | nothing | yes, no |
|
|
537
685
|
| `bash` | Run a shell command in the run's box, from its `work/`: pi's `{command, timeout?}`, 300 s when the call names no timeout | an agentic definition whose place is a sandbox ([Sandbox](#sandbox)) | no, no |
|
|
686
|
+
| `bash_background` | Start a shell command in the background in the run's box, from its `work/`, and answer its id at once: `{command}` in. Its stdout and stderr go to `work/background/<id>/output.log`, the first 16 MiB; at most 8 run at once ([background processes](#background-processes)) | an agentic definition whose place is a sandbox | no, no |
|
|
687
|
+
| `bash_output` | Read a background process's output from a byte offset: `{id, offset?, max_bytes?}` in (at most 48 KiB a call), its state, exit code, the log's size and the next offset out | an agentic definition whose place is a sandbox | no, no |
|
|
688
|
+
| `bash_input` | Write to a running background process's stdin: `{id, text, close?}` (at most 64 KiB a call) | an agentic definition whose place is a sandbox | no, no |
|
|
689
|
+
| `bash_signal` | Send a background process's group `TERM`, `INT` or `KILL`: `{id, signal}` | an agentic definition whose place is a sandbox | no, no |
|
|
690
|
+
| `bash_list` | List the run's background processes: id, state or exit code, output size, start time and command | an agentic definition whose place is a sandbox | no, no |
|
|
538
691
|
| `ask_person` | Ask the person who started the run; the turn ends until a message answers | nothing | no, no |
|
|
539
692
|
| `web_fetch` | Read one web page from a public host through the guarded direct fetch, or through Parallel's extract where Parallel is picked ([search and fetch](#search-and-fetch)), a part at a time: `{url, offset?, max_chars?}` in, a Page out, `{ok, url, status, title, text, chars, truncated?, original_chars?, beyond_read?, offset?, next_offset?, html_chars?, converted?, links, links_omitted?, via, parallel?, refused?, error?}` | nothing (`PARALLEL_API_KEY` for Parallel, one billed extract a page a run) | yes, yes |
|
|
540
693
|
| `web_search` | Search the web, natively where the harness or the model's provider can, else through Parallel where the server holds its key, else keyless through Exa, or through the provider picked ([search and fetch](#search-and-fetch)): `{query, n?}` in, `{provider, query, results: [{url, title, snippet, published?}], text?}` or `{error}` out | nothing (`PARALLEL_API_KEY` for Parallel) | yes, yes |
|
|
541
|
-
| `browser` | A
|
|
694
|
+
| `browser` | A hosted browser, Browserbase's or Kernel's, on pi-browser's durable adapter: `snapshot`, `run`, `screenshot`, `browser_read`, `browser_release`, `browser_relaunch`, `browser_downloads` and `browser_upload` (into and from the run's `work/`); Kernel keeps no downloads, so a run on Kernel has no `browser_downloads` | `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`, or `KERNEL_API_KEY` | yes, no |
|
|
542
695
|
| `monid.discover` | Search monid's catalog of paid data endpoints in plain words: `{query, limit?, minScore?}` in, `{results: [{provider, endpoint, description, score, price}]}` out | `MONID_API_KEY` | no, no |
|
|
543
696
|
| `monid.inspect` | One monid endpoint before it runs: `{provider, endpoint}` in, the JSON Schemas of its input (`pathParams`, `queryParams`, `body`), its price, notes and documentation out | `MONID_API_KEY` | no, no |
|
|
544
697
|
| `monid.run` | Run one monid endpoint, paid per call from the monid wallet: `{provider, endpoint, input}` in, the run's `output`, `price` and `cost` out | `MONID_API_KEY` | no, no |
|
|
545
698
|
| `pdf_pages` | A workflow call only: `{path, maxPages?, dpi?}` in, `{name, pageCount, dpi, pages: [{page, image}], text}` out. Draws a document's first pages (3 by default, at 110 dpi) as PNGs under the run's `work/pages/<stem>/<dpi>/` (`<stem>`: the document's path below its directory made one name, with a short hash, so two documents of one file name never share pages), the dpi lowered so a page's long side is at most 1568 px, with its text (`pdftotext`, cut at 20,000 characters). A PNG or JPEG passes through as one page, scaled down to 1568 px. `path` is under `--documents` or the run's `work/`, never outside | `pdftoppm`, `pdftotext` | no, yes |
|
|
546
699
|
| `llm` | A workflow call only: `{prompt, system?, maxTokens?, tier?}` in, `{text, model, usage, cost_usd}` out. One completion on the run's model of the tier (`default`; a tier the state fills in, such as `"{requestedTier}"`, may be any of the three, and a tier with no model fails the call), no tools and no loop; `cost_usd` is null when the model has no price, never 0 | a model | no, yes |
|
|
547
700
|
|
|
548
|
-
`bash`
|
|
701
|
+
`bash` and the background tools run only in a box: a runner agent, and a workflow, get no shell on this machine (see [Safety](#safety)). In a
|
|
549
702
|
sandbox place `read`, `write` and `edit` run in the box too. `fetch_page` is a legacy name for `web_fetch`: a
|
|
550
703
|
revision, a model node or a call node that names it still saves and runs, and gets `web_fetch` under that name (the
|
|
551
704
|
same Page with `via`, resolved as `web_fetch` is: the guarded fetch, Parallel only where picked). The table lists it no
|
|
@@ -585,7 +738,8 @@ On another harness, every host tool's result reaches the model within the host's
|
|
|
585
738
|
(`HOST_RESULT_MAX_CHARS`, `@parcha/agentrun-kernel`): the kernel's tool bridge cuts a longer one, its start with a line
|
|
586
739
|
saying where it was cut, and flags the call `truncated`. Each CLI adapter tells its CLI to pass a result that long to
|
|
587
740
|
the model whole: the Claude Agent CLI would otherwise save a result past 50,000 characters to a file and tell the model
|
|
588
|
-
to read it, which a run's confinement refuses,
|
|
741
|
+
to read it, which a run's confinement refuses, Codex keeps only the ends of a result past 10,000 tokens, and OpenCode
|
|
742
|
+
would cut one past 2,000 lines or 51,200 bytes and save the rest to a file the session has no tool to read. A
|
|
589
743
|
`web_search` answer past 100,000 characters leaves out its least relevant results, `omitted` counting them.
|
|
590
744
|
|
|
591
745
|
### Search and fetch
|
|
@@ -615,14 +769,17 @@ unavailable for a workflow.
|
|
|
615
769
|
| `web_fetch`, `kernel` (the default) | the guarded direct fetch | the same | the same |
|
|
616
770
|
| either, `parallel` | Parallel's search and extract, host tools | the same | the same |
|
|
617
771
|
|
|
618
|
-
`GET /settings/tools` answers the server's settings, `{web_search: {provider}, web_fetch: {provider}}`, the default
|
|
772
|
+
`GET /settings/tools` answers the server's settings, `{web_search: {provider}, web_fetch: {provider}, browser: {provider}}`, the default
|
|
619
773
|
where none is set; `PUT /settings/tools` takes the same map and replaces it (a capability it leaves out takes its
|
|
620
774
|
default). An agent's `definition.tool_settings` has the same shape and is over the server's. A provider is one offered
|
|
621
|
-
for its capability (`auto`, `native`, `exa-keyless` or `parallel` for `web_search`; `kernel` or `parallel` for `web_fetch
|
|
622
|
-
|
|
623
|
-
|
|
775
|
+
for its capability (`auto`, `native`, `exa-keyless` or `parallel` for `web_search`; `kernel` or `parallel` for `web_fetch`;
|
|
776
|
+
`auto`, `browserbase`, `kernel` or `chrome` for `browser`, [below](#tools)); an
|
|
777
|
+
unknown capability or provider is `422`. Any tool's settings also take a `permission`, `allow`, `ask` or `deny`, which the
|
|
778
|
+
tool gate holds every call to (an ask parks the run for the owner's approval); a workflow's call node, which cannot wait
|
|
779
|
+
for an approval, refuses its run when its tool is set to ask or deny (`409`, `details.asks` or `details.denied`). The
|
|
780
|
+
settings are kept in the data directory
|
|
624
781
|
(`tool-settings.json`, 0600, written whole and durably), not a secret, and read by every run launched from then on.
|
|
625
|
-
`GET /capabilities` is the one tool catalog: each of the
|
|
782
|
+
`GET /capabilities` is the one tool catalog: each of the three tools there gives the providers offered (`providers`), the
|
|
626
783
|
server's (`provider`, its default where it sets none), the built-in default (`default_provider`) and `resolves`, what it
|
|
627
784
|
resolves to on each harness under the server's settings and default model (`native`, `kernel`, `exa-keyless`,
|
|
628
785
|
`parallel`, or `unavailable: <reason>`), with `why`, keyed the same, one plain sentence for each (`Codex's own search`,
|
|
@@ -640,6 +797,10 @@ Parallel key gone since makes Parallel unavailable, never another provider), and
|
|
|
640
797
|
description with no secret in it (`AGENTRUN_SERVE_TOOL_PLANE`); the run reads its providers there, never from a request.
|
|
641
798
|
A workflow's tools are those its revision lists and those its model and call nodes name.
|
|
642
799
|
|
|
800
|
+
Upgrading to the tool gate: a workflow whose call node's tool is set to ask, by a setting or a default, now refuses its
|
|
801
|
+
run (`409` with `details.asks`); set that tool to allow for the agent (`definition.tool_settings`). Built-in tools are
|
|
802
|
+
allowed by default; catalog (`monid.*`) and MCP tools, which ask by default, are no call node's tools here.
|
|
803
|
+
|
|
643
804
|
Upgrading: a server holding `PARALLEL_API_KEY` used to read every `web_fetch` page through Parallel's extract on its own.
|
|
644
805
|
Now `web_fetch` is the guarded direct fetch unless Parallel is picked; to keep the old behaviour, set
|
|
645
806
|
`PUT /v2/settings/tools {"web_fetch": {"provider": "parallel"}}` once (or `tool_settings` in an agent). Parallel's key reaches an agentic run only when one of its capabilities resolves to Parallel (see
|
|
@@ -698,7 +859,7 @@ read 2026-11-03), an estimate: a `fast` search $0.001 for up to 10 results and $
|
|
|
698
859
|
$0.001 a URL; on a 4xx other than a 408 nothing (Parallel refused it), and on a 408, a 5xx, a timeout or a lost
|
|
699
860
|
connection its price (Parallel may have billed it). Under a [spend cap](#spend-cap) each is a paid call: sent only when
|
|
700
861
|
what the run has spent and holds, plus its price, fits the cap. Otherwise nothing reaches Parallel: a search answers the
|
|
701
|
-
cap's refusal (`spend_cap_reached:
|
|
862
|
+
cap's refusal (`spend_cap_reached: Not sent: the run has spent $0 of its $0.0009 cap, and Parallel's search could cost up to $0.001 …`) and a page is the
|
|
702
863
|
guarded direct fetch, with `parallel` giving the same words. One sent holds its price until Parallel answers: a model
|
|
703
864
|
request checked meanwhile, from any branch, tool round or harness, counts it beside what the run has spent, so the two
|
|
704
865
|
never pass the cap together. A workflow's `call` node naming either tool is booked the same way, under the node's own
|
|
@@ -715,12 +876,84 @@ snippet of at most 3,000 characters and its date when Exa knows it, then a line
|
|
|
715
876
|
relies on. Keyless Exa is the default for a harness with no native search when the server holds no Parallel key; `off`
|
|
716
877
|
turns `web_search` off, keyless Exa included.
|
|
717
878
|
|
|
718
|
-
The `browser` tool runs
|
|
719
|
-
|
|
879
|
+
The `browser` tool runs hosted sessions, at Browserbase or at Kernel, never a Chrome on this machine. Which one is
|
|
880
|
+
picked like `web_search`'s provider: the agent's own (`definition.tool_settings.browser.provider`) over the server's
|
|
881
|
+
(`PUT /settings/tools`), one of `auto` (the default), `browserbase`, `kernel` and `chrome`. `auto` is Browserbase where
|
|
882
|
+
the server holds its keys (`BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`), else Kernel where it holds
|
|
883
|
+
`KERNEL_API_KEY`, else unavailable, saying which keys would do. A vendor picked is that vendor alone: without its key
|
|
884
|
+
it is unavailable, never the other one. `chrome`, a Chrome on the server's own host, is in the list but not set up on
|
|
885
|
+
any server yet: it reads unavailable (`a local Chrome is not set up on this server`), and a run that would get it is
|
|
886
|
+
`409`. Capabilities' `tools[]` give the browser's providers, the server's pick and what it resolves to; a run keeps the
|
|
887
|
+
vendor its first launch resolved for its life, and one whose vendor's key is gone since is refused each browser call,
|
|
888
|
+
saying why. Kernel's browsers run headless, and keep no downloads, so a run on Kernel has no `browser_downloads`. The keys come from the server's environment or Tool keys and reach the
|
|
889
|
+
run's process over its pipe, as the rest do. A session's custody (its lease, its tag, what it was
|
|
720
890
|
doing) is kept in the run's own store, so a run opened again on its directory reconciles the sessions it held. Each
|
|
721
891
|
page it reads is filed under the run's `work/evidence/`, each read in a file of its own (`0001-browser_read.md`, ...),
|
|
722
892
|
reads at once included. There is no recording and no live view. When the run is let go (its work done, or a SIGTERM)
|
|
723
|
-
the sessions it still holds are released at
|
|
893
|
+
the sessions it still holds are released at their vendor. An agent's browser stays signed in from one run to the next
|
|
894
|
+
([saved sign-ins](#saved-sign-ins)).
|
|
895
|
+
|
|
896
|
+
A session's time is the run's spend, as a paid tool's charge is: each browser call books what its session ran since the
|
|
897
|
+
last charge, and the release books the rest, topped up to the provider's minimum. Each is a `Tool cost` line of its own
|
|
898
|
+
on the run's timeline, part of its `cost.usd`, and `/usage`'s `browser_time` meter (dollars, and seconds once the run has
|
|
899
|
+
ended). Prices are by provider (pi-browser's provider name):
|
|
900
|
+
|
|
901
|
+
| Provider | List price | Minimum | Its own price |
|
|
902
|
+
| --- | --- | --- | --- |
|
|
903
|
+
| `browserbase` | $0.12 an hour | 60 s | `AGENTRUN_BROWSER_USD_PER_HOUR_BROWSERBASE` |
|
|
904
|
+
| `kernel` (headless) | about $0.06 an hour, by the second | none | `AGENTRUN_BROWSER_USD_PER_HOUR_KERNEL` |
|
|
905
|
+
| `cdp` (a local Chrome) | $0 | none | `AGENTRUN_BROWSER_USD_PER_HOUR_CDP` |
|
|
906
|
+
|
|
907
|
+
A variable gives the provider's price in US dollars an hour (a contract rate; the minimum stays). A provider with no price,
|
|
908
|
+
or a variable that is not a non-negative decimal, has no price: its time is booked as an unknown cost, and under a cap
|
|
909
|
+
every browser call is refused. Under a cap the browser's time is held before it runs (see [Spend cap](#spend-cap)).
|
|
910
|
+
|
|
911
|
+
### Saved sign-ins
|
|
912
|
+
|
|
913
|
+
Sign in once in one of an agent's runs (for now, through the run's browser while it runs), and every later run of that
|
|
914
|
+
agent starts from that signed-in browser. Sign-ins are kept per agent, never shared between agents, and the server
|
|
915
|
+
picks which one a run gets, never the model.
|
|
916
|
+
|
|
917
|
+
- **Where the cookies are.** At the browser's vendor: a Browserbase context, or a Kernel profile under a random name
|
|
918
|
+
(`agentrun-` and 24 hex digits: Kernel's names are its account's, so a name derived from the agent would be any
|
|
919
|
+
server's that shares the key). This
|
|
920
|
+
server keeps only a pointer per agent and vendor, sealed under the seal key (`AGENTRUN_SEAL_KEY`) and bound to its
|
|
921
|
+
agent, in `<data>/homes/<key>/sign-ins/sign-ins.json`. With no seal key nothing is kept and runs start signed out;
|
|
922
|
+
capabilities say `sign_ins: true` only with a seal key and a browser vendor here. A local Chrome keeps none: its
|
|
923
|
+
cookies would sit on this server's disk.
|
|
924
|
+
- **How a run gets it.** Before a run with the `browser` tool is launched, the server makes the agent's context at
|
|
925
|
+
Browserbase (`POST /v1/contexts`, which opens no session; Browserbase bills sessions, not contexts) or its profile at
|
|
926
|
+
Kernel (`POST /profiles`, which starts no browser) if it has none,
|
|
927
|
+
and hands the run's process the pointer over its pipe, with its secrets, never in its environment. The run's process
|
|
928
|
+
never gets the seal key. Every session the run opens uses that profile, by the name `default`; the model never sees
|
|
929
|
+
the pointer. A vendor that does not answer leaves that run's browser signed out, said in the server's log.
|
|
930
|
+
- **One run saves at a time.** The first run of an agent to start with the browser holds the sign-in's save lease, and
|
|
931
|
+
its sessions save what changed (Browserbase `persist`, Kernel `save_changes`). A run of the same agent started while
|
|
932
|
+
another holds it starts signed in and saves nothing. The lease ends when its run ends (completed, failed or
|
|
933
|
+
cancelled) or lets go cleanly to wait for its person. A run whose process went, or a server restart, keeps it with
|
|
934
|
+
the run for its relaunch, since a session it opened before may still write back at the vendor, but for no longer than
|
|
935
|
+
such a session can live (pi-browser's session timeout, 30 minutes) while its process stays gone: a run that waits on
|
|
936
|
+
its person after its process died, or is never opened again, lets the others save after that. A run whose process
|
|
937
|
+
went without letting its sessions go keeps the lease that way even once it ends. Each launch decides again whether
|
|
938
|
+
its run saves: a follow-up of a run that saved, opened while another run holds the lease, saves nothing. One that names a run
|
|
939
|
+
that ended while the server was down counts as let go. Browserbase writes a saved context back a few seconds after
|
|
940
|
+
its session ends, so a Browserbase saver's lease stays named for it 10 seconds past its end (a bound this server
|
|
941
|
+
chose; Browserbase publishes none): a run started in that time starts from the context as it was, and saves nothing
|
|
942
|
+
over it, and the saver itself, resumed in that time, waits it out before it saves again. A gone holder's Browserbase
|
|
943
|
+
lease gets the same 10 seconds past the 30 minutes. A V1 limit: the lease goes to the first run of the agent to
|
|
944
|
+
start with the browser in its tools, whether or not it opens a browser, and stays with it until it ends, so a long
|
|
945
|
+
run that never browses keeps the others of that agent from saving meanwhile.
|
|
946
|
+
- **What you see.** `GET /v2/agents/{id}` lists `sign_ins`: `{key: "default", provider, state, held_by, verified_at}`,
|
|
947
|
+
`held` with the run's id while a run holds the lease, else `ready`; `verified_at` is when a saving session last ended.
|
|
948
|
+
`unreadable` (this server's own state, marked `signins/1` in the served contract) is a pointer that does not open
|
|
949
|
+
under the seal key the server has now (none, or another): runs start signed out, and none is made in its place until
|
|
950
|
+
you forget it, since the vendor's object it points to would be left behind. Its `held_by` still names a run that
|
|
951
|
+
holds its lease, as a held one does.
|
|
952
|
+
Never the pointer. `DELETE /v2/agents/{id}/sign-ins/{key}` forgets one: the vendor's context or profile is deleted,
|
|
953
|
+
then the pointer. A delete the vendor does not answer is said in the answer (`at_vendor: "not_deleted"`), and the
|
|
954
|
+
pointer goes all the same. It is `409 sign_in_held` while a run holds the lease. A run of the agent that is still
|
|
955
|
+
going without the lease keeps the pointer it was handed: once the vendor's object is gone, its later sessions fail. Archiving an agent keeps its
|
|
956
|
+
sign-ins; this server has no route that deletes an agent.
|
|
724
957
|
|
|
725
958
|
`monid.discover`, `monid.inspect` and `monid.run` give an agent [monid](https://monid.ai)'s whole catalog of data
|
|
726
959
|
endpoints on one key, `MONID_API_KEY`: it finds an endpoint in plain words, reads its input schemas and price, and runs
|
|
@@ -756,13 +989,14 @@ the model keys: a run's process gets it over its pipe, never in its environment.
|
|
|
756
989
|
## Tool keys
|
|
757
990
|
|
|
758
991
|
A tool's key comes from one of two places. The server's own environment, through its launcher: `PARALLEL_API_KEY`,
|
|
759
|
-
`MONID_API_KEY` and `
|
|
992
|
+
`MONID_API_KEY`, `BROWSERBASE_API_KEY` and `KERNEL_API_KEY` are among the secrets it hands the server over its pipe. Or the page, by name:
|
|
760
993
|
`PUT /v2/settings/tool-keys/{id}` with `{values: {NAME: "..."}}` saves one, field by field (`parallel` takes
|
|
761
994
|
`PARALLEL_API_KEY`, `monid` `MONID_API_KEY`, `browserbase` `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`,
|
|
762
|
-
`typesafe` `TYPESAFE_API_KEY`, which unlocks Jev's decisions, `decisions.jev`), and `DELETE` forgets it. A model
|
|
995
|
+
`kernel` `KERNEL_API_KEY`, `typesafe` `TYPESAFE_API_KEY`, which unlocks Jev's decisions, `decisions.jev`), and `DELETE` forgets it. A model
|
|
763
996
|
provider's key is saved the same way (`anthropic`, `openai` and `openrouter`, each `kind: "model"`, the others
|
|
764
997
|
`"tool"`): every run gets it, as every run gets the launcher's model keys, and with no `AGENT_MODEL` it gives the
|
|
765
|
-
default model ([models](#models)); its `harnesses` are pi and the provider's
|
|
998
|
+
default model ([models](#models)); its `harnesses` are pi and the harnesses that talk to that provider's API (OpenAI's:
|
|
999
|
+
codex and opencode; OpenRouter's, all four), of
|
|
766
1000
|
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
|
|
767
1001
|
this server cannot run for another reason (not installed, not the pinned build, more than this host's memory). `GET
|
|
768
1002
|
/v2/settings/tool-keys` lists each key, what it unlocks and the harnesses that run that, and each field's `set` and
|
|
@@ -772,20 +1006,28 @@ none of still lists, with nothing in `unlocks`. A field the server is started wi
|
|
|
772
1006
|
it is `409 key_set_by_server`. A value is text of at most 1024 bytes with no control character (`422` otherwise).
|
|
773
1007
|
|
|
774
1008
|
A key is checked against its provider before it is kept, with one call that costs nothing, given 5 s: monid's
|
|
775
|
-
discover of one result, Parallel's list of monitors, Browserbase's list of projects
|
|
776
|
-
`BROWSERBASE_BASE_URL` or `TYPESAFE_BASE_URL` when the server
|
|
1009
|
+
discover of one result, Parallel's list of monitors, Browserbase's list of projects, Kernel's list of browsers (at most
|
|
1010
|
+
one) and TypeSafe's list of models (at `BROWSERBASE_BASE_URL`, `KERNEL_BASE_URL` or `TYPESAFE_BASE_URL` when the server
|
|
1011
|
+
is started with one). A key the provider refuses (401)
|
|
777
1012
|
is `422 input_invalid`, its field's reason `refused_by_provider`, in plain words with the provider's first sentence
|
|
778
1013
|
(`Monid refused this key (401: Invalid API key format)`) and never any of the key, and nothing is kept: a key saved
|
|
779
1014
|
before stays as it was. Otherwise it is kept, and `GET` gives its row a `check`: `{state: "accepted", at}`, or
|
|
780
1015
|
`{state: "not_checked", reason, at}` when the provider would not answer the check (403: a key scoped away from that
|
|
781
1016
|
call may still work for its tools), did not answer in 5 s, could not be reached, answered a redirect (never followed,
|
|
782
|
-
so the key goes nowhere else) or something else, or has no call that costs nothing.
|
|
783
|
-
|
|
784
|
-
`
|
|
1017
|
+
so the key goes nowhere else) or something else, or has no call that costs nothing. A tool's key the server is
|
|
1018
|
+
started with is checked once as it starts, with the same call, in the background (the start never waits on it): its
|
|
1019
|
+
row's `check` is `accepted`, `not_checked`, or `{state: "refused", reason, at}` (`Browserbase refused
|
|
1020
|
+
BROWSERBASE_API_KEY (401: Unauthorized) when this server started: set the right one where AgentRun starts, then
|
|
1021
|
+
restart it`), and a tool that needs a refused key reads unavailable in capabilities with the same words. `check` is
|
|
1022
|
+
null when the key is not set, or is the server's and its check has not answered yet; a key saved before this server
|
|
1023
|
+
checked keys reads `not_checked`, and is checked when saved again. A model key the server is started with is not
|
|
1024
|
+
checked here: a run on a refused one fails at its first request, saying so. A save of Browserbase's project id alone sends no key, and leaves its
|
|
785
1025
|
check as it was. A save whose check is still waiting when the server begins to close keeps nothing (`503
|
|
786
1026
|
unavailable`, while its connection lasts): the check stops waiting, and the server's lock, released at close, may be
|
|
787
1027
|
another server's by then. Under `--faux` a key is checked only against the fake its runs are given (`fauxMonid`,
|
|
788
|
-
`fauxParallel`, `fauxJev`); with none it is `not_checked`, and nothing reaches the network.
|
|
1028
|
+
`fauxParallel`, `fauxJev`); with none it is `not_checked`, and nothing reaches the network. A key the server starts
|
|
1029
|
+
with is checked under `--faux` only against a check's own fake (`fauxBrowserbase`, `fauxMonidCheck`, `fauxKernel`), so the fakes the runs use see the
|
|
1030
|
+
runs' calls alone; with none, its `check` stays null.
|
|
789
1031
|
|
|
790
1032
|
A saved key is kept only as ciphertext: AES-256-GCM in `DIR/tool-keys.json` (0600), each value bound to its field's
|
|
791
1033
|
name, under the seal key `AGENTRUN_SEAL_KEY`, which only the server opens it with. A run's process never gets the seal
|
|
@@ -809,7 +1051,7 @@ answers once capabilities, a save's checks and a run's checks see the change, in
|
|
|
809
1051
|
key, so a key leaves what each harness offers as it is, and the harnesses are not checked again. A run already
|
|
810
1052
|
running keeps what it was handed; the next run started, or a run's process started again, takes what is saved then.
|
|
811
1053
|
`BROWSERBASE_PROJECT_ID` is on the launcher's list for this, as every field a person may save is. Capabilities name each
|
|
812
|
-
tool's key (`tools[].key`, a `GET /settings/tool-keys` id, `
|
|
1054
|
+
tool's key (`tools[].key`, a `GET /settings/tool-keys` id; for `browser` its vendor's, `kernel` where Kernel is picked or resolved, else `browserbase`), so a page can link a tool's
|
|
813
1055
|
missing names to where its key is saved. `agentrun-serve import` opens the saved keys in its data directory too and
|
|
814
1056
|
cuts each out of what it writes, as it cuts a key-shaped variable of its environment; one that does not open there is
|
|
815
1057
|
not known, so not cut, and the import says so.
|
|
@@ -875,9 +1117,10 @@ method, tool and whether an `Authorization` header came, never its value.
|
|
|
875
1117
|
|
|
876
1118
|
One URL hears of your runs without anyone watching the page. `PUT /v2/settings/webhook` with `{url}` sets it: an `http`
|
|
877
1119
|
or `https` address, with no user or password in it. Loopback and private-network addresses are allowed, so a receiver
|
|
878
|
-
on your own machine or network works. Two kinds of message are POSTed to it: `run.needs_input` when a run comes to
|
|
1120
|
+
on your own machine or network works. Two kinds of message are POSTed to it about runs: `run.needs_input` when a run comes to
|
|
879
1121
|
need its person (`input_required`: an `ask_person` question, or a stopped turn) and `run.ended` when it ends
|
|
880
|
-
(completed, failed or cancelled, once carried back).
|
|
1122
|
+
(completed, failed or cancelled, once carried back). A [schedule](#schedules) whose firing fails sends a third,
|
|
1123
|
+
`trigger.failed`; a server with no triggers never sends one.
|
|
881
1124
|
|
|
882
1125
|
A run's end and its `run.ended` are one durable step. The server chooses the end's time once and gives it to the agent
|
|
883
1126
|
store, so the row's `ended_at` and the message's `webhook-id` name one time. `run.ended` is queued only once the agent
|
|
@@ -922,6 +1165,85 @@ lists the last 50 attempts (`webhook_id`, type, status code, latency, error, whe
|
|
|
922
1165
|
410 turned off sends nothing, a test or a redelivery included (`409 webhook_off`), until a `PUT` sets it again.
|
|
923
1166
|
`DELETE /v2/settings/webhook` removes the webhook and drops its pending messages.
|
|
924
1167
|
|
|
1168
|
+
## Schedules
|
|
1169
|
+
|
|
1170
|
+
A schedule starts an agent's runs with no one there. `POST /v2/triggers` with a `source` and a `target`:
|
|
1171
|
+
|
|
1172
|
+
```json
|
|
1173
|
+
{ "name": "nightly triage",
|
|
1174
|
+
"source": { "kind": "schedule", "cron": "30 1 * * *", "timezone": "America/Los_Angeles" },
|
|
1175
|
+
"target": { "kind": "start_run", "agent_id": "triage", "input": { "content": "Triage last night's issues." },
|
|
1176
|
+
"max_cost_usd": 2 } }
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
A source is a cron line of five fields in an IANA zone (default UTC), `{at}` for one time (the trigger turns itself off
|
|
1180
|
+
after it fires), or `{every_s, start_at?}` for every N seconds, from 60 to a year and a day, on the grid from `start_at`. A time a clock
|
|
1181
|
+
change repeats fires once, at its first pass; one it skips fires at the first time after the gap. Each next time is
|
|
1182
|
+
reckoned from the last nominal one, so a timer that wakes late does not drift. Every run a trigger starts is capped: by
|
|
1183
|
+
the target's `max_cost_usd`, else by the agent's default (its definition's `max_cost_usd`) as it stands when the firing
|
|
1184
|
+
starts. A target with neither is `422`, and a firing that finds neither (the default removed since) fails, so no trigger
|
|
1185
|
+
starts an uncapped run. A workflow agent is refused, since a workflow run's spend is not capped here. Each run's
|
|
1186
|
+
input ends with a line naming the schedule and the time it fired for, in its zone, and the run's `trigger` names the
|
|
1187
|
+
trigger and the firing, in the run's view and in the runs lists (`GET /v2/runs`, `GET /v2/agents/{id}/runs`) alike;
|
|
1188
|
+
a run a caller started has `trigger: null`.
|
|
1189
|
+
|
|
1190
|
+
A firing starts its run once. Its key comes from the trigger and its nominal time, it is recorded `due` in
|
|
1191
|
+
`DIR/triggers.json` (written whole and synced) before its run starts, and the run is started under that key, so a firing
|
|
1192
|
+
a restart drives again finds its run. A firing's key stays bound to that run: when the server stopped while setting the
|
|
1193
|
+
run up, the firing reads `failed` ("The server stopped while setting up the run.") with that run's id, it never fires
|
|
1194
|
+
again, the next firing goes ahead, and `POST /v2/triggers/{id}/fire` is how a person tries it again. While the trigger's last run is active (working, or waiting on a person), a firing
|
|
1195
|
+
is `skipped`, with why; a full server (`429`) keeps it due and tries again. Times missed while the server was down are
|
|
1196
|
+
one `missed` firing with their count, and the schedule goes on from now; the latest of them still fires, once, when it is
|
|
1197
|
+
no older than the trigger's `catchup_window_s` (default an hour; 0, never), marked `catch_up`. Overlap is `skip` alone:
|
|
1198
|
+
a firing while the last run is active (working, or parked waiting on a person) is skipped with why, never queued,
|
|
1199
|
+
because a firing queued behind a parked run would wait as long as the person does. A firing whose run is refused is `failed`, and a webhook set on this server
|
|
1200
|
+
gets a `trigger.failed` message for it (`data: {trigger_id, name, firing_key, nominal_at, error, auto_paused}`, its
|
|
1201
|
+
`webhook-id` made from the firing's key, so a restart never sends it twice). Five failed firings in a row turn the
|
|
1202
|
+
trigger off (`disabled: {reason: "auto_paused"}`); a firing that starts its run resets the count, and so does turning
|
|
1203
|
+
it on again. Run now (below) works on an auto-paused trigger too, and counts toward the streak like any firing: one that
|
|
1204
|
+
starts its run resets it, one that fails adds to it. A trigger whose cron line or zone no longer reads here (after an
|
|
1205
|
+
upgrade of the cron library or of the time zone data) is turned off alone, at a start or when it comes due
|
|
1206
|
+
(`disabled: {reason: "source_unreadable", detail}`), and every other schedule goes on firing; turning it on again takes a
|
|
1207
|
+
new source. A trigger's firings are driven one at a time, in order, so a firing a crash left due settles to its run
|
|
1208
|
+
before the next one's overlap is checked. `PATCH /v2/triggers/{id}` changes it, and
|
|
1209
|
+
`{enabled: false}` pauses it: the time it was off is skipped, not caught up. `POST /v2/triggers/{id}/fire` runs it now,
|
|
1210
|
+
once per `Idempotency-Key` (required): the same key within `limits.idempotency_ttl_s` answers its firing, after the
|
|
1211
|
+
firing has left the history too, and later it is a new firing that a run the key started still answers. `GET /v2/triggers/{id}/firings` lists its last 200 firings.
|
|
1212
|
+
|
|
1213
|
+
### Webhook triggers
|
|
1214
|
+
|
|
1215
|
+
A trigger with `source: {kind: "webhook"}` fires on each request to `POST /v2/hooks/{trigger_id}`: this server's one
|
|
1216
|
+
route with no token. The request is signed by the trigger's own secret under the
|
|
1217
|
+
[Standard Webhooks](https://www.standardwebhooks.com) spec, the one this server's outbound [webhooks](#webhooks) sign
|
|
1218
|
+
with, so a sender uses any of its libraries: `webhook-id` (1 to 255 printable ASCII characters, no space), `webhook-timestamp` (Unix seconds, within 5 minutes of this
|
|
1219
|
+
server's clock either way) and `webhook-signature: v1,<base64 HMAC-SHA256 of "{id}.{timestamp}.{body}">` under the
|
|
1220
|
+
secret's bytes (several, space-separated, and any one may match). The signature is checked on the raw body, as sent and whatever its content type, before
|
|
1221
|
+
anything else. A bad signature, a stale timestamp, an unknown trigger, one that is off and one that is not a webhook's all
|
|
1222
|
+
answer the same `401`, so no trigger id can be found by asking; a body past 256 KiB is `413`.
|
|
1223
|
+
|
|
1224
|
+
The secret, `whsec_` and 32 random bytes in base64, is made with the trigger and shown in the `201` once; no `GET`
|
|
1225
|
+
shows it. It is kept sealed under `AGENTRUN_SEAL_KEY` in `DIR/trigger-secrets.json`, so with no seal key no webhook
|
|
1226
|
+
trigger is made (`409 no_sealing_key`). `POST /v2/triggers/{id}/secret` makes a new one, shown once, and the old one
|
|
1227
|
+
signs nothing from then on. An import cuts these secrets out of what it keeps, and no learning text shows one. A
|
|
1228
|
+
`trigger-secrets.json` that does not read is never written over: until it is fixed or moved away, no webhook trigger is
|
|
1229
|
+
made or rotated (`409 store_unreadable`) and none fires.
|
|
1230
|
+
|
|
1231
|
+
The request's `webhook-id` is its firing's key: the first answers `202` once the firing is recorded, and its run starts
|
|
1232
|
+
after; the same `webhook-id` again, for a day after (even once the firing has left the history of 200), answers `200` with that
|
|
1233
|
+
firing and starts nothing. The agent gets the trigger's input,
|
|
1234
|
+
then the body, cut at 16 KiB, inside `<trigger-payload source="webhook" untrusted>...</trigger-payload>`: whatever the
|
|
1235
|
+
sender wrote is data, not an instruction.
|
|
1236
|
+
|
|
1237
|
+
A trigger's target may also be `{kind: "message_run", run_id, input: {content}}`, with a webhook or a schedule source:
|
|
1238
|
+
each firing sends its input to that run as `POST /v2/runs/{id}/messages` would (a steer, or a follow-up that opens a
|
|
1239
|
+
completed run again), under its own cap. The run must have a cap (`422` on `target.run_id` otherwise, and a firing to a
|
|
1240
|
+
run that has none fails), and a firing never answers a run that waits on its person (a question, an approval, its
|
|
1241
|
+
cap): it is `skipped`, "The run is waiting on a person.", and the run still waits. The firing's key is the message's id in the run's store, which takes
|
|
1242
|
+
one message per id; a firing driven again after a restart first looks for it there, so it sends the message once and
|
|
1243
|
+
never opens a completed run again for one it already has. A firing to a run that is working waits for it (tried every
|
|
1244
|
+
5 s), and a trigger holds at most 20 firings due: past them a webhook event and a run now answer `429 rate_limited`
|
|
1245
|
+
with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
|
|
1246
|
+
|
|
925
1247
|
## What it serves
|
|
926
1248
|
|
|
927
1249
|
| Route | Here |
|
|
@@ -929,11 +1251,12 @@ lists the last 50 attempts (`webhook_id`, type, status code, latency, error, whe
|
|
|
929
1251
|
| `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
|
|
930
1252
|
| `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. |
|
|
931
1253
|
| `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. |
|
|
932
|
-
| `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. A field the store does not keep (`input_schema`, `output_schema
|
|
1254
|
+
| `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` (agentic only), the agent's default cap, kept by an edit that leaves it out and cleared only by 0 ([spend cap](#spend-cap)). A field the store does not keep (`input_schema`, `output_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)). |
|
|
933
1255
|
| `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. |
|
|
934
1256
|
| `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
|
|
935
1257
|
| `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
|
|
936
1258
|
| `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`. |
|
|
1259
|
+
| `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. |
|
|
937
1260
|
| `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. The agent's runs, newest first. |
|
|
938
1261
|
| `GET /runs` | Every agent's runs, newest first, a page of at most 100; `agent`, `revision` and `status` narrow it, and `archived=true` lists only archived ones. A failed run's summary carries its `error`, and a waiting run's its `pending`. |
|
|
939
1262
|
| `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what it waits on, by `kind`, such as `{kind: "question", question, asked_at}` for a question it asked a person; else null) and cost (`basis: estimate`; $0 before its first model request, a cancelled run's included). |
|
|
@@ -950,14 +1273,14 @@ lists the last 50 attempts (`webhook_id`, type, status code, latency, error, whe
|
|
|
950
1273
|
| `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`. |
|
|
951
1274
|
| `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. |
|
|
952
1275
|
| `GET /settings/mcp-servers`, `POST /settings/mcp-servers/preview`, `GET`, `PUT` and `DELETE /settings/mcp-servers/{name}`, `POST .../{name}/refresh` | [MCP servers](#mcp-servers), this server's own routes (`x-agentrun-serve: "mcpservers/1"`): preview a remote MCP server's tools, save it with its credential sealed, read it back without the credential, refresh its tools, or forget it. |
|
|
953
|
-
| `GET /settings/tools`, `PUT /settings/tools` | This server's own: the providers of `web_search` and `
|
|
1276
|
+
| `GET /settings/tools`, `PUT /settings/tools` | This server's own: the providers of `web_search`, `web_fetch` and `browser` ([search and fetch](#search-and-fetch)). |
|
|
954
1277
|
| `GET`, `PUT` and `DELETE /settings/webhook`, `POST /settings/webhook/test`, `GET /settings/webhook/deliveries` and `POST .../deliveries/{webhook_id}/redeliver` | [Webhooks](#webhooks), this server's own routes (`x-agentrun-serve: "webhook/1"`): the URL run notices are POSTed to, signed by the Standard Webhooks spec; never its secret but once. |
|
|
1278
|
+
| `GET` and `POST /triggers`, `GET`, `PATCH` and `DELETE /triggers/{id}`, `POST /triggers/{id}/fire`, `GET /triggers/{id}/firings`, `POST /triggers/{id}/secret`, `POST /hooks/{id}` (no token: [signed](#webhook-triggers)) | [Schedules](#schedules), this server's own routes (`x-agentrun-serve: "trigger/1"`): schedules that start an agent's capped runs, each firing once, and their history. |
|
|
955
1279
|
| `POST /mcp` | This server's own route (`x-agentrun-serve: "mcp/1"`): the [MCP endpoint](#for-coding-agents), Streamable HTTP with one JSON-RPC message per POST (`initialize`, `ping`, `tools/list`, `tools/call`), answered as JSON, stateless. Its ten tools call these routes in process with the caller's token. The Bearer token only, never the page's cookie; a browser `Origin` other than this server's own is `403`; any other method is `405`. |
|
|
956
|
-
| `GET /usage` | The runs' cost estimates, by meter, agent, key, day or region (`key` and `region` are one line, `local`). A run of unknown cost adds
|
|
1280
|
+
| `GET /usage` | The runs' cost estimates, by meter, agent, key, day or region (`key` and `region` are one line, `local`). A run of unknown cost adds what it is known to have spent so far (its `so_far_usd`: each priced charge, browser time and paid tools included) and is counted in `unpriced_runs` (in the total and in each line it is unknown on), so no sum is ever null, it never passes as $0, and a total is never below a line of its own: with `unpriced_runs` above 0 the total is a lower bound. |
|
|
957
1281
|
|
|
958
1282
|
Home export and import, quotes and `POST /runs/{id}/kill` answer `501 unsupported_here` naming the feature, and
|
|
959
|
-
capabilities declare each one false. No run waits out `input_wait_s` here (`null`),
|
|
960
|
-
browser sign-ins (`sign_ins: false`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
|
|
1283
|
+
capabilities declare each one false. No run waits out `input_wait_s` here (`null`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
|
|
961
1284
|
above $0 is taken; it does not mean caps are unsupported ([spend cap](#spend-cap)).
|
|
962
1285
|
|
|
963
1286
|
## Uploads
|
|
@@ -1019,11 +1342,12 @@ at once, the last wins. A body over `capabilities.home.max_file_bytes` (`limits.
|
|
|
1019
1342
|
`DELETE` removes a file (`204`; `404` when it is not there) and leaves an emptied directory in place. Paths are checked
|
|
1020
1343
|
as a run's are, a write goes at most 16 directories deep (as deep as the list goes), and a link anywhere on the way is
|
|
1021
1344
|
never followed: a read is `404`, a write or a delete
|
|
1022
|
-
`403 system_file_forbidden`. `learning/`
|
|
1023
|
-
`{"path": "learning", "host_owned":
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1345
|
+
`403 system_file_forbidden`. `learning/` and `sign-ins/` (the agent's [saved sign-ins](#saved-sign-ins)) are the
|
|
1346
|
+
server's alone (`capabilities.home.host_owned`): the list shows each as one entry, `{"path": "learning", "host_owned":
|
|
1347
|
+
true}`, with none of what is in it, and a `GET`, `PUT` or `DELETE` at or under one, however the path is spelled
|
|
1348
|
+
(`./Learning/x`), is `403 system_file_forbidden` (`details.reason` `host_owned`). A read's refusal names where to read
|
|
1349
|
+
it instead: the learning API (`/v2/agents/{id}/learning`) on a server that has that route (on one that does not, `the
|
|
1350
|
+
server keeps learning/ for itself; this server has no learning API yet`), and `/v2/agents/{id}` for `sign-ins/`. A host-owned name is matched by its
|
|
1027
1351
|
first segment folded (compatibility form, any case, no combining marks) and, where that segment and `learning/` are both
|
|
1028
1352
|
on disk, by identity (the same
|
|
1029
1353
|
device and inode), so a disk that takes another spelling for one name is refused the same way. A path takes only plain
|
|
@@ -1068,7 +1392,7 @@ codex mcp add agentrun --url "$AGENTRUN_BASE_URL/mcp" --bearer-token-env-var AGE
|
|
|
1068
1392
|
## Harnesses
|
|
1069
1393
|
|
|
1070
1394
|
A definition names the harness that runs it: `pi` (the default, and what a definition that names none gets),
|
|
1071
|
-
`claude-agent` or `
|
|
1395
|
+
`claude-agent`, `codex` or `opencode`; any other is `422 input_invalid` on `definition.harness`. Every answer names it. An edit
|
|
1072
1396
|
(`PUT /agents/{id}/definition`) that names no harness keeps the agent's, as it keeps its skill files; name `pi` to move it
|
|
1073
1397
|
back.
|
|
1074
1398
|
`GET /v2/capabilities` lists each in `harnesses`, with `available` and, when not, the `reason`, and `default_model`: the
|
|
@@ -1077,8 +1401,11 @@ it runs none (the harness does not run here, or no default model here runs on it
|
|
|
1077
1401
|
model). A definition naming a
|
|
1078
1402
|
harness this server does not run yet saves with a warning on `definition.harness`, and a run of it is
|
|
1079
1403
|
`409 agent_not_runnable` with `details.harness`; it never runs on pi instead. This server runs pi always, and
|
|
1080
|
-
`claude-agent` and `
|
|
1081
|
-
says what is missing.
|
|
1404
|
+
`claude-agent`, `codex` and `opencode` when each adapter's package, pins and provider endpoint check out; the harness's
|
|
1405
|
+
`reason` says what is missing. `opencode` needs `opencode-ai@1.19.5` installed beside the server (an exact optional peer of
|
|
1406
|
+
it), and its model goes where codex's does: the gateway at `AGENT_MODEL_BASE_URL`, or
|
|
1407
|
+
OpenAI with `OPENAI_API_KEY`, on the Responses API. The packages and pins are checked once, at the start
|
|
1408
|
+
(`event=harness_offers why=start`): a harness
|
|
1082
1409
|
installed after it, or put back on its pinned build, stays unavailable until AgentRun restarts, and its reason ends
|
|
1083
1410
|
saying so, `once it is installed, restart AgentRun to pick it up` or `once the pinned build is installed, restart
|
|
1084
1411
|
AgentRun`. Run from npx, a reason whose install line is the npx line that starts the server with what is missing needs
|
|
@@ -1086,13 +1413,13 @@ no such clause: running that line is the restart. A reason a setting fixes (a mo
|
|
|
1086
1413
|
|
|
1087
1414
|
`claude-agent` sends its requests to `ANTHROPIC_BASE_URL` (else Anthropic) with `ANTHROPIC_API_KEY` and Anthropic's own
|
|
1088
1415
|
model id, and prices the run by it: a revision's `anthropic/<model-id>`, its dots as dashes, so OpenRouter's dotted name
|
|
1089
|
-
(`anthropic/claude-sonnet-5.5`) and Anthropic's own (`claude-sonnet-5-5`) are one model. `codex`
|
|
1090
|
-
serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
|
|
1416
|
+
(`anthropic/claude-sonnet-5.5`) and Anthropic's own (`claude-sonnet-5-5`) are one model. `codex` and `opencode` send their requests
|
|
1417
|
+
to serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
|
|
1091
1418
|
`OPENROUTER_API_KEY` is set, runs through OpenRouter (`https://openrouter.ai/api`, the key as a bearer token):
|
|
1092
1419
|
claude-agent on its Messages endpoint, with Anthropic's own id on the wire (OpenRouter takes it: its Claude Code guide
|
|
1093
|
-
says its "Anthropic Skin … handles model mapping") and the run priced by OpenRouter's catalog entry; codex on its Responses API, with the model's whole id (`openai/gpt-6-sol`). On that key alone the defaults are
|
|
1420
|
+
says its "Anthropic Skin … handles model mapping") and the run priced by OpenRouter's catalog entry; codex and opencode on its Responses API, with the model's whole id (`openai/gpt-6-sol`). On that key alone the defaults are
|
|
1094
1421
|
`openrouter/openai/gpt-6-sol` for pi (pi-ai's OpenRouter provider, on the bearer route), `anthropic/claude-sonnet-5.5` for
|
|
1095
|
-
claude-agent and `openai/gpt-6-sol` for codex; a direct provider's key gives the default for its harnesses where it is
|
|
1422
|
+
claude-agent and `openai/gpt-6-sol` for codex and opencode; a direct provider's key gives the default for its harnesses where it is
|
|
1096
1423
|
set. A model named `openrouter/<vendor>/<model>` (pi's name for it) goes through OpenRouter on every harness. An endpoint
|
|
1097
1424
|
the host names never gets OpenRouter's key: `ANTHROPIC_BASE_URL` without `ANTHROPIC_API_KEY` is refused. A model with more
|
|
1098
1425
|
than one segment after its provider (`anthropic/anthropic/claude-sonnet-5.5`) is refused, naming the form to use. A provider
|
|
@@ -1104,7 +1431,10 @@ harness, with the provider's first sentence only.
|
|
|
1104
1431
|
tool and reads its other files with `read_skill_file`, and the system prompt holds the instructions alone. A skill the
|
|
1105
1432
|
adapter does not take (a name that is not lowercase letters, digits and dashes, a `SKILL.md` without front matter giving
|
|
1106
1433
|
its `name` and a `description`, a file path that is not plain or is deeper than five segments) stays inlined in the
|
|
1107
|
-
system prompt
|
|
1434
|
+
system prompt; so do all of them when together they hold more than 1 MiB. On `pi`, `codex` and `opencode`, a run with the
|
|
1435
|
+
`read` or `bash` tool is told each skill's name, what it is for (its `description`) and its `SKILL.md`'s path under
|
|
1436
|
+
`.agents/skills/`, and reads the file when the skill fits the step it is on; a run with neither gets every `SKILL.md`
|
|
1437
|
+
inlined in its system prompt.
|
|
1108
1438
|
|
|
1109
1439
|
`definition.harness` and `capabilities.harnesses` are this server's, outside the `agentrun.v2/0` contract:
|
|
1110
1440
|
`GET /v2/openapi.json` marks each `x-agentrun-serve: "harness/1"`, beside the other properties it adds (`model/1`,
|
|
@@ -1264,7 +1594,15 @@ left out: 2 sessions still being written: they come in next time
|
|
|
1264
1594
|
[sandbox](#sandbox), where it and the file tools run in the run's box. The run is `queued` until its first message shows; while the process runs, the
|
|
1265
1595
|
timeline comes from its door's events through `@parcha/pi-durable-agent/timeline`. Once the run is idle and its
|
|
1266
1596
|
newest row is the agent's answer, the server sends the process SIGTERM. A model error ends it `failed`
|
|
1267
|
-
(`run_failed`)
|
|
1597
|
+
(`run_failed`). A run whose `max_cost_usd` cannot buy its next request is paused, `input_required` and `waiting`
|
|
1598
|
+
with `pending.kind` `budget`; one its cap refuses for a reason no cap fixes ends `failed` (`spend_cap_reached`,
|
|
1599
|
+
[below](#spend-cap)). A
|
|
1600
|
+
provider's content filter stopping the answer ends it `failed` with `moderated` on every harness, saying so in plain
|
|
1601
|
+
words ("The model provider stopped this answer (its content filter). Rephrase the request, or try another model.");
|
|
1602
|
+
the Timeline's error row keeps the harness's own words for the stop: pi-ai's on pi ("Response incomplete:
|
|
1603
|
+
content_filter", say), the kernel's on claude-agent and codex ("content_filter: the model provider stopped this
|
|
1604
|
+
answer"), never the provider's own. On claude-agent and codex the session's model proxy reads
|
|
1605
|
+
the provider's stop and ends the turn at once, so the CLI never asks for the refused answer again.
|
|
1268
1606
|
A stop sent while the run still reads `queued` (a message sent to it not yet in its timeline) waits, up to a
|
|
1269
1607
|
request's deadline, for that message to show, then stops the turn as it stops any working run.
|
|
1270
1608
|
A stopped run can be continued: a follow-up starts a fresh turn on the whole history, and the turn the stop cut is
|
|
@@ -1289,8 +1627,11 @@ left out: 2 sessions still being written: they come in next time
|
|
|
1289
1627
|
agentic run waiting for an answer waits without one, until a message). A carry back that finds the store held by
|
|
1290
1628
|
another writer is tried again with backoff, and at the next start.
|
|
1291
1629
|
|
|
1292
|
-
An `Idempotency-Key` answer is kept in `DATA/.idempotency.json` for `limits.idempotency_ttl_s` (a day),
|
|
1293
|
-
the answer is sent, so a retry after a restart gets the first answer
|
|
1630
|
+
An `Idempotency-Key` answer is kept in `DATA/.idempotency.json` for `limits.idempotency_ttl_s` (a day), saved once the
|
|
1631
|
+
work is done and before the answer is sent, so a retry after a restart gets the first answer; a server that goes down
|
|
1632
|
+
between the work and the save loses it, and a save that fails still answers. A run create's key is also kept with its
|
|
1633
|
+
run in the agent store, written with the run itself, so a retry after any restart, or after that day, gets that run (as
|
|
1634
|
+
it is now, marked `Idempotent-Replayed: true`), and another body under the key is still `409 idempotency_mismatch`.
|
|
1294
1635
|
|
|
1295
1636
|
A completed agentic run's `result` is `{output: null, final_answer}`; a completed workflow run's is
|
|
1296
1637
|
`{output: <the workflow's output>, final_answer: null}`.
|
|
@@ -1352,6 +1693,31 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
|
|
|
1352
1693
|
follow-up gets them laid again, fresh, whatever the run wrote over them; one the work no longer holds whole when the
|
|
1353
1694
|
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
|
|
1354
1695
|
of shape is not read, and a symbolic link or a submodule at `skills/` or anywhere under it is a learning fault.
|
|
1696
|
+
- The workflows the agent learned, each a folder `workflows/<name>/` on `main` with its `workflow.json` and its
|
|
1697
|
+
`README.md`, are the run's as one tool, `learned_workflow {name, input}`, on every harness (pi, claude-agent, codex),
|
|
1698
|
+
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
|
|
1699
|
+
`active`. Its description names each workflow with the line its README gives, 8 KiB of lines in all: by name, each
|
|
1700
|
+
while its line fits, and one that does not, or holds one of the server's secrets, is left out. A README whose front
|
|
1701
|
+
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
|
|
1702
|
+
ones the run gets (`workflows`), each kept whole in the run's directory (`learned-workflows.json`), outside its work,
|
|
1703
|
+
and the ones left out (`workflows_left_out`). The list is fixed when the run starts: a workflow approved or retired
|
|
1704
|
+
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
|
|
1705
|
+
agent's own tools as its run resolves them, as the merge did: one whose call node names a tool the agent was not
|
|
1706
|
+
granted (or one its run resolves unavailable), whose model node names any tool (a learned model node runs without
|
|
1707
|
+
tools, so the merge refuses one too), or that holds a code node or a shell or executor call, is refused before any of
|
|
1708
|
+
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
|
|
1709
|
+
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
|
|
1710
|
+
own, each call node `via: "tool"` on a tool the agent has, its paid requests booked under
|
|
1711
|
+
the `learned_workflow` call, and web_search on the provider's own search where it resolves native, through the run's
|
|
1712
|
+
models. Its model requests are the run's, under its cap and on its timeline as side requests labelled
|
|
1713
|
+
`learned_workflow`: on claude-agent and codex, the harness's requests and the workflow's count against one total, and
|
|
1714
|
+
each holds its worst case in flight where the other's check sees it, and the workflow's go where the harness's go (on
|
|
1715
|
+
OPENROUTER_API_KEY alone, through OpenRouter, by OpenRouter's name for the run's model; claude-agent through the
|
|
1716
|
+
operator's own gateway at ANTHROPIC_BASE_URL, or any harness at an origin its requests could not follow, is offered
|
|
1717
|
+
none, which its pin names in `workflows_off`; opencode takes codex's route). A call a crash cut off is answered interrupted,
|
|
1718
|
+
never run again. The tool gate holds
|
|
1719
|
+
`learned_workflow` like any tool: its settings key is `learned_workflow`, allowed by default (the agent's own graded
|
|
1720
|
+
workflow, each node checked), and tool settings may set it to ask (the run parks until an owner answers) or deny.
|
|
1355
1721
|
|
|
1356
1722
|
The server reads the commit with git plumbing, never the working tree. What it holds that is not a regular UTF-8 file of
|
|
1357
1723
|
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
|
|
@@ -1381,7 +1747,8 @@ path that is not a `.md` file at the top, a bad name, front matter out of shape
|
|
|
1381
1747
|
naming a note that is not active, more than 8 notes superseded, more than 8 new notes or a note over 4068 bytes (4096,
|
|
1382
1748
|
less the 28 the server's own `origin` and `status` lines may take once it merges the note), an
|
|
1383
1749
|
index past 200 lines, hidden characters, and text shaped like a secret or holding one of the server's own secrets (the
|
|
1384
|
-
launcher's, the keys and tokens in its environment, its API and door tokens
|
|
1750
|
+
launcher's, the keys and tokens in its environment, its API and door tokens, each webhook trigger's signing secret as it
|
|
1751
|
+
is now), in a note or its name. A `MEMORY.md` the
|
|
1385
1752
|
answer gives is ignored. What passes is kept as the run's proposal, `runs/<id>/learning-proposal.json`, with what the
|
|
1386
1753
|
user said, each message cut of the server's secrets.
|
|
1387
1754
|
|
|
@@ -1393,8 +1760,8 @@ neither, on the agent's own model. `GET /capabilities` names it as `learning.gra
|
|
|
1393
1760
|
cheap model is a poor grader, so point the strong tier (or `--grade-model`) at a strong one. The grader reads each active
|
|
1394
1761
|
note's index line, the whole text only of the notes the proposal supersedes, what the user said in the run (cut of the
|
|
1395
1762
|
server's secrets, as the proposal keeps it), and the new notes, so its prompt stays under 200,000 characters however
|
|
1396
|
-
many notes the folder holds.
|
|
1397
|
-
|
|
1763
|
+
many notes the folder holds. No injection screen runs before it: a page classifier cannot see where a note came
|
|
1764
|
+
from, and read a preference the user stated as a planted instruction; the grader's Planted question decides. What the
|
|
1398
1765
|
grade spends is in no run's totals: it is kept on the run's learning, and counted once on `GET /usage` under the meter
|
|
1399
1766
|
`learning`, by agent and by day; a call cut off at its bound spent what nobody knows, so its cost is unknown, never $0.
|
|
1400
1767
|
|
|
@@ -1414,8 +1781,8 @@ The run's `learning` (on `GET /runs/{run_id}`, and `{state, reason, detail}` in
|
|
|
1414
1781
|
characters and no time) says how it went: `seeded`, then
|
|
1415
1782
|
`reflecting` during the turn and until what it answered is checked, `proposed` while it is graded, and `merged`, or
|
|
1416
1783
|
`dropped` with a reason from a closed list (`seed_failed`, `no_budget`, `unknown_cost`, `cancelled`, `crashed`,
|
|
1417
|
-
`reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `
|
|
1418
|
-
`
|
|
1784
|
+
`reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`;
|
|
1785
|
+
`no_write_tool`, `tool_denied`, `screen` and `screen_down` are an older server's, still read and counted, and no run
|
|
1419
1786
|
gets them now). It is `null` for a
|
|
1420
1787
|
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
|
|
1421
1788
|
workflow's or an imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2
|
|
@@ -1519,28 +1886,54 @@ log shows `by: {user: true, via: "console"}` at the commit's time, never the not
|
|
|
1519
1886
|
|
|
1520
1887
|
## Spend cap
|
|
1521
1888
|
|
|
1522
|
-
An agentic run may name `max_cost_usd` (a workflow run may not: `422`).
|
|
1889
|
+
An agentic run may name `max_cost_usd` (a workflow run may not: `422`). A run that names none takes its agent's default,
|
|
1890
|
+
the `max_cost_usd` of the revision it runs, kept with the revision; a run's own cap wins, since its caller chose it. A
|
|
1891
|
+
definition's `max_cost_usd` above 0 sets that default, and 0 clears it (no default); anything else is `422`. An edit that
|
|
1892
|
+
leaves the field out keeps the agent's default, as it keeps its harness and place: leaving a field out never removes a
|
|
1893
|
+
spend limit. A workflow definition keeps none: above 0 is `422 not_allowed`, and 0 changes nothing. The cap is checked in the run's own process
|
|
1523
1894
|
before each model request, the agent's and a compaction's alike, on every harness: what the run has spent so far, plus
|
|
1524
1895
|
the worst case of each request still in flight, plus this request's worst case must stay within it, or the request is
|
|
1525
|
-
not sent and the run
|
|
1896
|
+
not sent and the run pauses ([below](#a-run-paused-at-its-cap)). A request's worst case is its input bound at the higher of
|
|
1526
1897
|
the model's input and cache-write prices (the provider may bill any of the input as a cache write), plus the output it is
|
|
1527
1898
|
sent with at the output price, plus any fee its tokens do not show (below). Under a cap each request is limited to the
|
|
1528
1899
|
output tokens what is left of the cap can buy, thinking included, never more than it asks for or than the model's
|
|
1529
1900
|
ceiling (its max output tokens, else its context window, clamped to what the window leaves): on pi through the request's
|
|
1530
|
-
own options (its max tokens, and on Anthropic's API its thinking budget), on claude-agent and
|
|
1901
|
+
own options (its max tokens, and on Anthropic's API its thinking budget), on claude-agent, codex and opencode written into its body
|
|
1531
1902
|
by the model proxy (`max_tokens` and `thinking.budget_tokens`, or `max_output_tokens`). The limit is what it is held at,
|
|
1532
1903
|
so the cap stays exact. A request is refused only when what is left cannot buy its least: 1,024
|
|
1533
1904
|
tokens for its answer (what it asks for, when that is fewer), and when it thinks, the provider's least thinking budget
|
|
1534
1905
|
where thinking takes one (Anthropic's, 1,024, the budget squeezed to it at the least) or else its thinking level's
|
|
1535
1906
|
budget, since its reasoning then shares the limit (minimal 1,024, low 2,048, medium 8,192, high 16,384). The input bound is one token per UTF-8 byte of what is sent (a byte-level tokenizer never makes
|
|
1536
1907
|
a token of less than one byte, and an image's base64 is far more bytes than its tokens), plus what the provider adds
|
|
1537
|
-
server-side (a tool-use prompt, each image), from the same table the model proxy of claude-agent and
|
|
1908
|
+
server-side (a tool-use prompt, each image), from the same table the model proxy of claude-agent, codex and opencode uses; there
|
|
1538
1909
|
the proxy measures each request's body. A request in flight holds its worst case until it answers, so requests sent side
|
|
1539
1910
|
by side cannot pass the cap together. Spent so far is read from the run's store each time its process starts, so it
|
|
1540
1911
|
survives a restart, plus each response since, and with them each charge a paid tool booked (`monid.run`, which is itself
|
|
1541
1912
|
refused once the spend reaches the cap; see [monid](#tools)).
|
|
1542
1913
|
|
|
1543
|
-
|
|
1914
|
+
The `browser` tool's session time is held the same way, before it runs, so no browser minute passes the cap. Its next
|
|
1915
|
+
stretch is the most a session can run before the run can check again: the provider's minimum (what its release may top
|
|
1916
|
+
it up to), pi-browser's idle window before it releases a session nobody calls (180 s), and 30 s for that release to be
|
|
1917
|
+
confirmed at the provider; at Browserbase's price, 270 s or $0.009. Before each browser call, the call is held at what its
|
|
1918
|
+
session ran since its last charge plus two stretches (one for the call's own time, one for a session it opens): spent, plus
|
|
1919
|
+
every hold, plus that must stay within the cap. Otherwise the call is not made: the model gets the cap's words
|
|
1920
|
+
(`spend_cap_reached: Not sent: the run has spent $X of its $C cap, and this browser call could cost up to $0.018 ...`), and
|
|
1921
|
+
the run's session is released.
|
|
1922
|
+
A session's first charge moves one stretch of its call's hold to the session, held until its release is booked, which
|
|
1923
|
+
covers its idle time, its top-up and its release; each call's charge comes out of the call's hold, which goes when the
|
|
1924
|
+
call returns. So what the run spent plus what it holds stays within the cap through a session's create, its calls, the
|
|
1925
|
+
idle time between them and its release. A session a create's lost answer left to a release after the create deadline is
|
|
1926
|
+
held for that deadline and a stretch until its release is billed. Across a restart of the run's process, every session
|
|
1927
|
+
custody still tracks (kept, unreached, still releasing) is held from the reopen, at a stretch beside what it ran since
|
|
1928
|
+
its last charge, and one kept is released an idle window later unless a call uses it. Three
|
|
1929
|
+
things can still pass the cap, each by what it ran over, booked and shown: a single browser call that runs longer than a
|
|
1930
|
+
stretch, a release that takes longer than 30 s to be confirmed, and the time a run's process was down while it held a
|
|
1931
|
+
session (spent before any process could hold it). A session whose release is never confirmed is billed in full
|
|
1932
|
+
(what it ran and its minimum) when the run gives up on it. When the run is let go, its sessions are released and their
|
|
1933
|
+
last charges booked before its process exits.
|
|
1934
|
+
|
|
1935
|
+
Under a cap, whatever cannot be priced is refused, never passed as $0, and the run ends `failed` with
|
|
1936
|
+
`spend_cap_reached`, since no cap would send it:
|
|
1544
1937
|
|
|
1545
1938
|
- A model serve has no price for (a gateway id pi-ai's catalog does not know, with no `AGENT_MODEL_PRICE`): its first
|
|
1546
1939
|
request is refused before anything is sent, and the run ends `spend_cap_reached` at $0. With no cap its run's cost
|
|
@@ -1553,14 +1946,40 @@ Under a cap, whatever cannot be priced is refused, never passed as $0:
|
|
|
1553
1946
|
after a cut, at the worst case the cap held, as pi does.
|
|
1554
1947
|
|
|
1555
1948
|
A request you stop counts what it streamed plus up to 1,024 output tokens the provider may have produced after the last
|
|
1556
|
-
word we read; never more than it was held. That is its input bound and each byte it streamed (text,
|
|
1557
|
-
calls on pi;
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
request
|
|
1949
|
+
word we read; never more than it was held. That is its input bound and each byte of content it streamed (its text,
|
|
1950
|
+
thinking and tool calls on pi; on `claude-agent`, `codex` and `opencode`, the text, reasoning and tool-argument deltas
|
|
1951
|
+
the response sent, never the provider's framing around them, which runs to about 12 bytes a character on the Responses
|
|
1952
|
+
API and 24 on the Messages API) as a token, plus 1,024 tokens of output (`STOP_ALLOWANCE_TOKENS`), at the model's price, and at most
|
|
1953
|
+
the worst case the cap held for it. The cut stream's own usage is never read: it is not what the provider billed (the
|
|
1954
|
+
Responses API reports none until the end, and Anthropic's output count comes at the end). The 1,024 tokens are a stated
|
|
1955
|
+
bound, as the native search allowance is: a provider that went on producing for longer after the stop could bill past
|
|
1956
|
+
what is counted. A request that ended on an error after its response began (an overload part way, a reset), or a summary
|
|
1957
|
+
that failed, still counts at its worst case, and so does a request cut by a crash (its process gone mid-request). A
|
|
1958
|
+
request stopped before the provider's first header counts its input and the 1,024 tokens, on every harness.
|
|
1959
|
+
|
|
1960
|
+
Reasoning the provider never streams counts too. A model whose reasoning streams only as a summary (the Responses API's
|
|
1961
|
+
reasoning; Claude 4-class thinking, and redacted thinking) or not at all is billed for far more than the summary's
|
|
1962
|
+
bytes, so a stopped request that reasons also counts the part of its reasoning budget that did not stream: input +
|
|
1963
|
+
streamed + 1,024 + max(0, reasoning budget - reasoning streamed), never more than the hold. Reasoning streamed is its
|
|
1964
|
+
thinking's bytes on pi, and on `claude-agent`, `codex` and `opencode` the bytes of the reasoning events the response
|
|
1965
|
+
sent (a thinking delta, a reasoning summary delta); answer text never stands in for it. The budget is its effort's or thinking
|
|
1966
|
+
level's (minimal 1,024, low 2,048, medium 8,192, high 16,384; on Anthropic's API, the `budget_tokens` it was sent with).
|
|
1967
|
+
A Claude model whose thinking is adaptive (pi-ai sends every current one `thinking: {type: "adaptive"}`, no budget) thinks
|
|
1968
|
+
within its output limit as it sees fit, so on pi it counts that limit less 1,024 tokens, as `claude-agent` counts
|
|
1969
|
+
`max_tokens`, and is sent the limit it is held at. With no effort or level given, on an API whose model then reasons at
|
|
1970
|
+
its own default (OpenAI's), it counts its whole output limit, the conservative side; with thinking off on Anthropic's
|
|
1971
|
+
API, none, unless the model thinks adaptively at any level (pi-ai's models with mid-conversation effort). On
|
|
1972
|
+
`claude-agent`, every request that thinks counts its budget, since Claude 4-class models stream only a summary of their
|
|
1973
|
+
thinking; thinking that streamed is subtracted, so a stop after a budget's worth of visible thinking counts nothing on
|
|
1974
|
+
top. The figure is an estimate: an effort's budget is not a limit the provider keeps, so a request can reason past it.
|
|
1975
|
+
It is bounded by the request's hold, and its real usage replaces it when that comes.
|
|
1976
|
+
|
|
1977
|
+
So on a model whose thinking is adaptive (every current Claude model, on pi and on `claude-agent`), a stopped request
|
|
1978
|
+
counts up to its hold: the provider is given no thinking budget, and what streamed says nothing of the thinking billed.
|
|
1979
|
+
That whole budget is the safe figure, kept on purpose: the stream reports the thinking billed only on its final
|
|
1980
|
+
`message_delta` (`usage.output_tokens_details.thinking_tokens`), which a stopped stream never receives, and the live
|
|
1981
|
+
`thinking_delta.estimated_tokens` is a display hint that can under-count. Under a cap with little left beside that hold,
|
|
1982
|
+
the request after the stop can be refused, and the run then pauses for a raise.
|
|
1564
1983
|
|
|
1565
1984
|
On pi the figure is written on the request's start mark (`agentrun.request_started`, its worst case) and on the end mark
|
|
1566
1985
|
of one stopped (`agentrun.request_ended`, what it counts at), as `heldUsd`; on `claude-agent` and `codex` on the
|
|
@@ -1568,7 +1987,8 @@ request's `runner.request` record (its worst case) and, for one stopped, on its
|
|
|
1568
1987
|
the same: a capped run stopped and sent another message, or opened again after its process died, goes on while its cap
|
|
1569
1988
|
allows. A cut request from a store written before serve kept the figure has none, and is a spend no one knows.
|
|
1570
1989
|
|
|
1571
|
-
A refusal says so in plain words, with the numbers, on
|
|
1990
|
+
A refusal says so in plain words, with the numbers, on its timeline row and on the run's `pending` (or, for a refusal
|
|
1991
|
+
no cap fixes, its error): "Not sent: this run's
|
|
1572
1992
|
cap of $0.01 can't cover one Claude Sonnet 5.5 request (at least $0.03). Raise the cap to at least $0.03 to run it.", and
|
|
1573
1993
|
once a run has spent: "Not sent: the run has spent $0.45 of its $0.50 cap, and its next Claude Sonnet 5.5 request needs at
|
|
1574
1994
|
least $0.03. Raise the cap to at least $0.48 to run it." The cap that would run it is what was spent, what requests still
|
|
@@ -1579,6 +1999,51 @@ refused was never sent: the run's usage counts no request for it, and a run whos
|
|
|
1579
1999
|
request sent". A reply the limit cut short says so on the run's timeline: "The reply stopped at 1,500 tokens: all that
|
|
1580
2000
|
the $0.15 left of the run's $0.50 cap could buy."
|
|
1581
2001
|
|
|
2002
|
+
### A run paused at its cap
|
|
2003
|
+
|
|
2004
|
+
A refusal for room (what is left of the cap cannot buy the next request's least) pauses the run instead of ending it: the
|
|
2005
|
+
refused request was not sent, so the cap holds, and a higher cap would send it. The run is `input_required` and
|
|
2006
|
+
`waiting`, `error` null, with `pending: {kind: "budget", cap_usd, spent_usd, needs_usd, suggested_cap_usd, said, at}`:
|
|
2007
|
+
its cap, what the cap counted as taken (spent, and held for requests still answering) and the least the refused request
|
|
2008
|
+
needs (a cap above their sum sends it), the raise it is offered, the refusal's words above, and when it came. The
|
|
2009
|
+
offered raise, `suggested_cap_usd`, is `spent_usd` + 10 × `needs_usd` rounded up to a whole dollar, and always above the
|
|
2010
|
+
cap, so a `PATCH` with it (below) resumes the run; it is absent with the other figures. The figures come from the refusal's own start mark, so a
|
|
2011
|
+
server started again says them too, shown as `cost.usd` is (to a millionth of a dollar), except `spent_usd` once the paused process is gone: the refusal counted requests
|
|
2012
|
+
still answering at what it held for them, so then it is the store's spend, when that is lower, and `suggested_cap_usd`
|
|
2013
|
+
follows it. The refusal's words (`said`) keep its own figures. Its timeline shows the refusal's row, then a waiting row: "Paused at the run's $0.05 cap: Not sent: …". The
|
|
2014
|
+
webhook's `run.needs_input` says `pending.kind: "budget"`. Its process is let go while it waits (SIGTERM: it drains and
|
|
2015
|
+
releases the run), so a paused run holds no place; a server started again reads it paused from its store. A paused
|
|
2016
|
+
process that does not let go within the drain timeout (`--drain-timeout`, 30 s by default) is killed, and the run ends
|
|
2017
|
+
`failed`, as any run whose process is killed does, unless its cap was raised meanwhile: it held nothing, so the raise's
|
|
2018
|
+
follow-up goes (below). A message to a
|
|
2019
|
+
paused run is `409 budget_reached`; a stop does nothing more, and a cancel ends it `cancelled`. Only a refusal for room
|
|
2020
|
+
pauses a run: one no cap fixes (above) ends it `failed`, as does a cost found past the cap after a response.
|
|
2021
|
+
|
|
2022
|
+
A paid tool call (monid's run, a search or a fetch through Parallel, browser time) that the cap refuses for room pauses
|
|
2023
|
+
the run the same way. The call is not sent, and its result says so in the cap's words. The model's next request is
|
|
2024
|
+
refused in those words, so the turn ends there and the model gets no turn to work around it. The run's `pending`
|
|
2025
|
+
holds what was taken (`spent_usd`), the call's hold as what it needs (`needs_usd`), and the raise it is offered. A
|
|
2026
|
+
raise sends the run on, and the model makes the call again if it still needs it: each call the model makes is one
|
|
2027
|
+
call, and nothing is retried for it. The refusal answers that turn's next request alone: a stop in between, then a
|
|
2028
|
+
message, starts a turn that is judged as any other. A paid call refused because what the run has spent is unknown
|
|
2029
|
+
still ends the run `failed`.
|
|
2030
|
+
|
|
2031
|
+
`PATCH /runs/{run_id}` with `{max_cost_usd}` raises the cap, and only raises it: the new cap is above the run's current
|
|
2032
|
+
cap, its last raise included, by more than a float's tail (1e-9; `422` otherwise, and for a run with no cap or a workflow
|
|
2033
|
+
run; `409 not_continuable` for an ended run). The same raise sent again (a retry), within that tail, changes nothing and
|
|
2034
|
+
answers as the first did. The run's serve.json keeps the raise before any answer, with each raise in `cap_raised`, so its
|
|
2035
|
+
next process opens under it, as does a server started again; a raise it could not keep is not taken (an error answers it),
|
|
2036
|
+
and the same raise again is taken anew. A run paused at its cap goes on: the answer is `{run_id, max_cost_usd, resumed: true,
|
|
2037
|
+
message_id, status, state}` at once, and the pause gets one follow-up turn, "The cap was raised to $2; continue the
|
|
2038
|
+
task.", under that `message_id`, which the server sends once the process being let go is gone, and which runs under the
|
|
2039
|
+
new cap. A second raise before it goes raises the cap it names and answers the same `message_id`. It is sent once: a
|
|
2040
|
+
server stopped before it went, or between starting its process and sending it, sends it when it starts again. One that
|
|
2041
|
+
cannot be sent is tried again (after 1 s, then 3 s); after 3 tries the run ends `failed`, saying the cap was raised but
|
|
2042
|
+
the run could not be sent on. The follow-up shows in the run's timeline as the server's, "AgentRun: The cap was raised…", never as the
|
|
2043
|
+
person's message (its submit names the server as its origin, `cap_raised`). A working run's
|
|
2044
|
+
live process keeps the cap it was opened with until its next one, and the answer's `note` says so. The raise is keyed to
|
|
2045
|
+
the refusal's own start mark, so a row shown after the refusal never reads the run paused again.
|
|
2046
|
+
|
|
1582
2047
|
A request carrying a native web search tool reads pages into its input that its body does not hold (the provider bills
|
|
1583
2048
|
them as input): under a cap its input bound is its body's plus an allowance. Claude's own search, an explicit `native`
|
|
1584
2049
|
pick, does not run under a cap: each search has a per-use fee the cap cannot reserve yet, so a capped claude-agent run
|
|
@@ -1611,8 +2076,8 @@ export default function reply(context, faux) {
|
|
|
1611
2076
|
```
|
|
1612
2077
|
|
|
1613
2078
|
`startServe({ faux, fauxBrowser, fauxWeb })` (the tests', not the CLI's) also names modules whose default exports give
|
|
1614
|
-
the `browser` tool's `{ provider, driver }` in place of Browserbase's (pi-browser's fake backend,
|
|
1615
|
-
`test/fixtures/faux-browser.mjs`), `web_fetch`'s direct fetch's `{ lookup, fetchImpl }` in place of the system's resolver and
|
|
2079
|
+
the `browser` tool's `{ provider, driver }` in place of Browserbase's or Kernel's (pi-browser's fake backend, told the
|
|
2080
|
+
vendor the run's plane names and the saved sign-in the run was handed: `test/fixtures/faux-browser.mjs`), `web_fetch`'s direct fetch's `{ lookup, fetchImpl }` in place of the system's resolver and
|
|
1616
2081
|
undici (a table of names and pages, `test/fixtures/faux-web.mjs`), and, as `fauxMonid`, the fetch the monid tools send
|
|
1617
2082
|
through in place of monid's API (`test/fixtures/faux-monid.mjs`). Each is honored only with `faux`.
|
|
1618
2083
|
|
|
@@ -1642,9 +2107,11 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
1642
2107
|
pipe.
|
|
1643
2108
|
- `web_fetch`'s direct fetch dials public addresses only, each hop checked and pinned (see [Tools](#tools)): a run cannot reach this
|
|
1644
2109
|
machine, its network or a cloud's metadata address through it.
|
|
1645
|
-
- A `browser` session runs at Browserbase, not on this machine: a page the model opens is reached from
|
|
1646
|
-
network, so what the model may reach there is the operator's choice of keys and project. Its downloads and uploads stay
|
|
1647
|
-
in the run's `work/`.
|
|
2110
|
+
- A `browser` session runs at Browserbase or Kernel, not on this machine: a page the model opens is reached from that
|
|
2111
|
+
vendor's network, so what the model may reach there is the operator's choice of vendor, keys and project. Its downloads and uploads stay
|
|
2112
|
+
in the run's `work/`. An agent's saved sign-in stays at the vendor; this server keeps a sealed pointer to it, which a
|
|
2113
|
+
run's process gets over its pipe and its tools and model never see. Anyone holding the vendor's key can open that
|
|
2114
|
+
context or profile there.
|
|
1648
2115
|
- It binds 127.0.0.1 by default, and there refuses a request whose `Host` is not a loopback name (DNS rebinding). On
|
|
1649
2116
|
another address (`--listen`, the container's `0.0.0.0`) it serves every `Host` name, and the token is its only lock.
|
|
1650
2117
|
It sends no CORS headers, so a page on another origin cannot read an answer.
|
|
@@ -1661,7 +2128,7 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
1661
2128
|
`SENTRY_DSN`, `DB_PWD`; never `PWD` or `OLDPWD`), whether the launcher's list names it or not. The rule is
|
|
1662
2129
|
pi-durable-disk's (`@parcha/pi-durable-disk/secret-name`), which an import's cut and a harness's log take too. The keys it
|
|
1663
2130
|
needs come over its pipe. It gets none of the boxes' keys ([Boxes](#boxes)). A tool key reaches it only when its
|
|
1664
|
-
revision names a tool the key unlocks (`MONID_API_KEY` a monid tool, `BROWSERBASE_API_KEY` `browser`; a workflow's
|
|
2131
|
+
revision names a tool the key unlocks (`MONID_API_KEY` a monid tool, `BROWSERBASE_API_KEY` and `KERNEL_API_KEY` `browser`; a workflow's
|
|
1665
2132
|
tools are those its model and call nodes name), and a model key only when its model needs it ([Models](#models)), read
|
|
1666
2133
|
from the revision at each launch, a relaunch or a resume after a restart included.
|
|
1667
2134
|
- A variable named like a key that is not on the launcher's list (`capabilities.secrets.names`) is left out of every
|