Software factory / Issues
Reproduce and fix a bug
A bug report arrives with no repro. You want an agent to reproduce the bug, and then open a pull request with a fix and a test.
7 min read
The Issue fix agent reproduces a bug in a sandbox and saves the repro. Then it can fix the bug and open a pull request. By default, it reproduces bugs for authors with triage access or more, and it opens a fix pull request only when someone adds a label. You need admin access to the repository.
1. Turn on Issue fix
- Open Agents. In the sidebar, click Agents under Software factory.
- Turn on the switch of Issue fix. It saves at once.
Issue fix now reproduces the bug of each issue from people with triage access or more. For an issue from anyone else, add the label factory:investigate.
2. Read the repro
The agent reads the issue, writes the smallest repro that it can, and runs it in a sandbox on the default branch. Then it posts one comment with the result, the repro and the files it suspects.
| Verdict | The panel shows | Meaning |
|---|---|---|
reproduced | Investigation: Reproduced | The repro shows the problem. The factory saves it. |
not-reproduced | Investigation: Not reproduced | A repro of the claim of the issue ran, and the code works correctly. |
unclear | Investigation: Unclear | The issue does not say enough, the repro does not run, or the agent cannot check a fact outside the repository that the issue depends on. |
The agent does not deny a fact outside the repository that it did not check, for example a new model of a provider or a new release. The data files of the repository (catalogs, snapshots, fixtures) can be the old data that the issue reports. When the code does not have the thing that the issue names, the repro asserts that the thing is there. The repro fails, and the verdict is reproduced.
To let the agent check such facts on the web, see What Issue fix can read on the web.
The step Verify the linked issue uses the saved repro again, on each pull request that says fixes #N.
3. Pick when it opens a fix pull request
- Click Settings next to Issue fix.
- Under Open a fix PR, pick when Issue fix opens a fix pull request. It saves at once.
| Choice | Issue fix opens a fix pull request |
|---|---|
| Off | Never. |
When labeled factory:fix (the default) | When someone adds the label factory:fix to an issue that it reproduced. |
| Automatically | For each issue that it reproduced, with no label. |
Tip
With When labeled factory:fix, you can add the label at once: the fix waits until the issue is reproduced.
4. Get the fix pull request
The agent runs the saved repro and sees it fail. Then it fixes the code, turns the repro into a regression test, and runs the tests. Last, it opens a pull request from the branch factory/issue-<n> into the default branch. The body starts with Fixes #<n>.
| Verdict | The panel shows | Meaning |
|---|---|---|
opened | Fix PR: Pull request opened | The verdict has the number of the new pull request. |
could-not-fix | Fix PR: Could not fix | The repro or the test still fails, or the pull request did not open. |
no-repro | Fix PR: No repro | The agent has no saved repro to fix from, and the run is not a Fix anyway run. |
When you started Fix PR by hand, you get a notification for the issue when the run ends. When the agent opened a pull request, the notification names it, for example "Fix PR #456". A click opens that pull request.
5. Fix an issue that the agent did not reproduce
The investigation can be wrong. When its verdict is not-reproduced or unclear, you can still start the fix. You need write access to the repository.
- Open the issue.
- In the Factory panel, find the row Fix PR. It shows the line "The investigation did not reproduce this issue. The fix agent writes its own failing test first."
- Click Fix anyway.
If the row has no button (for example, Fix PR ran on the issue before), click Select next to the Factory title. Fix PR says Fix anyway there. Run agents starts it too.
With src, run src factory start <issue number> auto-pr. See Start an agent run.
The agent then works in this order:
- It reads what the investigation found, as data.
- It writes its own test of the problem in the issue, and sees the test fail.
- It fixes the code, and sees the test pass.
- It opens the pull request, as in step 4.
When it cannot write a test that fails, or cannot make the test pass, the verdict is could-not-fix.
- A run that waits: when you start the fix while an investigation runs, the fix waits for it. It starts when the investigation ends with any of the three verdicts.
- A retry: Retry of a Fix anyway run is a Fix anyway run too.
- Starts with no person: Automatically and the label
factory:fixstill start a fix only for areproducedissue.
6. Review the fix
The new pull request goes through screening first, as a pull request from a person without write access does. Then it gets the full pull request steps, the audit too. The issue text can try to steer the fix, so the audit reads it as it reads any other change.
Review it and merge it as you merge any other pull request.
Done
A reproduced bug gets a fix, a test and a pull request that says Fixes #<n>, on the label factory:fix or by itself. A bug that the agent did not reproduce gets the same, when you click Fix anyway.
What Issue fix can read on the web
Some issues depend on facts outside the repository, for example a new model of a provider. Both steps of Issue fix (Investigation and Fix PR) can check such facts on the web. What they get depends on the repository and on the model.
| Tool | The steps get it when | What it does |
|---|---|---|
web_fetch | The repository is public. | Reads one https page or API answer, with no query string. Only text comes back, with a size limit and a time limit. |
| Web search of the provider | The model uses your own Anthropic key, an Anthropic federation, or your own OpenAI key. | Searches the web. With Anthropic, the model makes at most 5 searches in one model call. |
web_fetchuses the same host checks as MCP connections. It does not go to a local, private or internal host, also after a redirect. It sends no credentials and no cookies.- A private repository gets no
web_fetch, because the issue text can try to send private code out. - The provider bills each web search to your key. See Add a model key.
- A Workers AI model gets no web search. This includes the models that the forge calls through its AI Gateway.
To give Issue fix web search, pick an Anthropic or OpenAI model for it. See Pick a model.
Reproduce and fix more issues
- To reproduce the issues of other authors too, change Who starts it of Issue fix. See Pick who starts each agent.
- To fix every reproduced issue, set Open a fix PR to Automatically.