Series 3 of 4 · AI Evals · Level 1 · Topic 06

The Three Gulfs

The Ground Truth
IN THIS NOTE YOU WILL LEARN
  • 01. The three root causes behind every AI product failure — and why most teams misdiagnose which one they're facing.
  • 02. Why the fix for each gulf is completely different, and why applying the wrong fix wastes months.
  • 03. How to diagnose which gulf caused a specific failure by reading the trace, not guessing from the output.

The Story

Guidelines Central, a clinical decision support company, partnered with John Snow Labs to build an AI system that matches patient cases to clinical guidelines from 35+ medical societies. The model was fluent. It could generate structured clinical suggestions that read like they were written by a specialist. General reasoning benchmarks looked strong.

But when the team tested it against real clinical workflows, the system frequently missed critical patient conditions or mapped them to the wrong guideline sections. A patient with both diabetes and hypertension might get guidance for only the diabetes. A patient on specific medication combinations might get a recommendation that contradicted established drug interaction protocols.

The initial diagnosis was predictable: the model isn't smart enough for this level of clinical reasoning. The team considered upgrading to a larger model or fine-tuning on medical data.

The actual problem was different. The clinical text flowing into the system was unstructured — raw notes written by clinicians in shorthand, abbreviations, and non-standard terminology. The model didn't lack reasoning ability. It lacked machine-readable clinical context. Without a normalization layer mapping to standard medical terminologies, the model was trying to reason over messy, ambiguous text — and sometimes succeeding, sometimes failing.

The team didn't need a smarter model. They needed structured context.

The Core Idea

When an AI product produces a wrong answer, the instinct is to blame the model. This instinct is natural. It's also usually wrong.

The Three Gulfs framework gives you a diagnostic lens for WHY each failure happened — and more importantly, what to do about it. Every AI product failure traces back to one of three gaps.

The Comprehension Gulf — the system misunderstood the input because it had wrong data, missing context, or poorly formatted information. The clinical AI didn't fail at reasoning. It failed because the unstructured text didn't give it the right inputs to reason over.

The Specification Gulf — your instructions to the model were ambiguous, incomplete, or contradictory. The model did exactly what you asked — it just wasn't what you meant. In January 2024, DPD's customer-service chatbot was coaxed into swearing at a customer. The system prompt said "be helpful" but didn't specify how to handle adversarial conversation.

The Generalization Gulf — the model genuinely can't handle this type of input because it's beyond its capability boundary. A model asked to interpret a rare legal statute from a jurisdiction with almost no case law in its training data may simply not have the pattern to draw from. This is the only gulf that's actually a model problem.

Fig 1. The Three Gulfs
THE DEFINITION

Every AI failure lives in one of
three gaps between intent and output.

Find which gulf your failures fall in. The fix depends entirely on the category.
COMPREHENSION

Didn't understand the question.

60-70%

of failures

SPECIFICATION

Understood, but followed wrong rules.

20-30%

of failures

GENERALIZATION

Works usually. Fails on new cases.

5-15%

of failures

A new employee who misreads the brief, follows the wrong process, or can't handle surprises.
Three different problems. Three different fixes.

The reason this framework matters for practitioners: the fix is completely different for each gulf.

A Comprehension failure means your retrieval pipeline, data sources, or context preparation is broken. Fix the data. Don't touch the model.

A Specification failure means your prompts, system instructions, or output templates have gaps. Rewrite the prompt. Don't touch the data pipeline.

A Generalization failure means you've hit a genuine capability boundary. This is the expensive fix — and it's the one teams reach for first, usually when one of the cheaper fixes would have worked.

In my experience across enterprise deployments, the distribution runs roughly: 60-70% of production failures are Comprehension problems, 20-30% are Specification problems, and only 5-15% are genuine Generalization limits.

For agents, the Three Gulfs apply at every step in the chain. The retriever-to-reasoner transition might fail because of a Comprehension gulf. The reasoner-to-tool-executor transition might fail because of a Specification gulf. Each step has its own gulf. A single agent workflow can contain failures from all three gulfs simultaneously, at different steps.

Where This Hits in Production

Multi-tenant diagnostic nightmare. In enterprise B2B, the same agent can fail at the same rate for two different customers — but for completely different gulfs. Tenant A experiences 30% failure because their SharePoint integration drops permissions (Comprehension). Tenant B experiences 30% failure because their custom system prompt contradicts the agent's core routing logic (Specification). A global dashboard showing "30% failure rate" is useless.

Context window overflow as gulf overlap. The RAG pipeline successfully retrieves the perfect documents. Comprehension success. But the payload is 95,000 tokens, and the model's attention degrades. This looks like a Generalization failure — but it was triggered by a Comprehension strategy. The fix isn't a smarter model. It's retrieval that's more selective.

Regulatory specification is a legal liability. In healthcare and financial services, the Specification gulf isn't just about formatting. It involves complex legal disclaimers and regulatory constraints that must be explicitly encoded in the prompt. If the system instructions fail to specify the exact conditions under which a disclaimer must appear, the enterprise is liable — regardless of how capable the underlying model is.

Connecting the Dots

At Levels 1-3 on the autonomy spectrum, Specification failures dominate. The human is still in the loop and catches Comprehension failures naturally. At Levels 5-7, Comprehension failures become the dominant risk — the agent proceeds with bad context and no human catches it until damage is visible downstream.

There's a practitioner discipline hidden here that most teams miss: fix Specification before measuring Generalization. If you build an automated evaluator for a failure mode that's really a Specification gap, you're automating measurement of the wrong thing. Fix the prompt first. Then measure what's left.

!

Common Mistake

Reaching for fine-tuning to solve a Comprehension or Specification problem.

A model consistently ignores a formatting instruction. The team assumes the model needs to be "taught" the correct behavior through supervised fine-tuning — costing tens of thousands of dollars and weeks of work.

What's actually happening: the system instructions are being silently truncated because the context window overflowed, or the retrieved documents contradict the instructions.

The fix hierarchy: (1) Exhaust prompt engineering — hours, not weeks. (2) Exhaust RAG optimization — days. (3) Only then consider fine-tuning — and only for genuine Generalization failures.

In Practice: Diagnosing Which Gulf

RAG systems have a natural diagnostic framework called the RAG Triad: three metrics that each map to a different gulf. Context Relevance maps to Comprehension. Faithfulness maps to Specification. Answer Relevance maps to a different type of Specification failure. All three high but the answer is still wrong? That's Generalization.

# Three metrics, one per gulf
from deepeval.metrics import (
    ContextualRelevancyMetric,
    FaithfulnessMetric,
    AnswerRelevancyMetric
)

comprehension = ContextualRelevancyMetric(threshold=0.8)
specification_faith = FaithfulnessMetric(threshold=0.8)
specification_relevance = AnswerRelevancyMetric(threshold=0.8)

def diagnose_gulf(test_case):
    comp = comprehension.measure(test_case)
    faith = specification_faith.measure(test_case)
    relevance = specification_relevance.measure(test_case)

    if comp < 0.8:
        return "COMPREHENSION: Fix retrieval / data pipeline"
    elif faith < 0.8:
        return "SPECIFICATION: Fix grounding constraints"
    elif relevance < 0.8:
        return "SPECIFICATION: Fix intent interpretation"
    else:
        return "GENERALIZATION: Model capability limit"
Claims Copilot · Gulf Diagnosis · Last 30 days
Traces sampled: 4,200 | Failures: 847

Gulf              Count   %     Top Fix
─────────────────────────────────────────
Comprehension     508    60%   Stale policy docs (v16 → v17)
Specification     254    30%   Multi-jurisdiction prompt gap
Generalization     85    10%   Complex subrogation logic

By tenant:
  Acme Insurance:  72% Comprehension (stale doc index)
  Vertex Health:   55% Specification (custom prompt conflicts)
  RegionCo:        40% Generalization (niche regulatory)
Diagnose the Gulf, Then Pick the Fix

A failure is found in production

Comprehension
The system got the wrong files, stale data, or missing context.
Context Relevance score is LOW
Retrieval returns 2023 policy when 2024 version exists.
Fix the context
Update retrieval, fix data pipeline
Specification
The model followed instructions. The instructions had a gap.
Faithfulness is LOW (context was fine)
DPD chatbot swore at a customer. No profanity constraint existed.
Fix the instructions
Rewrite prompt, add constraints
Generalization
Good context, clear prompt. The model genuinely can't do it.
All scores OK, answer still wrong
Rare legal statute with no case law in training data.
Fix the training data
Fine-tune, swap model, or redesign

Remember This

1. When an AI product fails, diagnose WHICH gulf before choosing a fix. Comprehension (wrong context) → fix the data pipeline. Specification (vague instructions) → fix the prompt. Generalization (capability limit) → consider model changes.

2. Most production failures are Comprehension or Specification problems, not model problems. The distribution is roughly 60-70% context, 20-30% prompt, 5-15% model. You almost never need a bigger model.

3. For agents, each step in the workflow has its own gulf. A single trace can contain Comprehension failures at the retrieval step, Specification failures at the reasoning step, and Generalization failures at the output step — simultaneously.

Previous Topic Back to the Deep Dive