AI
Google Discovers How Outdated Code Comments Waste AI Agent Cycles
Stale technical debt like old TODO comments and resolved bug references cause coding agents to pursue work that wasn't requested, wasting tokens and compute time.
InfoQ
Google researchers have identified a significant efficiency problem in AI coding agents: they get sidetracked by obsolete code artifacts and never fully addressed to-do items. This phenomenon, termed agent distraction, causes autonomous code systems to embark on work that falls outside the scope of the developer's actual request.
The Problem: Outdated Context Misleads Agents#
Stale documentation, abandoned bug tickets, and lingering TODO comments linger in codebases long after they're resolved—but AI systems treat them as active context. When agents encounter these artifacts during code analysis, they often interpret them as legitimate work to address. The result: wasted processing cycles, inflated token consumption, and sometimes flawed logic, according to senior staff engineer Sam Saccone and senior staff data scientist Madhuri Garikapati from Google.
The issue became apparent when researchers examined instances where agents acted on TODO(bug/...) comments without any mention in the developer's original request. Across thousands of engineer sessions and hundreds of millions of agent steps, roughly 13% of sessions exposed agents to these stale inline references—and in 6% of those cases, the agents actually took action on them.
Scale of the Waste#
The detours carry measurable overhead. Agents working on these unintended tasks consumed 70% more execution steps, 77% additional tokens, and took 105% longer to complete compared to focused sessions. Crucially, 41% of these tangential efforts targeted tickets already marked as closed; another 57% involved open bugs that simply weren't part of the developer's scope—what researchers classified as scope creep.
The Fix: Automated Cleanup#
To combat the problem, Google built scanner agents designed to systematically locate and purge obsolete TODOs from the codebase. These agents would dig through years of git history when needed to confirm that both a comment and its underlying intent had become irrelevant. Once verified, the system generated pull requests to remove the outdated references.
Over six months, this cleanup effort removed thousands of genuinely obsolete references, achieving over 95% acceptance from human code reviewers—a strong signal that automated tools can identify stale artifacts reliably without requiring manual intervention at scale.

