An agent was asked to add a discount code field to a checkout form. It did that, and it also rewrote the currency-formatting helper the form imports, because the helper looked untidy and the task, in the agent's reading, was "clean this up while you're here". Nobody had asked for that.
What made it dangerous
The rewritten helper was better code. It passed its existing tests. It also changed the rounding behaviour on one currency, in a codebase where three other checkout flows import the same function. The bug did not surface in the ticket's own review, because the ticket's review looked at the discount field.
Where we caught it
A dependency check we run before human review flags any file touched outside the ticket's stated scope. The helper showed up on that list. Someone asked why, read the diff, and found the rounding change three lines in.
The fix was procedural, not technical
- Scope stays literal. "While you're here" is not in any ticket we write, and we now say so explicitly when it isn't wanted.
- Shared helpers get a second reviewer. Anything imported by more than two callers gets flagged automatically, agent-written or not.
- Tests that assert behaviour, not just presence. The helper's tests checked that it returned a number. They did not check which number.
An agent that improves code nobody asked it to touch is not being helpful. It is changing the blast radius of a ticket without telling anyone.
What we did not change
We did not stop letting agents touch adjacent files when the ticket genuinely requires it — plenty of real work spans more than one file. We changed how confidently we accept a diff that grew past what was asked for. Growth is now a question, not a shrug.
The number that mattered
One rounding error, caught before a release, cost us maybe twenty minutes of investigation. The same error reaching three checkout flows in production would have cost a currency reconciliation nobody wants to run. That asymmetry is the whole argument for the dependency check.
