How I Added a Blast Radius Map... Note

How I Added a Blast Radius Map to My AI Agent—It Caught a Bug Before CI Did

When AI agents autonomously modify code, unanticipated ripple effects pose a significant risk, as traditional CI often misses global impacts. To address this, the author developed a "blast radius map," a dependency graph of code entities enriched with metadata like test coverage and runtime call frequency. This map helps AI agents proactively identify what might break before code changes are made.The process involves three steps: extracting a dependency graph, computing reverse reachability, and enriching the map with risk metadata. The dependency graph, initially built at the file level (and later enhanced to function level), shows what relies on what. Reverse reachability identifies all code impacted by a change. Risk metadata, including test coverage, criticality scores, and change frequency, quantifies the risk associated with each affected node.A real-world example demonstrated the map's effectiveness. An AI agent, refactoring a date utility function, used the map to identify an uncritically covered billing service. The agent ran a targeted smoke test, immediately uncovering a daylight saving time bug that CI would have missed. This proactive approach prevented a production issue.The AI agent integrates the blast radius map into its planning phase. Before any edit, it proposes changes, computes the blast radius, assesses risk, and, if critical, uncovered files are affected, generates and runs a smoke test. If the test fails, the agent revises its plan.Practical implementation involves choosing granularity (file or function level), incrementally building the graph, integrating it as a tool for the agent, and defining safety policies. While effective, the map has limitations, such as handling dynamic imports or reflection. Ultimately, AI agents need system awareness beyond code completion, and a blast radius map provides critical foresight for self-correction.