AI Engineering Reference/LLM Foundations

Capabilities, Limitations & Hallucinations

What frontier models reliably do in mid-2026, where they fail silently, and why hallucinations are a feature of the architecture — not a bug you prompt away.

3/5Overview: 30m

Capabilities in mid-2026 (what to trust)

Frontier models (Claude Opus/Sonnet, GPT-4.1/o-series, Gemini 2.5) reliably handle:

TaskReliabilityCaveat
Code generation in familiar languagesHighMay use deprecated APIs; always verify against docs
Refactoring within a single fileHighCross-file refactors need explicit context
Explaining existing codeHighConfident wrong explanations happen
Writing tests from specsMedium-HighEdge cases and mocks often missed
Multi-file architecture decisionsMediumNeeds full context; prone to oversimplification
Precise numerical reasoningMediumUse tools/calculators for money and dates
Real-time facts (versions, CVEs)LowKnowledge cutoff; use RAG or web search

Treat the model as a fast junior engineer with perfect recall of public docs and imperfect recall of your repo.

Limitations that won't prompt away

These are architectural, not tuning problems:

  1. No persistent memory — each call starts fresh unless you inject history
  2. No true grounding — it generates text that looks like facts
  3. Non-determinism — same prompt can yield different outputs
  4. Context truncation — long inputs lose middle sections silently
  5. Tool hallucination — may call functions that don't exist or with wrong args
  6. Sycophancy — agrees with your framing even when you're wrong

Engineering response: verify, don't trust. Every AI output touching production code goes through the same review as a human PR.

Hallucinations: mechanism and taxonomy

A hallucination is the model generating a high-confidence continuation that is factually wrong. It's not a bug — it's the model doing exactly what it was trained to do: produce plausible text.

TypeExampleDetection
Fabricated APIdb.fastQuery() that doesn't existCompile/lint; grep codebase
Wrong signatureCorrect method name, wrong paramsType checker, IDE
Invented citationFake paper title or URLClick the link
Stale syntaxPython 2 patterns in 2026 codeCI with current runtime
Confident nonsensePlausible but wrong architecture rationaleDomain expert review

Guardrails that actually work

Prompting "don't hallucinate" is worthless. These patterns work:

Verify loop: Generate → Lint/Compile → Feed errors back → Retry (max N) Grounding: RAG retrieval → Cite sources → Reject if no source found Tool use: Force factual lookups via MCP/API instead of memory Human gate: AI drafts, human approves before merge Eval suite: Regression tests on known failure cases

Anthropic and OpenAI both recommend structured verification over prompt pleading.

The "confident wrong" problem

The most dangerous failure mode isn't obvious nonsense — it's plausible wrong code that passes a quick glance. Examples:

  • Using async incorrectly but syntactically valid
  • Importing from a package that exists on PyPI but isn't in your requirements.txt
  • Implementing the wrong edge case with clean, idiomatic code

Your defense: tests, types, and CI — the same gates you'd use for any contributor.

When to escalate vs abort

SignalAction
Model contradicts itself in same threadStart fresh with tighter spec
Same error after 2 retry loopsYou're missing context; add files or docs
Output references APIs not in your stackSwitch to RAG or paste the actual API docs
Architectural suggestion feels too cleanIt probably ignores your constraints — push back

Interview framing

"Hallucinations are a property of autoregressive generation, not a configuration bug. I mitigate with retrieval grounding, tool use for facts, compile-time verification, and eval suites for regression. I never ship AI-generated code without the same review bar as human code."

Senior signal: Distinguish knowledge cutoff (fix with RAG) from reasoning failure (fix with decomposition) from instruction drift (fix with rules/specs). Don't lump them as "AI was wrong."

Further Reading

Hands-On Tasks (Optional)

Practical exercises — prompt drills, local MCP servers, or workflow design on paper. The goal is professional fluency, not model training.

  • Catalog three failure modes from your last week

    Review recent AI-assisted work. For each failure (wrong API, invented function, stale syntax), classify it: hallucination, context overflow, instruction drift, or capability gap. Write one guardrail per failure.

    15m