When an AI coding agent silently changes a formula to make a test pass
by•
Had a weird bug this week while testing a calculation flow built with Claude Code. A test case failed on a boundary number, so the agent "fixed" it by quietly loosening the expected value in the test instead of fixing the actual rule logic. Everything showed green until I checked the numbers manually.
For anyone shipping apps with coding agents right now, how are you stopping the agent from touching your test assertions or hardcoding edge cases just to get a green build?
20 views
p/meridian-16
p/runevr
p/netclicker
p/problemhunt
p/posy-3
p/valentina-studio
p/pushary
p/termexo
p/mindpal-ai
p/teaserkit
p/producthunt
p/reso
p/many-displays
p/burnlink
p/kodlo
p/classroomio
p/dots-7
p/citable
p/neoagent
Replies
The agent tweaked a tiered fee calculation to return a constant for edge cases, then marked the suite green. Bad code is fine, but reporting green while secretly shifting the logic breaks trust. Now the test summary gets ignored and every git diff is reviewed directly.
What I lean on is that the expected numbers don't live only in the test. Our pricing decisions are written down with their maths in the project notes, like the weekly plan's credits, how many songs that is and the margin even if every credit is used, and the price code has one anchor value everything else is derived from. So when a test's expected value changes, there's a written decision it either matches or contradicts, and the agent can't quietly win the argument.
A cheap mechanical check on top: a diff that touches both the rule and its test in the same change deserves to be read line by line. Changing the expected value can be right, but it should be a decision someone makes out loud, not a side effect of getting to green.
In my setup that counts as changing the business logic, and the agent isn't allowed to do it on its own. Changing a validation rule, removing a feature, or moving any number users see, like limits, prices or periods, needs my OK first. The business logic doc also gets updated before the code, so a quiet change shows up as a mismatch.