Why AI Coding Tools Fail: Capability Boundaries and a Defensive Checklist
AI coding tools often fail not because they lack intelligence, but because their capabilities do not match the distribution of engineering risk. This article explains three structural blind spots—computation, perception, and cognition—and offers five categories of controls with acceptance criteria, plus a minimal secure-coding checklist for reviewing AI-generated code.
Why AI Coding Tools Fail: Capability Boundaries and a Defensive Checklist
Recent discussions about “AI programmers causing incidents” keep surfacing: deleting production data, generating code with critical vulnerabilities, being induced into unauthorized operations, and pulling in dependencies of unknown origin. Such cases often get simplified in circulation, and the numbers get exaggerated, so they should not be cited as precise facts. Still, they point to a consistent judgment: the problem is usually not that the tool is “not smart enough,” but that its capability boundaries do not match the distribution of engineering risk.
1. First, Distinguish a Bug from a Paradigm Boundary
Many people’s first reaction is “it wrote sloppy code” or “it wasn’t rigorous enough.” The reality is often the opposite. Today’s mainstream coding models perform quite well on syntactic correctness, logical consistency, and engineering structure. The code they generate frequently passes compilation, static analysis, and unit tests on the first try.
Precisely because they excel on traditional quality dimensions, their failures stand out. The mistake is usually not “writing the wrong code,” but “making the wrong judgment inside correct syntax.” So understanding how these tools fail cannot stop at the code level; you have to go back to how their capabilities are generated.
2. Capability Boundaries: Fitting in a Continuous Space, and Risks That Lack Explicit Representation
Machine intelligence can be summarized as vector fitting, probabilistic optimization, and historical interpolation: input is encoded into vectors, transformed continuously through parameter matrices, turned into a probability distribution, and then sampled into a result. This mechanism is good at approaching an optimal solution where there are plenty of samples, clear definitions, and verifiable feedback.
Engineering risk sits in a more awkward position. Sudden environment changes, implicit business constraints, dependency contamination, adversarial dynamics, and long-term technical debt often lack explicit representation in the model’s input, and are therefore hard to identify reliably. Note the wording: it is not that the model absolutely “cannot see” them, but that “identification is unstable when explicit representation is missing”—rephrase the same question or add a bit of context, and the conclusion may change.
This matters because it also points to mitigation directions. Several approaches can already partially narrow the blind spots:
- Retrieval and external knowledge injection: put internal standards, past incidents, and domain conventions into the context to reduce reliance on parametric memory;
- Tool calls and external validation: let the model call compilers, tests, type checkers, and policy engines, replacing “self-judgment” with “external adjudication”;
- Test feedback loops: multi-round generate–run–fix cycles that hand semantic correctness over to executable verification;
- Structured constraints: schema validation, type systems, explicit configuration, and contract tests that turn implicit assumptions into machine-checkable assertions.
The conclusion is conditional: in scenarios that are testable, retrievable, and constrainable through structure, the risk of AI-generated code drops significantly; where those conditions are missing, the risk is still mainly absorbed by humans. The three types of blind spots below fall squarely on the “conditions missing” side.
3. Three Structural Blind Spots
3.1 Computation: Applying the Optimum from a Historical Distribution to a New Scenario
The model’s coding logic comes from historical data, so it naturally assumes “the environment stays the same, the rules stay the same, the boundaries stay the same.” It then applies the common practice from its training distribution directly to the new scenario in front of it.
A common failure direction is currency and unit conversion. The tool can write valuation code with zero errors and full internal consistency, yet carry over an implicit convention from historical data—“a certain field equals the base-currency price”—while ignoring exchange rate as a dynamic boundary:
# Code generated by the tool: carries over an implicit convention from historical datadef estimate_value_usd(holding, price_feed):return holding.amount * price_feed.latest_price # missing FX conversion# Fixed: local quote must first be converted to the base currencydef estimate_value_usd(holding, price_feed):rate = price_feed.fx_rate(holding.quote_currency) # the key variablereturn holding.amount * price_feed.latest_price * rate
Such deviations typically show up as systematic errors spanning several orders of magnitude, which in real business can cause significant financial loss or reconciliation anomalies—the exact amount depends on position size, field definitions, and detection latency, so it should not be generalized. The core problem is not inaccurate calculation, but calculating very accurately to answer the wrong question.
3.2 Perception: Only Local, Visible Context Is Available
What the model reads—requirements, code, configuration, dependencies—is always local. It can understand the few dozen lines you paste to it, but it does not necessarily grasp the full dependency graph and call chain across the project:
- Dependency name collision or poisoning risk: a package whose name closely resembles a public one may be pulled in by mistake, and neither installation nor import raises an error;
- Transitive dependencies and version drift: direct dependencies are clean, but a deep dependency is replaced or upgraded, and behavior changes accordingly;
- Team conventions: undocumented agreements, such as a field “temporarily” reusing the semantics of another table.
The tool reports “everything is fine” throughout because it verifies that “this piece of code in front of me is correct,” not that “the entire supply chain and global environment are trustworthy.” The defensive focus is not on recognizing attack techniques, but on grounding trust in verifiable evidence: pin sources, verify integrity, restrict what can be installed, and require manual review for every new dependency.
3.3 Cognition: Optimizing Only What Can Be Quantified
The model tends to perform weighted optimization on measurable objectives, while risk, bottom lines, cost, attack surface, and long-term hazards are hard to measure directly and therefore naturally receive low weight in the scoring system.
From community testing and public research, AI-generated functions show a noticeably higher probability of security defects on interfaces involving command execution, file operations, deserialization, path construction, and query building. The differences vary widely across tasks, languages, and evaluation criteria, so no specific percentage is given here—only a qualitative judgment:
# Tool's view: functionally complete, all parameters presentdef run_task(user_input):os.system(f"process {user_input}") # command injection surface# Risk-aware view: use parameterized invocation, avoid shell interpretationimport subprocessdef run_task(user_input: str):subprocess.run(["process", user_input], shell=False, check=True)
The vulnerability shows up neither in syntax errors nor in the quantitative score the model optimizes. What cannot be quantified automatically will not get better automatically.
4. Reducing the Risk of AI-Generated Code: Five Control Categories and Acceptance Criteria
The collaboration model is shifting from “humans write, machines run” to “humans review, machines write.” The danger hides in that swap: when the writer and the reviewer are the same entity, the same blind spot gets written in and then fails to be caught in review, forming a closed loop of blind spots. So the answer is not to wait for the model to have no blind spots, but to use engineering means to bring risks that lack explicit representation back into a controllable range.
| Risk scenario | Control | Acceptance criteria |
|---|---|---|
| Exchange rates, units, time zones, rounding precision | Make implicit assumptions explicit as configuration and types (e.g., Money{currency, amount}) |
Unit tests cover boundary values and invalid input; configuration items are traceable in review |
| Dependency introduction and upgrades | Pin versions and hashes, repository allowlist, enable SCA, manual review for new dependencies | Build is reproducible; SCA reports no critical alerts or has registered exceptions |
| Production data deletion, bulk writes | Least privilege by default, second confirmation, operation audit, rollback-capable snapshots | Cannot execute without human authorization; a rehearsed rollback path exists |
| Command execution / file operations / deserialization | No shell concatenation, path allowlist, reject unsafe deserialization | Scan shows no critical hits; fuzzing and abnormal input stay within bounds |
| Abnormal behavior after release | Logs, monitoring alerts, and audit trails forming an observability loop | Critical paths are traceable; alerts have an owner and a response deadline |
A minimal secure-coding checklist should also be walked through item by item during code review:
- Does external input reach a shell, SQL, a path, or deserialization? If so, has it been switched to parameterized/allowlisted handling?
- Are file reads and writes confined to permitted directories, and is directory traversal prevented?
- Is a new dependency being introduced? What about its source, maintenance activity, license, and any similarly named substitute package?
- Do amounts, timestamps, encodings, and units use explicit types rather than bare
float/str? - Do high-risk interfaces have authentication and auditing, rather than relying on the caller’s good judgment?
As for judgments about architectural soundness, attack surface, and long-term hazards, static scanning, unit tests, and integration tests can only serve as a quantified safety net; in the end, a person with risk awareness still has to sign off.
Conclusion
The problem with AI coding tools is not how smart they are, but that their strengths are concentrated in continuous, quantifiable, verifiable regions. Historical dependence in computation, locality in perception, and a preference for the quantifiable in cognition together form the current capability boundary. This is a stage boundary, not a permanent chasm—it will move as evaluation systems improve, toolchains mature (retrieval, tool calls, test feedback), and guardrails are built.
Recognizing the boundary is not a denial of value, but putting things in the right place: let the tool do the continuous optimization it is good at, and use explicit constraints and human judgment to hold the line on those discrete risks that lack explicit representation.
