All Posts
AI EngineeringAgent Craft · Part 7 of 12

Day 7 – Failure Modes of Coding Agents

Share

Phase 2: Core Techniques (Days 4–7) — Build the tools to measure and improve agent output systematically.

Understanding Core Concepts

1. Hallucination

The agent confidently uses an API method that doesn't exist, a variable that isn't defined, or assumes a library is available when it isn't.

Prevention: Give the agent access to code it can reference (existing patterns, API docs). Test against real compilation/execution, not just linting.

2. Context Drift

Early in the task, the agent understands the requirements. Later, it forgets or reinterprets them and starts solving a different problem.

Prevention: Restate the goal repeatedly. Use short, focused tasks. Break large work into smaller sub-tasks.

3. Off-by-One and Edge Case Blindness

The agent's solution works for the happy path but breaks on boundary conditions: empty collections, null values, single-element lists, maximum integers.

Prevention: Explicit edge case examples in the spec. Test against them specifically.

4. Copy-Paste Errors

The agent reuses code but doesn't adapt it—leaves old variable names, outdated logic, or copy-paste mistakes that would take a human 2 seconds to spot.

Prevention: Clear examples of the pattern, strong tests for each instance, and low tolerance in evaluation for near-duplicates.

Tiny Action for Today (20–30 minutes)

Look at 3 mistakes the agent made recently. Categorize each one:

  • Which failure mode does it match? (hallucination, drift, edge case, copy-paste, or something else?)
  • What information or constraint would have prevented it?

Save these. They inform what to put in specs, context, and test cases next time.

Share
Back to all posts