Run result
A run result is what a run ends with: a code change, new tickets or both. The code change is the commit, title and description that the run ends with. New tickets are tickets that the pipeline returns for a ticket system. Each part goes to its run result destination: a patch file or a pull request for the code change, ticket files or GitHub issues for the new tickets.
Agents and shell steps work in the daemon’s own clone of the target repository, and every agent step commits to a ref that only codeband reads. Nothing a run does reaches your repository while it runs. The run result destination is the one place where the work leaves codeband, as a patch file that you apply or a pull request that you review. Until then, your branches, your working tree and your git log stay as they were.
How the parts fit together
Section titled “How the parts fit together”- The trigger that starts the run, such as
codeband run, names the run result destination of the code change and the one of new tickets in the run request. The daemon checks both before the run starts, so a run never does its work only to find that it can’t deliver it. - Each agent step ends with an end commit, the commit at which it leaves its workspace. codeband keeps that commit on a hidden ref in the daemon’s clone. The Agent step page explains agent steps and end commits.
- The pipeline returns a run result with a code change: a commit, usually an agent step’s end commit, with a title and a description. A pipeline that returns none ends the run with
no code change. - The engine makes the commit of the code change: one commit on top of the run’s start commit, with the files of the returned commit, the title as its subject and the description as its body. The agent steps may have made ten commits; the commit of the code change is still one.
- The engine delivers the code change to its run result destination and records where it went: a patch file holds the commit of the code change, and a pull request holds the commits of the agent steps.
codeband runprints that place as its final line. - The engine delivers the new tickets to their run result destination and records where each one went, such as the path of its ticket file.
codeband runprints a line for each one after the final line. The engine delivers each part of the run result on its own: when one part fails, the run records the error, and the engine still delivers the other part.
The code change
Section titled “The code change”Your pipeline function ends the run with a code change in its run result. The write_hello pipeline of the example py-factory runs one agent step of the agent writer and builds the code change from the agent step’s end commit and step output:
@cb.pipeline(stages=[build])def write_hello(instruction: str = "add a file hello.txt that says hello") -> cb.RunResult | None: with build: agent_step = writer.do(WriterInput(instruction=instruction))
change = cb.CodeChange(commit=agent_step.commit, title=agent_step.output.title, description=agent_step.output.summary) return cb.RunResult(code_change=change)| Field | Holds | Rules |
|---|---|---|
commit |
The commit whose files the code change holds, such as an agent step’s end commit | A full commit ID that the run knows, such as agent_step.commit |
title |
The subject of the commit of the code change, and so of the patch | One line, not empty. Otherwise the run fails |
description |
The body of the commit of the code change, and the description of a pull request | Can be empty |
branch_label |
A part of the name of a pull request’s branch, such as a ticket ID | Optional. It must fit in a git branch name. The patch file ignores it |
A code change whose commit has the same files as the run’s start commit is no code change. The run ends with no code change, the same as when the pipeline returns none.
New tickets
Section titled “New tickets”A pipeline that plans work, or finds work that it leaves for later, ends the run with new tickets: each one a title, a body in Markdown and tags. A run result can hold new tickets and no code change, or both. The run journal records the new tickets on the entry that ends the run, with where the engine delivered each one, and codeband run and codeband show print a line new ticket: TITLE: WHERE for each one after the line that says how the run ended:
Started run 9d3kq7tmzxno code changenew ticket: Log failed logins: /home/ada/src/webshop/9d3kq7tmzx/01-log-failed-logins.mdnew ticket: Rate-limit the login form: /home/ada/src/webshop/9d3kq7tmzx/02-rate-limit-the-login-form.mdThe page for the run in the web interface lists them under the code change, each with its path or URL. A new ticket has no ID until a ticket system files it. A run that stops or is cancelled has no new tickets, and a run that fails delivers none. When the run fails as the engine makes the commit of its code change, the run journal keeps its new tickets, each with the failure as the reason it was not delivered. Pipeline code never calls a ticket system: an agent proposes tickets in its step output, and the pipeline decides which of them go into the run result. The engine adds a line that names the run to each delivered ticket, so a reader finds the run journal and the agent transcripts behind it. A pipeline that wants to name the ticket that it started from writes that into the body.
New tickets follow the run result destination of the code change: with a patch file they go to ticket files next to it, with a pull request to GitHub issues. --tickets of codeband run names a folder for ticket files and wins over both.
A run files at most 5 new tickets. The engine delivers the first 5 in the order of the run result, and the run journal keeps each other one with the reason over the limit of 5 new tickets. max_new_tickets in the [run_result] table of codeband.toml sets another limit. The limit protects a ticket system from a loop in pipeline code that returns hundreds of tickets.
Ticket files
Section titled “Ticket files”The run result destination ticket files is one Markdown file for each new ticket, in a folder named after the run. It needs no setup and no login. --tickets FOLDER names the folder in which codeband run makes the folder of the run, relative to the folder where you run codeband run. Without it, the folder of the run is next to the patch file. The start form of the web interface has a field for the folder.
codeband run py-factory/intake --tickets /tmp/py-factory-tickets \ --input '{"title": "Release 1.2", "body": "- Fix the crash on start\n- Add a dark mode"}'Started run td7hekxqvv✓ received_at#0 function step✓ post_summary#0 function stepno code changenew ticket: Fix the crash on start: /tmp/py-factory-tickets/td7hekxqvv/01-fix-the-crash-on-start.mdnew ticket: Add a dark mode: /tmp/py-factory-tickets/td7hekxqvv/02-add-a-dark-mode.mdA file’s name is the ticket’s number in the run result and its title in lower-case letters, digits and hyphens. The file holds the tags in YAML front matter, the title as the first # heading, the body and a line that names the run:
---tags: ["feature","small"]---
# Add a dark mode
Part of the request Release 1.2.
From codeband run td7hekxqvv.A run without new tickets makes no folder. The daemon refuses a folder that does not exist or a path that is not absolute before the run starts: codeband run prints start run: run request rejected: the folder /tmp/py-factory-tickets for ticket files does not exist and exits with code 1. A folder that exists but can’t be written fails only the new tickets. The engine still delivers the code change, the run journal keeps each ticket with the error, and codeband run prints new ticket: TITLE: could not deliver: MESSAGE and exits with code 1. When the engine delivers the tickets of a run again, it writes the same file names, so no ticket gets a second file.
A ticket file has no id in its front matter, because a new ticket has none.
GitHub issues
Section titled “GitHub issues”With --pr and without --tickets, the engine files one issue for each new ticket in the GitHub repository of the pull request. It calls the GitHub REST API with the token of the [github] table of codeband.toml, as it does for the pull request. codeband run prints the URL of each issue:
codeband run py-factory/intake --pr \ --input '{"title": "Release 1.2", "body": "- Fix the crash on start\n- Add a dark mode"}'Started run td7hekxqvv✓ received_at#0 function step✓ post_summary#0 function stepno code changenew ticket: Fix the crash on start: https://github.com/acme/webshop/issues/57new ticket: Add a dark mode: https://github.com/acme/webshop/issues/58| Part of the issue | Value |
|---|---|
| Title | The title of the new ticket |
| Body | The body of the new ticket and the line From codeband run RUN-ID. |
| Labels | The tags of the new ticket |
| Other fields | The fields of the new ticket’s extra["github"], with the names of the GitHub REST API, such as assignees and milestone. The title, the body and the labels come from the ticket, also when extra["github"] names them |
extra holds the data of ticket systems, each under its name. The run result destination GitHub issues reads only extra["github"], and ticket files ignore extra, so a pipeline that sets extra["github"] still runs with ticket files. A new ticket with extra={"github": {"assignees": ["octocat"]}} gives an issue assigned to octocat.
When GitHub refuses an issue, such as in a repository without issues, the engine still opens the pull request. The run journal keeps each ticket that it could not file with GitHub’s message, and codeband run prints new ticket: TITLE: could not deliver: MESSAGE and exits with code 1. Before the engine files the issues of a run, it looks in the repository for the issues whose body names the run, so a run that the engine delivers again files no issue twice.
| Run result destination of new tickets | Fits when |
|---|---|
| Ticket files | Your tools or scripts read Markdown files, or you try a pipeline on your machine |
| GitHub issues | Your team plans its work in the issues of the repository that the pull request goes to |
Text that the daemon writes to GitHub
Section titled “Text that the daemon writes to GitHub”An agent that read text from a ticket or a web page can put a mention or a hidden HTML comment into the text that it returns. Before the daemon writes a pull request, an issue or a human step question to GitHub, it changes that text in two ways:
| Change | Why |
|---|---|
An @-mention of a person who is not a collaborator of the repository becomes `@name` |
GitHub notifies nobody outside the repository because of an agent |
An HTML comment, <!-- … -->, is removed |
No hidden text reaches the next person or agent that reads the issue |
The run journal keeps the text that the pipeline returned. That text comes from your pipeline code, which gets each step output and the output of each shell step with the values of the variables already replaced by ***, so a token that an agent printed does not reach GitHub. A variable whose source is value is not masked. The code change is not masked either, so a secret that an agent commits shows in the pull request. Text that your pipeline code takes from elsewhere, such as its own environment, reaches GitHub as it is.
Patch file
Section titled “Patch file”A patch file holds the commit of the code change in the format of git format-patch. codeband run writes the code change to a patch file, and --patch names its path, relative to the folder where you run codeband run; a folder means RUN-ID.patch in that folder, and without --patch the file is RUN-ID.patch in the current folder. The guide End a run with a patch runs write_hello and applies its patch step by step.
codeband run py-factory/write_hello --patch hello.patchThe final line is the absolute path of the patch file, and the command exits with code 0:
Started run 8qqf0wfkgr▸ writer#0 agent step of writer writer#0: writing hello.txt✓ writer#0 finished after 0.2s, $0.00/home/ada/src/webshop/hello.patchThe patch has the title of the code change as its subject and the description as its message:
From 8d02f9293c6397815783a8cdb00f2d9273b95c6e Mon Sep 17 00:00:00 2001From: codeband <codeband@localhost>Date: Tue, 24 Nov 2026 15:34:25 +0100Subject: [PATCH] Add hello.txt
The writer added hello.txt, which says hello.--- hello.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 hello.txt
diff --git a/hello.txt b/hello.txtnew file mode 100644index 0000000..ce01362--- /dev/null+++ b/hello.txt@@ -0,0 +1 @@+hellogit am hello.patch makes a commit Add hello.txt on your current branch, with the description as its message and codeband as its author. git apply hello.patch changes only your working tree, and you commit yourself.
The daemon refuses a patch path where a file already exists, or whose folder is missing, before the run starts. codeband run then prints start run: run request rejected: patch file /home/ada/src/webshop/hello.patch exists and exits with code 1. The daemon writes the patch to a temporary file and renames it, so the path never holds half a patch.
Pull request
Section titled “Pull request”For a pull request, the engine pushes a branch to the GitHub repository of the target repository and opens a draft pull request from it. You mark it ready for review when you have read it. The title and description of the code change become the pull request’s title and description. It is the only time a run creates a branch: agent steps commit to hidden refs, and the branch exists only for the pull request. --pr chooses it, and the [github] table of codeband.toml names the token that the daemon pushes and calls the GitHub REST API with:
codeband run py-factory/write_hello --prThe final line is the URL of the pull request, and the command exits with code 0:
Started run 8qqf0wfkgr▸ writer#0 agent step of writer writer#0: writing hello.txt✓ writer#0 finished after 0.2s, $0.00https://github.com/acme/webshop/pull/42| Part | Value |
|---|---|
| GitHub repository | The owner and name in the URL of the target repository’s origin, or of the remote that --prRemote names. HTTPS and SSH URLs of github.com work |
| Branch it merges into | The run’s start branch: the branch that --commit names, or that HEAD is on. A run without a start branch, such as from a commit ID or a detached HEAD, gets the repository’s default branch |
| Branch | codeband/LABEL-RUNID with a branch_label, where RUNID is the first 6 characters of the run ID, such as codeband/cb-42-8qqf0w. Without a label, codeband/RUN-ID |
| Commits | The commits from the run’s start commit to the returned commit: the agent steps’ own commits and the codeband: leftovers of STEP commits. The commit of the code change is not part of the branch |
The daemon checks the pull request before the run starts. It rejects a remote that is missing or not on github.com, a token without a value, and a start branch that GitHub does not have, so a branch that exists only on your machine needs a push first. codeband run then prints the reason and exits with code 1, and no run is recorded:
start run: run request rejected: branch feature-x is not on GitHub repository acme/webshopWhen the engine delivers a run’s code change again, the push replaces what the branch held, and the engine takes the open pull request from the branch instead of opening a second one. A run that the daemon delivers again after a restart opens no second pull request.
| Run result destination | Fits when |
|---|---|
| Patch file | You want to look at the code change on your machine before anyone else sees it |
| Pull request | Your team reviews the code change where it reviews all other changes to the target repository |
We recommend a pull request for code changes that other people review, and a patch file while you build and try a pipeline.
Deliver a run result later
Section titled “Deliver a run result later”The engine delivers a run result once, when the run ends, to the run result destination of the run request. A run fork delivers nothing on its own. To deliver the recorded run result of a run that ended, such as the run fork whose code change you liked best, run codeband deliver with the run ID, or use Deliver on the page for the run:
codeband deliver --pr 7kq2m9xw4dThe engine delivers the code change and the new tickets that the run journal holds, as it would have at the end of the run, and records where each part went. Nothing runs again. A run that delivered to a patch file can deliver to a pull request this way, after you read the patch.
Hidden refs
Section titled “Hidden refs”A hidden ref is a git ref under refs/codeband/, outside refs/heads/ and refs/tags/, so git branch and git tag don’t list it. After the run of write_hello, the daemon’s clone of the target repository, in repos/ of the state folder, held these refs:
349efe1f496b6c9ad1f8de406ed58e2040a7f7ba commit refs/codeband/runs/8qqf0wfkgr/attempts/writer/0/08d02f9293c6397815783a8cdb00f2d9273b95c6e commit refs/codeband/runs/8qqf0wfkgr/code_change88a7e887355e27d105de57b84340d18ab484d997 commit refs/codeband/runs/8qqf0wfkgr/start349efe1f496b6c9ad1f8de406ed58e2040a7f7ba commit refs/codeband/runs/8qqf0wfkgr/agent_steps/writer/0Ref under refs/codeband/runs/RUN-ID/ |
Points to |
|---|---|
start |
The run’s start commit. The ref keeps it safe from git gc |
attempts/AGENT/N/K |
The end commit of attempt K of the agent step AGENT#N, failed attempts too |
agent_steps/AGENT/N |
The end commit of the agent step AGENT#N: the commit of its last attempt |
code_change |
The commit of the code change, which a patch file holds. Its ID is the From line of the patch |
The agent name and the counter are separate path parts, agent_steps/writer/0 and not writer#0, because # is special in some shells.
Why run results work this way
Section titled “Why run results work this way”Agent steps commit to hidden refs, not branches
Section titled “Agent steps commit to hidden refs, not branches”Many runs and many agent steps of one run work on the same target repository at the same time. A branch for each of them would flood git branch and collide between runs. Hidden refs keep every end commit, so git can compare any two agent steps, and a real branch appears only for the pull request.
The repository holds code, not run data
Section titled “The repository holds code, not run data”Run journals, agent transcripts and other run data stay in the run store, linked to the commits by their IDs. An agent transcript can hold secrets that anyone with access to the repository could read, and run data would make the history grow with every run.
The daemon never writes to your clone
Section titled “The daemon never writes to your clone”The daemon fetches each start commit into its own bare clone and works only there. It is the one writer of everything it depends on, so your git gc or a rewrite of your branches can’t remove a run’s commits, and codeband’s workspaces and refs stay out of your git worktree list and git log --all. You get the work as a patch or a pull request. Uncommitted changes in your working tree are never part of a run: codeband run warns about them and starts the run without them.
A pull request keeps the commits of the agent steps
Section titled “A pull request keeps the commits of the agent steps”The agents split their work into commits, such as one per Conventional Commit, and a reviewer reads that history in the pull request. The patch file is one commit, because you apply it to your own branch and commit it as you like.
A code change that the engine could not deliver stays
Section titled “A code change that the engine could not deliver stays”The engine makes the commit of the code change and keeps its patch in the run store before it delivers. When it cannot deliver, the run still ends with its code change, the code_change ref still points to it, and codeband run prints could not deliver the code change: MESSAGE and exits with code 1.
Related
Section titled “Related”- Run lists the ways a run ends, of which a delivered code change is one.
- Agent step explains end commits and the workspaces that agent steps run in.
codeband runlists--patch,--pr,--tickets, the final lines and the exit codes.- Architecture shows the state folder, its bare clones in
repos/and the run store.