AGENT.RUN() / GET STARTED

Set up AgentRun
with your agent.

Follow the AgentRun quickstart with your coding agent. Open the prompt in an app, or copy it into your terminal agent.

Download Markdown

DOCUMENTATION / PLATFORM REFERENCE / AGENTRUN SERVER

Based on AgentRun release · Synced .

Learning

Learning is off unless an agent's definition says learning: true (an agentic one: a workflow refuses the field). A definition that sets it keeps it on its revision, false included, and an edit that leaves it out keeps the agent's; one that never sets it stores nothing, so its revision id is the one it had before the switch. The server's --learning off turns learning off for every run it starts, whatever the agent says.

An agent learns two things. Its owner's corrections: the words they give after a run (a grade's, or a message after the job's first) become one line of the agent's corrections.md, and every later run reads the file whole. And its job, once it repeats: after learning.compile_after completed runs (20 by default) the run's end asks one compile turn for the whole job as one workflow, which is checked in code, replayed on the agent's own past inputs, and served as one tool once it agrees with the agent's own answers. The console reads GET /v2/agents/{id}/learning for the agent's corrections, workflows and history, and GET /v2/runs/{id}/learning and its /diff for an individual result. Observation requires no model key. Creating workflow drafts requires an agentic run executed or reported through this server with learning enabled and access to its configured compile model. For a connected SDK agent, compilation runs on this server; shadow execution and tool access remain in the original application, as described below.

Set up Settings → API Keys → Model keys with a provider key that matches the learning model, such as OpenRouter, Anthropic or OpenAI, or a supported server sign-in. An unrelated provider key, tool API key, AgentRun connection key or decision-provider key does not supply compiler access. Background compilation cannot borrow a caller's per-request gateway key. The new SDK shadow comparison is deterministic and needs no separate Jev key. Native project connections use their original runtime's sign-in for corrections; learned workflows are not available on that connection.

The agent's Learning tab and Learning Dojo show missing setup for that agent's actual model. learning_model in GET /v2/agents/{id}/learning describes that route; the same field in capabilities describes the server default. ready means the route and credentials are configured, not that quota or provider availability has been verified. These reads make no paid request, and saving a matching key refreshes the setup guidance.

Importing Claude Code, Codex or pi session history does not replay learning or connect a live learning stream. Before/after cost and duration are observations, not an accuracy evaluation.

Existing CLI capture. A project enrolled with cli_learning keeps running in its original Codex CLI or Claude Code process. Its hooks record normal prompt windows and provide the agent's explicit owner-written corrections on later prompts when learning is enabled. Capturing a prompt does not turn its content or answer into a correction. CLI capture starts no extra source prompt, native grading turn or automatic note/skill extraction. It has no approved workflow tool bridge, so it neither compiles nor executes learned workflows. The Learning tab edits corrections and shows captured runs; new captures begin with the next normal prompt after hooks are ready. Historical learning files remain stored and are not converted into owner corrections or deleted. Older stored CLI learning: "notes" settings read publicly as true; that compatibility read does not rewrite the revision.

An agent that learns has a learning folder, learning/ in its folder on the disk (DATA/disk/agents/<key>/learning/):

  • corrections.md, its owner's standing corrections, one - line each, at most 2048 bytes;
  • one folder per learned workflow, workflows/<name>/, with its workflow.json and its README.md (front matter with name and description, and status: pending while it waits for its owner's OK).

The server reads and writes it with its own code, in src/learn/, whose SPEC.md is the folder's contract. The folder is plain git with main checked out. The agent's first run that learns makes it, with one empty commit on main; an agent that does not learn never gets one. The server is its only writer. Every git call the server makes there runs with the folder's hooks and fsmonitor off, no replace refs, no lazy fetch and no system or global config, one at a time per agent.

Each run of an agent that learns starts from main as it is when the run is made, whatever its harness:

  • runs/<id>/learning.json pins that commit (seed). It is written once: a resume or a follow-up reads the same commit, however main moves on.
  • The agent's corrections go into the run's instructions after the agent's, under # Learned, so a run reads them whatever its tools: corrections.md whole, after one line that says they are its owner's standing corrections, to follow each one that applies. Nothing picks, ranks or summarizes them: the file's cap keeps it whole. A run with no corrections yet reads "Nothing learned yet." there; a run that does not learn gets no # Learned. The text is cut of the server's secrets as they are when the run is made, as a person's reads are. That is pi's system prompt and claude-agent's and codex's instructions: the same channel CLAUDE.md and AGENTS.md travel in. No file is written into the run's work. The pin keeps the section the run reads (section), so a resume or a follow-up reads the same.
  • The workflows the agent learned, each a folder workflows/<name>/ on main with its workflow.json and its README.md, are the run's as one tool, learned_workflow {name, input}, on every harness (pi, claude-agent, codex), with no edit of the agent's definition. Only an active, promoted revision is: its README.md sets no status, or active, and its promotion record names the checked champion. A compiled draft without that record is withheld; front matter that does not read one way (not closed, a key indented under another, a key set twice, a status over more than one line) reads as retired, so no run is given it. Its description names each workflow with the line its README gives, 8 KiB of lines in all: by name, each while its line fits, and one that does not, or holds one of the server's secrets, is left out. A README whose front 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 ones the run gets (workflows), each kept whole in the run's directory (learned-workflows.json), outside its work, and the ones left out (workflows_left_out). The list is fixed when the run starts: a workflow approved or retired while it runs is the next run's to get or not. A call checks the workflow again against the agent's own tools as its run resolves them, as the commit's checks did: one whose call node names a tool the agent was not granted (or one its run resolves unavailable), whose model node names any tool (a learned model node runs without tools, so the checks refuse one too), or that holds a code node or a shell or executor call, is refused before any of 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 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 own, each call node via: "tool" on a tool the agent has, its paid requests booked under the learned_workflow call, and web_search on the provider's own search where it resolves native, through the run's models. Its model requests are the run's, under its cap: on pi, side requests of the run's models labelled learned_workflow on its timeline; on claude-agent, codex and opencode, requests on the run's one route, the session's model proxy, under a key of the run's own: the same body rules, provider, key, price and cap as the harness's own requests, booked on the session's records labelled learned_workflow. So they go wherever the harness's go (the operator's gateway at ANTHROPIC_BASE_URL or AGENT_MODEL_BASE_URL, OpenRouter, the vendor's API), and every run is offered the workflows its pin names. A call a crash cut off is answered interrupted, never run again. The tool gate holds learned_workflow like any tool: its settings key is learned_workflow, allowed by default (the agent's own checked and replayed workflow), and tool settings may set it to ask (the run parks until an owner answers) or deny. When a run's learned workflows name decision providers (Jev, Parallel, OpenRouter), the runner opens those providers' keys as it opens the run's own, from the server's environment first and then its saved keys, for the run's tools alone: never for its model or a CLI harness's own environment. A provider the run's tool gate denies gets no key. A learned workflow's call node can run an MCP tool the agent grants (mcp:<server>/<tool>) through the run's own MCP, under the run's tool gate: allowed, it runs at the run's tool cost; denied, the workflow is refused before any node runs; set to ask, the learned_workflow call asks once, naming every such tool, and the run parks. A run's own draft can't call one yet: the checks admitting it are coming.

The server reads the commit with git plumbing, never the working tree. What it holds that is not a regular UTF-8 file of 1 MiB or less, or a workflow out of shape, is not read, and the server's stderr names it. A learning fault never blocks a run: when the folder cannot be made or read, the run starts with nothing learned. A host without git 2.32 or later (what learning's own git calls need) is one such fault, said once on stderr.

What a run learns

When a run that learns answers or fails, its end step (src/runner/reflect-hook.ts) keeps two things, one commit a round on the agent's main, whatever its harness:

  • Its owner's words. A grade's words, or a message they sent after the job's first, become one line of corrections.md, with no model turn: - and the words, whitespace folded. A line that holds one of the server's secrets, text shaped like a secret or a hidden character, or that would take the file past 2048 bytes, is refused whole, nothing of it written, and the run's learning says why (problems).
  • Its job, when a compile is due: once the agent has its learning.compile_after completed runs (20 by default) and no learned workflow, or once per hold of one its promotion held, the server asks the same session one more turn, under the fixed request id learn-reflect-<run id> and the origin reflect, so a server that restarts mid-turn asks again and the run takes it once. The turn (compilePrompt, in src/learn/compile.ts) gives the agent's last runs (each input, its tool calls, its answer and what the person said after it), the workflow language and one worked example, and asks for the whole job as one workflow draft. The draft is checked in code and dry-run; what the checks refuse goes back to the model, as data, up to 3 times. A draft that passes is committed directly, with no grader: its promotion check (below) decides whether it serves. A compile whose drafts all failed is recorded as the compile's attempt (compile once), and its errors are on the run's learning (draft_errors), never silent. src/learn/SPEC.md has the rules.
  • Its answer's quote re-pick, with learning.repick: true (off by default): a workflow whose answer quotes the pages its run fetched re-picks once when a quote is in none of them. Off, the re-pick reads its compact notes and its failed draft. On, the server rewrites the passing draft before it commits it, so the re-pick reads the pages themselves, sent as untrusted data (the model is told never to follow anything written in them, and the step has no tools), at most learning.repick_max_chars characters of them (150000 by default, 1 to 400000; past it the longest pages are cut first). Its request is the served run's, under the run's cost cap. The setting is read at each compile: turning it on or off changes only the workflows compiled after that, never one already kept. An agent whose workflows run through an SDK bridge ignores it.

The turn runs under the run's own cap, with no reserve, and within 10 minutes; its rows are labelled learning, and the run's answer stays the job's. While it runs, the run reads reflecting on every harness. A run with no words from its owner and no compile due spends nothing on learning, and its learning ends dropped (empty). A run whose only tool work was its learned workflows, each answering, with nothing said after its first message and no compile due, ends dropped (empty) too: "Nothing new: the run only ran a learned workflow."

The round's commit is made with plumbing: the passing draft's files added or changed (its README.md with status: pending when a step calls a tool with no price, to wait for its owner's OK) and the owner's line appended to corrections.md. Its message is learning: <run id>: merged, the reason and a Run-Id trailer; main moves only from the commit the change was made on (once more on a main that moved meanwhile), and a run a trailer already names is merged, never twice. A draft file that is not on main as it was on the run's seed is a conflict, never written over.

A new workflow revision serves only once its promotion check passes. For a server-run agent, the first run that lays it replays it on the inputs of the agent's last compile_after completed runs, one replay run each at workflow cost, and scores each against the agent's own recorded answer. It is promoted when it agrees on at least learning.agree_min (0.8) of them and answers at least learning.alone_min (0.7) alone; under either bar it is held, and the next run asks one revision with the inputs it disagreed on. Held again, it stops, and nothing compiles again until its owner acts. A promotion by check is never moved by grades. GET /agents/{agent_id}/learning/promotions reads every record.

Connected SDK agents (Claude Agent SDK, Codex SDK and Eve) check where their original tools live. When an application starts an SDK run with a workflow bridge, learning.workflows contains only compatible promoted revisions. If a compiled draft needs a check, the server instead reserves one candidate in learning.check: {id, revision, digest, workflow} and returns an empty learning.workflows list. The candidate is not a tool for the model. The application completes its ordinary native turn first, then the bridge executes the candidate in shadow using that turn's recorded tool results. It makes no fresh tool calls by default and never repeats a write. A host can explicitly enable shadowReadFallback for its declared read-only callbacks under its original policy. Missing or changed evidence, an input that cannot be bound to the workflow, and unsupported adapters fail the check closed.

The bridge posts one workflow_check event with the reservation's id and digest, its execution outcome (answered, handed_back, failed or skipped_write), and its answer or reason. It does not choose whether the workflow passes. The server compares the answer with the immutable native completion and applies the same agree_min and alone_min promotion policy on the same evidence bar: the check decides once, on compile_after independent native turns, as a server check decides once on that many of the agent's inputs. Each turn is one row, kept on the promotion record (check.turns) while the check waits for the next turn the draft takes; the turn that makes compile_after decides on all of them. Agreement is whole-answer equality (JSON values or trimmed text), or equality of the owner's configured agree_on fields; there is no semantic model grader on this path. A paraphrase can therefore be held even when a person would consider it equivalent.

A start reserves a check only on a turn that can be its baseline: a JSON object task must pass the draft's input schema (a prose task's input is resolved by the bridge), and a start whose task or instructions held a protected value reserves nothing. A reserved turn that still cannot be the baseline (cancelled or failed, incomplete, redacted or workflow-assisted evidence, no workflow_check report, or a shadow that failed or skipped_write) gives the reservation back: the record stays replaying with no runs, counts it in check.released, and the next turn the draft takes is checked. The fifth given-back turn stops the check with nothing checked (no recompile). A turn the backend never completes within an hour is decided as one failed input through the same check, so its hold asks the one recompile and a recompile's check that ends the same way stops. Connected checks' records say via: "sdk"; check.fresh_reads counts the shadow's shadowReadFallback reads.

Concurrent starts reserve at most one check per workflow; retries keep the same reservation, and a late report cannot replace a recorded decision. An older checked champion can still serve while a newer revision is checking or held, except on the independent check turn itself. Learning Off returns neither workflows nor a check. Without a workflow bridge the application gets no workflow to execute. The application's tools, model callbacks and credentials stay in its process; the server receives evidence and the shadow result through the run-scoped SDK credential.

The run's learning (on GET /runs/{run_id}, and {state, reason, detail} in run lists, the detail cut to 140 characters and no time) says how it went: seeded, then reflecting during its end step, and merged, or dropped with a reason from a closed list (seed_failed, no_budget, unknown_cost, cancelled, crashed, reflect_failed, empty, checker, use; a run record with any other reason is not counted). It is null for a 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 workflow's or an imported run). Its detail says the same in a person's words, never the machine's: "Started from 2 corrections.", "Keeping what this run learned…", "Learned the workflow sort-invoice. Kept your correction.", "Nothing new to keep from this run.", "Not kept: it held something that must not be stored (one of this server's secrets).", "Not kept: learning stopped (…)." and so on (learning-words.ts); a client that acts on it reads state and reason. A workflow's name in it is said again at each read from what the run keeps, cut of the server's secrets as they are then before the words are cut short (300 characters, 140 in a list), so a value that became a secret after the run is never shown in part. Once it is merged or dropped (seed_failed included), the run's timeline has one row of kind learning whose summary is that detail. Its read also says how many lines its merge added to corrections.md (corrections) and the workflow it wrote (workflows, each pending while it waits for the owner's OK).

GET /stats counts the runs that tried to learn under learning, over its from, to and agent, from the store (each run's kept learning; in_progress while its end step runs), never opening a run's files.

The learning bench, node scripts/learn-bench.mjs, runs repeated jobs with learning off and on, on pi and claude-agent, and reports the follow rate on repeat steps, the work cost per run and its trend, how often workflows are proposed and reused, staleness after a rule changes, and wrong keeps after a planted request. Six jobs ship with it, in learn-bench/; it calls real models and spends, so it runs on demand or nightly.

Coming

  • A learned workflow's node of a tier runs on the server's model of that tier, at its own price (#2408).
  • A run's workflow draft may call a granted MCP tool: the checks admit it, and one that writes waits for the owner's OK.

What a person sees and controls

A person reads and changes an agent's learning through this server's own routes (learning/1 in /v2/openapi.json), with the token, an archived agent's too:

  • GET /agents/{agent_id}/learning: main's head, corrections.md as corrections, the learned workflows (each its name, files, description, status and etag; status is one word: pending or retired as its README.md says, else where it stands as .../learning/promotions says it: serving, checking, held or stopped, a champion the cost rule stopped included), the first 20 changes on main (newest first, each by: {run} from its Run-Id trailer or {user: true}, with its commit, time, reason and files), how the agent's runs that tried to learn fared (merged, dropped by reason, in_progress), counted as GET /stats counts them, and impact, what learning changed: the agent's completed runs that started from at least one learned item (a correction, or a learned workflow) against those that started before its first, each side's runs; median_duration_s, the time to the answer (the run's start to its job's end, before its end-of-run step). What a run costs, learning included, and what learning itself cost are .../learning/cost's (summary.before/after, the bill's learning_usd). Null unless both sides count 2 runs. An agent with no folder answers main: null, empty lists and impact: null. GET .../learning/log?cursor=&limit= pages on, up to 200 at a time; a cursor reads the same commit its first page did.
  • GET .../learning/corrections: corrections.md on main as {text, etag, cap_bytes} (empty text when there is none). PUT .../learning/corrections with {text} replaces it whole under If-Match: <etag>: a stale ETag is 412, none (or If-Match: *) 428 precondition_required. A text that holds one of the server's secrets, a secret's shape or a hidden character, or passes 2048 bytes, is 422 with the problems, and nothing is written. A text read cut of a secret and sent back keeps the cut: a person's write never puts a secret back. One commit on main in the agent's queue, learning: edited by a person: corrections.md with a Changed-By: user trailer.
  • GET .../learning/files/{file}: corrections.md or a workflow's file on main, with its ETag, the file's git blob id. POST .../learning/files/{file}/retire under If-Match, on a workflow's README.md, sets status: retired: no later run is given it. POST .../learning/files/{file}/approve makes a pending workflow active (see Approving a workflow that waits, below). POST .../learning/files/{file}/restore under If-Match gives a retired workflow to every later run again, after checking its files again as a run's draft is checked (a refusal is 400 with problems, and it stays retired); it takes the owner's password session alone, as an approval does. The learning view gives each workflow last_change ({kind, by, at}: approved, edited, created, retired or restored by a person, or learned by a run) and each retired one retired ({at, by}).
  • GET .../learning/workflows/{name}/revisions lists a learned workflow's revisions on main; GET .../learning/promotions its promotion records; GET .../learning/loop each compile turn; and GET .../learning/cost the agent's cost per run, run after run.
  • DELETE /agents/{agent_id}/learning resets the agent's learning: its learning folder whole (corrections.md, its workflows, their history and the audit ledger), here and on every Archil disk its runs used (503 while one can't be reached), then its promotion records and grades. The agent and its runs stay, with their files, costs and each run's own learning, so the run list, GET /stats and GET /usage read the same (a served run keeps its share of its revision's compile and check); a run's learning diff goes with the folder (404); the next run takes the agent path, given nothing learned. It cancels the runs that exist only for learning (replays, audit shadows) and waits for them; while a run of the agent's own is still going it is 409 learning_busy (each named in details.runs), and nothing is deleted. 204, a second call and an agent that never learned included. The API-only profile serves it too.
  • GET /runs/{run_id}/learning: the run's learning whole (its seed, its merge, the corrections it added, the workflow it wrote, its compile turn's attempts and the checks' problems), null for a run that does not learn. GET /runs/{run_id}/learning/diff: a merged run's merge commit against its parent, each file's patch as git writes it from the first @@, or withheld (too_large, secret).

Every read is the folder's snapshot (.agentrun/snapshot.json, written last by the same exec as each commit to main), the files it names, each checked against its blob id (a file that is not, read twice, is a write in flight: 503), and a merge's .agentrun/diffs/<run>.json, through the folder's file API: no git and no exec. Every text it answers is cut of the server's secrets as they are then; a file name holding one (a workflow named after a value made secret since, say) reads [redacted] whole, in the workflows, the log's files and a diff's path, while its route still answers the real name to a caller who knows it. A log page reads the snapshot alone (it keeps the newest 200 changes). A cursor reads at the main it names while this server still holds that snapshot, else as the first page of main now. Every write to main (a run's merge, a person's corrections, retire, approve or restore) is one exec of the learning script, a compare and swap on main. A symbolic link at the agent's home, its learning folder or the folder's .git is never followed: a read or a write there answers 500, and nothing is written.

Approving a workflow that waits

A learned workflow whose step calls a tool with no price is committed with status: pending in its README.md and given to no run until its owner approves it.

Who can approve: the owner, signed in with their password. No token approves, the server's own included, so a run that reaches this server only through its API (its MCP tools, a sandbox run) can't approve its own workflows. Runs that use bash on the host run as you: they can read this server's files, its session key among them, so no route keeps them from approving. For untrusted tasks, use the sandbox.

POST .../learning/files/{file}/approve (and .../restore, which puts a retired item back into every run) takes the console's password session, sent from this server's own origin with a JSON body as every page write is. Any token is 403: the server's own (what scripts and the MCP endpoint's tools carry) and a token sent beside the session. So is every request on a server with accounts off (AGENTRUN_ACCOUNTS=0), which has no password session: its console session comes from the launch code, never the token. With no credential it is 401, as every route. capabilities.learning.approve is true only for the owner's session; every other caller reads approve: false with approve_needs: "password". A workflow that is not pending is 400; a stale ETag is 412, none 428. The approval is one host commit, learning: approved by a person: <file>, with the trailers Changed-By: user and Approved-Via: console; the log shows by: {user: true, via: "console"} at the commit's time.