Skip to main content
Kliff

Find and fix bugs

Have an agent reproduce a bug before it fixes anything, then prove the fix with the same steps.

Video coming soon

A bug fix is only as good as the evidence behind it. An agent that changes code because the change looks right may fix the symptom, fix nothing, or break something nearby. The order that works is the one a careful engineer follows: reproduce, then fix, then verify with the same steps. This lesson shows how to set an agent up for each.

Give it everything you saw

Start with what you observed, not your theory of the cause. A good bug report for an agent includes:

  • What happened, with the exact error message or a screenshot.
  • What you expected instead.
  • How to trigger it: the steps, the input, the account type, the browser.
  • Where it happens: the page, the endpoint, or the job.

Select Add files and context to upload a screenshot or a log file with your message. A stack trace pasted in full is worth more than a summary of it.

If you have a guess about the cause, say it is a guess. Otherwise the agent may treat it as fact and stop looking.

Reproduce before fixing

Ask the agent to make the bug happen on its own computer before it changes any code. The strongest reproduction is a test that fails now and should pass after the fix:

Reproduce firsttext
Users with a + in their email cannot reset their password. The reset
link says "invalid token". Write a test that reproduces this and confirm
it fails for the right reason. Do not fix anything yet. Tell me the cause.

Reading the cause before the fix lets you catch a wrong diagnosis early. If the agent cannot reproduce the bug, that is useful too. It usually means a missing step in your report or a difference between environments, and it is far better to learn that now than after a fix that changes nothing.

On the Agents page, the Ship a bug fix starter under the composer shows the same pattern: find a real bug, write a failing test that shows it, fix it, run the tests, and open a draft pull request.

Give the agent a way to run your code

Reproducing needs a working setup: dependencies installed, services configured, the app able to start. When a repository you chose has no setup script yet, the new agent composer offers Set up cloud environment, and an agent writes the setup script for it.

You can manage environments yourself under Cloud. An environment holds a Setup script that runs in each repository before work starts, such as installing dependencies, plus the Allowed hosts its computer may reach and the Secrets it needs, such as API keys. Secret values are encrypted and never shown again.

For bugs you can only see in a running app, ask the agent to start the app and open the Browser app beside the conversation. It shows a server on the agent's computer once something listens on a port, so you can look at the bug yourself. You can also open Terminal and run a command on the agent's computer directly.

Fix it, then prove it

Once the cause is clear, ask for the smallest fix that addresses it, and for the proof:

Fix and verifytext
That cause makes sense. Fix it with the smallest change you can.
Run the new test and show it passing, then run the full test suite.
If anything else fails, stop and tell me before changing more.

Then check the result the way you found the bug. If you reproduced it in the browser, reproduce it again there. If it was a failing request, send the same request. The test proves the code path. Your own steps prove the bug you reported is gone.

When it holds up, ask for a draft pull request, with the cause, the fix, and the test in its description, so the reviewer sees the evidence and not just the diff.

Key points

  • Report what you saw, with exact errors and screenshots, and mark any guess as a guess.
  • Ask for a failing test or a reproduction before any fix, and read the cause first.
  • Set up a cloud environment so the agent can install, run, and test your code.
  • Prove the fix with the new test, the full suite, and the same steps that showed the bug.