Finding backend performance wins with a coding agent
Scott Cooper · 3 November 2026
Read the originalA Sentry engineer pointed an AI agent at Sentry's own performance data, tested each fix on a copy of the database, and removed hundreds of millions of weekly queries.
Scott Cooper, an engineer at Sentry, which sells software that tracks errors and slow code, spent several weeks using an AI agent to find slow backend code. He connected the AI agent to Sentry's own performance data through Sentry's MCP server, a connector that lets AI agents query a product. Most fixes changed a line or two of code.
- The AI agent ranked database queries by how often they ran and how long they took, and gave a file, a line and an example for each.
- Before changing anything, Cooper had the AI agent read the code and its change history and say what might break. He steered it away from areas he did not know.
- The AI agent tested each query change on a read-only copy of the database, and every pull request linked to an example showing the extra work it removed.
- One fix removed an estimated 143 million unnecessary database reads a week, and another cut a query from 935 milliseconds to 0.4 milliseconds on the copy.
Engineers who hand performance work to an AI agent can ask for evidence before review: a stated risk, a test on a copy of the data and a linked example. This is Sentry's account of work done with its own product.
Have the AI agent read the code and its change history and state what might break before it changes anything.
Have the AI agent test each database query change on a read-only copy of the database before it opens a pull request.
Derived by Working Surface from the article; more in the Playbook. Source line: Making sure the agent has the ability to validate changes in the read-only database rather than guessing leads to much better results.
7 November 2026: teams using AI agents are judging work by evidence they can check, and are naming the people who decide what counts as good.