Your Agent Says Tests Pass. On Your Laptop. Not on CI.
The agent ran the test command, watched the green checkmark, and said done. You opened the PR. Twenty minutes later CI was red. The agent looked at the failing job, shrugged, and said "works on my machine." It was not being smug. It genuinely had no idea what was on your machine that was not on the runner. This is one of the most common and least discussed failure modes in agentic coding. The…
When an agent runs tests on your machine, it inherits everything that makes your environment unique: environment variables, local databases, specific package versions, and more. However, this doesn't match the conditions of your Continuous Integration (CI) system, which typically runs in a clean, isolated environment. The agent's tests can pass on your machine due to factors like local services or fixtures that won't be present in CI, leading to false positives.
The solution is to make the agent run tests in an environment that mirrors CI, not your local setup. This means running the exact command CI uses, in the same order and with the same setup. This ensures the tests are portable and the "green" result truly reflects CI's outcome. The agent should not alter the environment to pass the tests; instead, it should make the tests self-contained or report dependence on external state.
The PR should include the CI-equivalent command and its output for transparency. This discipline ensures the green checkmark truly signifies a working implementation, not just a passing test on your machine.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to