System design answer
A coding agent that fixes small bugs
An agent with repository tools in a sandbox, tests as the main check, budgets, and a person reviewing every pull request.
The question“Design an agent that takes a bug ticket, finds the code, makes a fix, runs tests and opens a pull request.”
1Clarify0-5 min
Ask before you draw. These answers change the design.
- What kinds of tickets: small bugs or features?
- Which languages and how big is the codebase?
- Can it run tests and install packages?
- Who reviews and merges?
2Requirements and numbers5-8 min
It must
- Read the ticket and search the code
- Edit files and run tests in a sandbox
- Open a pull request with an explanation
And it must be
- Never pushes to the main branch
- No secrets or network in the sandbox beyond the package mirror
- Cost and time capped per ticket
Numbers to say out loud
- Tickets
- 200 small bugs a week
- Steps
- 20-60 tool calls, up to 15 minutes
- Success target
- About 40% merged without changes
3High-level design8-12 min
- Bug ticket → Agent loop
- Agent loop → Search and read code
- Agent loop → Edit files in a sandbox
- Agent loop → Run tests in a sandbox
- Run tests in a sandbox → fail → Agent loop
- Run tests in a sandbox → pass → Open a pull request
- Open a pull request → A person reviews and merges
4Deep dives12-26 min
Context
The agent searches the repository instead of loading it, keeps notes of what it has learned, and drops old tool output, so long runs stay within the context window.
Sandbox
A container per ticket with the repository, no secrets and network only to the package mirror; CPU and time limits; destroyed afterwards.
5Failures26-30 min
| What can go wrong | What stops it |
|---|---|
| Fix passes tests but is wrong | Human review; the agent adds a test that fails before the fix |
| Endless loops | Step and time caps |
| Dependency confusion or malware | Package mirror only; no internet |
6Evals and monitoring30-33 min
- A set of 100 past bugs with known fixes: share solved, tests added
- Review acceptance rate and reviewer time saved
7Trade-offs33-35 min
- More autonomy saves more time but needs a stronger sandbox
- Small tickets first; features later
Follow-ups to expect
- How would you stop it from deleting tests to make them pass?
- How do you measure value for the team?