Run
A run is one go of a pipeline for one run request. It starts at one commit of the target repository, records every step in its run journal, and ends exactly once: with a code change, with no code change, stopped, failed or cancelled. A recorded run never changes.
The run is the unit you start, follow, answer and cancel, and the unit codeband keeps. Because the run journal holds every step and its step output, codeband can move a run forward by run replay, wait days for an answer without a running agent, and later fork the run at any agent step to try something else. After this page you know how a run starts, what it records, how it ends and how its run journal relates to the pipeline’s graph.
How a run starts
Section titled “How a run starts”A trigger is what starts a run: it turns what a person asks for into a run request and sends it to the daemon. A codeband run command is one trigger: it builds the run request from its argument and flags. The web interface is another: its start form on the board of a pipeline builds the run request from its fields, as the guide Start a run in the web interface shows.
| Part of the run request | What it says | From codeband run |
From the web interface |
|---|---|---|---|
| Pipeline | Which pipeline runs, named after its factory | The argument, such as py-factory/write_hello |
Pipeline, the pipeline of the board until you choose another |
| Target repository | The repository the run works on | --repo, the current folder by default |
Target repository, an absolute path or a URL |
| Start commit | The commit the run starts from | --commit, HEAD by default |
Branch or commit, HEAD by default |
| Input | The run input as JSON | --input, {} by default |
Input, with the defaults of the pipeline’s parameters |
| Notification channel | Where the run posts the questions of its human steps and the notice of how it ended | The terminal of codeband run |
The web interface |
| Run result destination | Where the run’s code change goes | A patch file, --patch, ./RUN-ID.patch by default |
A patch file, Patch file path, the folder of a local repository by default |
| Title | A name of the run for people, such as Fix the login |
--title, none by default |
Title, none by default |
A run request names one commit by its full commit ID. Each trigger resolves a branch or commit name first: codeband run in the folder of the repository, the web interface through the daemon, which reads a local folder in place and fetches the name from a URL. The daemon pushes nothing to the terminal or the web interface as a notification channel. People see the questions of the run in the streams that codeband run, codeband attach and the web interface read. These are daemon clients, the programs through which a person calls the daemon, and every daemon client can answer the questions and cancel the run, whichever trigger started it.
The title is for people only. It is not part of the run input, and the pipeline code never sees it. codeband ls, codeband show and the run list of the web interface show it, and a run without a title shows its run ID there.
A GitHub issue, a ticket in the ticket system GitHub issues, is a third trigger. A person with write or triage access sets the label codeband/FACTORY/PIPELINE on the issue, and the run input holds the issue and every comment written before the label. A run that an issue starts posts its human step questions and the notice of how it ended in the issue’s thread, its notification channel, and people with write access answer there. Start runs from GitHub issues shows it.
The daemon checks the request before it records anything. It checks that the run result destination can take a code change, fetches the start commit into its own clone of the target repository, and has the code server check the input against the pipeline’s parameters. A request that fails a check records no run, and codeband run prints start run: run request rejected: … and exits with code 1. A request that passes gets a run ID of 10 characters, such as 7cnjg6pm3c, and a run journal whose first journal entry holds the request and the user who sent it.
How a run moves forward
Section titled “How a run moves forward”The engine moves a run forward one invocation at a time. An invocation is one run replay that the code server does for the engine: it runs the pipeline from the start, every step that has a record returns its recorded step output, and the invocation ends at the first step without one or when the pipeline ends. The engine runs that step, writes its value to the run journal and invokes again. A step is a function step, a shell step, an agent step of an agent or a human step.
A run moves forward only from its run journal, so pipeline code must give the same steps in the same order in each run replay. A value that differs between run replays, such as the clock, belongs in a function step, which records it once.
Waiting at a human step
Section titled “Waiting at a human step”A human step is a typed question that pipeline code asks a person. When a run reaches a human step without an answer, the engine records the question and the run waits. No agent runs while it waits, so a run can wait for an hour or a week at no cost. A person answers in the terminal of codeband run or with codeband answer. The code server checks the answer against the human step’s answer type, the first accepted answer is recorded, and the run continues with it.
Agents never wait for a person inside an agent step. An agent that cannot go on without one ends its agent step with an agent question, and the pipeline routes its questions to a human step. The answer goes into a new agent step. A run that goes over a budget on agent steps or cost also stops at a human step. An agent step that paused for hours could not be replayed as one recorded unit, and it would hold a process the whole time.
How a run ends
Section titled “How a run ends”A run ends once, in one of five ways. codeband run prints one final line for each and exits with its code. The run summary in the run store records its run status, which says where the run is: running, waiting for an answer, finished, stopped by its pipeline on purpose, failed or cancelled.
| End | When | Final line | Exit code | Run status |
|---|---|---|---|---|
| Code change delivered | The pipeline returns a code change, and the engine delivers it as a patch file or a pull request | Where the code change went: the patch file’s path or the pull request’s URL | 0 | finished |
| No code change | The pipeline returns no code change, or one whose files equal the start commit’s | no code change |
0 | finished |
| Stopped | The pipeline stops the run on purpose, with a reason | stopped: REASON |
3 | stopped |
| Failed | Pipeline code raises an error it does not catch or no longer matches the run journal, or the engine cannot continue. Run problems lists the kinds | failed: KIND: STEP: MESSAGE |
1 | failed |
| Cancelled | A person cancels the run | cancelled by USER |
4 | cancelled |
The write_hello pipeline of the example py-factory runs one agent step and ends with its code change. Run in a target repository, it ends with the path of the patch file:
Started run 7cnjg6pm3c/home/ada/src/webshop/7cnjg6pm3c.patchThe code change is a commit with a title and a description, made on top of the start commit. The Run result page explains how it becomes a patch file or a pull request. A code change that the engine cannot deliver ends the run with could not deliver the code change: MESSAGE and exit code 1, and the patch stays in the run store.
A cancellation is a person’s request to stop a run. It comes from codeband cancel, from Ctrl-C in the terminal of codeband run or from the web interface. The run records who asked, stops its running agent steps and shell steps, closes its open human steps and ends with cancelled by ada, where ada is that user. A run whose code change the engine has started to deliver takes no cancellation.
While a run has not ended, its run status is running when an invocation or a step is in progress, and waiting when only human steps wait for their answers.
The run summary also names the run’s stage: the stage of the latest step that started in one. A human step between two stage blocks leaves the stage as it is, and a run that has ended keeps the stage it entered last. A run that has not entered a stage has none. While a run goes on, its summary lists the steps that started and have no value yet, each with its kind and its stage. The list is empty after the run ends. The run list of the web interface shows both.
The run journal and the run store
Section titled “The run journal and the run store”The run journal is the ordered list of journal entries that records everything a run has produced so far, and codeband resumes, replays and forks the run from it. A journal entry is one record in a run journal, such as a step that started, a step that finished with its step output, an answer or the end of the run. The entries are numbered from 1 without gaps. The engine writes an entry before the work it announces starts, so after a crash a run journal can show work that started and never finished, but never a result whose work is missing.
The run journal of the write_hello run has eight journal entries:
jq -r 'keys - ["seq", "time"] | .[0]' ~/.local/state/codeband/store/runs/7cnjg6pm3c/journal.jsonlrunStartedinvocationFinishedstepStartedattemptStartedattemptFinishedstepFinishedinvocationFinishedrunFinished| Entry | Records |
|---|---|
runStarted |
The run request with its title, the name of the factory, its folder and commit, and who asked for the run |
invocationFinished |
One invocation: the factory manifest of the code that answered, and its warnings |
stepStarted, stepFinished |
The start of a step, and its value: a function step’s value, an agent step’s step output, a shell step’s result or a human step’s answer |
attemptStarted, attemptFinished |
Each attempt of an agent step by its harness |
cancellationRequested |
A cancellation, and who asked for it |
runFinished |
How the run ended |
The run store is files in the daemon’s state folder. Each run has a folder in store/runs/ with journal.jsonl and run.json, the run summary with its status. Values such as the input, step outputs, function step values and answers sit in the run journal entries as JSON text, so you can read a run journal with jq and compare step outputs across runs without opening other files. Files such as rendered prompts, agent transcripts, the full output of shell steps and patches go to the blob store in store/blobs/, under their content ID. Keeping files out of the run journal keeps it small. Architecture lists every folder of the state folder.
A run continues after the daemon restarts. The run journal holds everything the run needs, so the engine picks up each run that has not ended from its last entry.
Preview graph and observed graph
Section titled “Preview graph and observed graph”A pipeline’s shape lives in its code, as branches, loops and calls, so codeband shows it as two graphs. The preview graph is the shape that the code server infers from the pipeline code before any run. codeband graph prints it, and the web interface draws it:
codeband graph py-factory/intakepy_factory/pipeline.py:21 if not plan.ticketspy_factory/pipeline.py:22 stop "the request has no tickets: write each one as a '- ' bullet"py_factory/pipeline.py:24 if len(plan.tickets) > max_ticketspy_factory/pipeline.py:25 stop f'the request has {len(plan.tickets)} tickets, more than {max_tickets}: split it'py_factory/pipeline.py:27 function step received_atpy_factory/pipeline.py:31 with contextlib.suppress(cb.FunctionStepFailedError)py_factory/pipeline.py:32 function step post_summarypy_factory/pipeline.py:34 returnA block that enters a stage is a node of its own, which names the stage and holds the steps of the block. The web interface draws it as a frame with the stage’s name around those steps:
codeband graph py-factory/write_hellopy_factory/hello.py:51 stage buildpy_factory/hello.py:52 agent step writerpy_factory/hello.py:54 returnThe preview graph is a hint. Code that the analysis cannot follow becomes an opaque node, and a run can start steps that the graph does not show. The engine makes no decision from it.
The observed graph is the path that one or more runs actually took, built from their run journals. The web interface draws it on the pipelines screen and on the page for a run. A run of intake whose request has no bullets took the stop at line 21 and no function step. Its nodes use the same names as the preview graph’s, such as received_at, so the two graphs line up. When they disagree, the run journal is right.
Runs never change
Section titled “Runs never change”A run that has ended stays as its run journal recorded it. To try a different harness, model, prompt or input, you start a new run.
A run fork is a new run that branches off a run at a chosen agent step and points to its parent. The new run reuses the run journal up to that agent step, and the old run never changes. Every change of course leaves a record, and the runs of one task form a tree that you compare by their scores.
Related
Section titled “Related”- Agent step explains the step that runs an agent, and what each agent step records.
- Run result explains how a run’s code change becomes a patch file or a pull request.
- Run problems fixes a run that does not start or fails, by its exact error text.
codeband runlists the flags, final lines and exit codes.