Software factory / Runs
Start an agent run
An agent is on, but the Factory panel of a pull request or an issue says Not run yet. Or you changed something, and you want a new verdict now, without a push or a label. Or ten pull requests came in, and you want the same agents on all of them.
9 min read
You need:
- Write access to the repository.
1. Run all agents, or pick some
- Open the pull request or the issue.
- In the Factory panel, next to the Factory title:
- To run every step that can run now, click Run agents. The steps start at once. Go to Read the verdict.
- To pick steps, click Select, then turn on the checkbox of each step that you want.
The picker lists each step of the agents that are on, for this kind of item, that can run. Each step has one line that says what it does. A step that ran on the item before says Run again.
A step that cannot run on the item is not in the list, for example CI self-heal when no CI run failed. See When an agent cannot run. A step that waits only for its own run, or for another step that changes the branch now, is in the list: its row is grey and shows the reason. It can run again when that run ends.
When a step that you pick needs another step first, its row says Starts after and the name of that step. See Agents that wait for another agent.
2. Click Start
Click Start. The button shows how many agents you picked, for example Start 2 agents.
Each step that you picked gets a new run, also when it ran on this commit before. The rows of the panel show each run that started, and each run that waits for another step. When a step did not start, the line under the Factory title says why, for example:
Keep green: CI self-heal did not start. No CI run failed on this commit.
To start one agent only, you can also use the row of the panel that says Not run yet. When the agent can run now, the row has a Run button.
Note
A run that you start skips the trigger of the agent (Who starts it, or a label such as factory:fix). It also skips the daily run limit of the author, and does not count toward it. The monthly spend cap still holds.
3. Read the verdict
The run shows in the list of runs of the Factory panel, as Waiting and then Running. When it ends, the panel shows its verdict. Then the factory goes on with the next steps, as after any other run.
You do not have to watch the page. When the first run that you started ends, the bell in the header gets one notification for the item, for example "Agents finished on #12". It lists each agent, with done or failed.
- While the notification is unread, each next run that you started on the item and that ends goes into it.
- When a run failed, it shows under Waiting on you.
- A run that you stop sends nothing. Runs that start by themselves, for example on a push, send nothing.
See Agent runs that you started. To turn these notifications off, clear Agent runs that you started in your notification settings.
The Conflict fixer step of Keep green looks for a conflict only when you start it. If there is no conflict, the panel says that the run did not start, and why.
Done
The agents ran on the item now, with no push and no label. To read what they did, see Read the log of a run.
Agents that wait for another agent
Some steps need the result of another step on the same commit. For example, PR review needs a clean Security audit first, so a review does not run on code that can attack the sandbox.
| Step | It needs first |
|---|---|
| Value check, Fixes the issue, PR review | A clean Security audit, when the Security audit agent is on. |
| Fixer | A review with findings. When the author has no write access, also a clean Security audit. |
| Conflict fixer, CI self-heal | A clean Security audit, when the author has no write access. |
| Classify | The end of the PR impact run, when PR impact is on. |
| Fix PR | An investigation of the issue that ended with a verdict. After not-reproduced or unclear, the run is a Fix anyway run. |
What happens to the step that it needs:
- You picked it too: it gets a new run. Your other step waits in a queue, and starts when that run ends well.
- You did not pick it, and it has a good result on this commit: your step uses that result, and starts now.
- You did not pick it, and it has no good result: it starts first, and your step waits in a queue.
- It is off: Fixer, Conflict fixer, CI self-heal and Fix PR are grey, with a reason such as "Needs the Security audit agent, which is off." The other steps start without it.
A step that waits in the queue does not start in these cases. It shows in the list of runs as skipped, with the reason:
- The run that it waits for failed or was stopped.
- That run gave nothing to work on: a suspicious or malicious audit, a review with no findings, or a
reproducedinvestigation with no saved repro. - Someone pushed a new commit to the pull request.
- The item was closed or held for screening, or a ban holds its author.
Start agents on many items
- Open the list of pull requests or the list of issues.
- Turn on the checkbox of each item that you want. To pick each item of the page, turn on Select all on this page.
- In the bar above the list, click Run agents.
- Turn on the checkbox of each agent that you want, then click Start.
You can pick at most 50 items at a time. When you try to pick more, the list says "Select at most 50 pull requests at a time." Clear removes your picks. The row of a stack has no checkbox, because it is a group of pull requests.
The picker shows each agent of this kind of item. An agent that is off on the repository does not start. Each item follows the rules of Agents that wait for another agent.
The notice above the list counts the runs, then gives one line for each step and reason that skipped a run:
Started 2 runs, queued 1 run and skipped 4 runs.
PR review on #128 and #127: The review agent is off.
Items from GitHub
On a repository with GitHub sync, a run that you start on an item from GitHub acts on GitHub as you. Its comments, reviews, labels and assignees go to GitHub with your GitHub token. See What agents can do.
From src, MCP or REST
Your coding agent pushed a fix to pull request #12, and it wants a new review now. It can start the agent, then read the run:
src factory start 12 review
src factory run <run id>
src factory start prints the id of the run. If the agent waits for another agent, or no run starts, it says so and exits with 0.
To start several agents on several items, put commas between the numbers, and a space between the agents:
src factory start 12,14 audit review
It prints one line for each item and agent:
#12 audit: started run-7
#12 review: queued behind audit
#14 audit: skipped: <reason>
With --json, --jq or --template, each result has the fields number, agent, runId, queuedBehind and skipped.
- MCP: the tool
start_factory_run, withowner,repo,numberornumbers(at most 50), andagentoragents(at most 20). For one number and one agent, it gives backrunId,queuedBehindorskippedwith the reason. For a list, it gives backresults. Read a run withget_factory_run. - REST:
POST /api/v1/repos/{owner}/{repo}/factory/runs. See the answers below.
| Body | Answer |
|---|---|
{ "number": 12, "agent": "review" } | 201 with { "runId": "..." }, 202 with { "queuedBehind": "audit" }, or 200 with { "skipped": "<reason>" } |
{ "numbers": [12, 14], "agents": ["audit", "review"] } | { "results": [{ "number": 12, "agent": "audit", "runId": "..." }, ...] }. 201 when at least one agent started or waits in the queue, else 200. |
The body { "number": 12, "agents": ["audit", "review"] } works too. More than 50 items or more than 20 agents gets the answer 400.
In all three, agent is the id of a built-in step from the tables below. Any other id gets the answer 400. The same rules hold as on the page.
Note
Only people start agents by hand. Your own login and your own tokens work, a scoped token too, with write access. The token of an agent session, a job or an app gets the answer 403: "Only people start factory agents by hand".
When an agent cannot run
These rules hold for each agent:
- Only the built-in agents start this way. Custom agents do not.
- The agent and the step must be on, and the step must run on this kind of item. For example, triage runs on issues only.
- A run of the same step that is still waiting or running blocks a second run. Wait until it ends.
- The factory does not run on an item that is closed, or that screening holds.
- When a ban holds the author, only Spam can run.
Some steps need something to work on:
| Step | It needs |
|---|---|
Fixes the issue (fixes-issue) | The pull request names an issue that it fixes, for example fixes #12. |
CI self-heal (ci-heal) | A CI run on the head commit failed. |
Conflict fixer (conflicts) | The pull request conflicts with its base now. |
Assign (assign) | Nobody is assigned yet. |
The agents you can start
You start one step of an agent. The picker shows the name of the agent and of the step, for example PR review: Fixer. A step with the same id as its agent shows the name of the agent only, for example PR review or Triage. Your own agent types the id of the step.
On a pull request:
| Agent | Step | Id to type |
|---|---|---|
| Security audit | audit | |
| PR review | Review | review |
| PR review | Value check | value |
| PR review | Fixes the issue | fixes-issue |
| PR review | Fixer | fixer |
| Keep green | Conflict fixer | conflicts |
| Keep green | CI self-heal | ci-heal |
| PR summary | PR impact | impact |
| PR summary | PR domains | domains |
| PR summary | Classify | classify |
| Spam | spam |
On an issue:
| Agent | Step | Id to type |
|---|---|---|
| Triage | triage | |
| Assign | assign | |
| Issue fix | Investigation | investigate |
| Issue fix | Fix PR | auto-pr |
| Spam | spam |