Back to Hub
Certification Study Notes

Knowledge Engineering

Vendor-neutral guide to the data and interface layer under every grounded AI agent: the 3-phase, 7-step framework (layout-aware ingestion, normalization, structure-aware chunking, metadata & provenance, hybrid indexes, knowledge graphs & ontologies, typed retrieval tools), the progressive scaling ladder, a symptom-to-fix diagnostic sheet, and how to keep the knowledge layer multimodal, permission-aware, fresh, and measurable.

Author: Michaël Bettan
Track: Knowledge & Retrieval
Test Yourself: Knowledge Engineering Practice Quiz →
00

Overview & Mental Model

Definition

Knowledge Engineering for AI agents is the discipline of transforming raw, unstructured enterprise data into structured, traceable, and mistake-proof retrieval systems and tools (Agent-Computer Interfaces) so an LLM can reason over verified ground truth.

Core thesis: an agent is only as reliable as the ground truth returned by its tools. Even the most sophisticated reasoning loop (ReAct, Evaluator-Optimizer, Orchestrator-Workers) will confidently hallucinate if its knowledge layer drops tables, bisects clauses, ignores document versions, or misses multi-hop entity relationships.

The 5 structural gaps it solves

  • Silent parsing corruption: naive extractors (pypdf) strip table grids, scramble multi-column layouts, and return empty strings on scans.
  • Severed logical context: fixed-token chunking slices clauses away from their exceptions and table rows from their headers.
  • Permission & version blindness: pure vector similarity ignores whether a policy is superseded, expired, or restricted to another tenant's ACL.
  • Lexical & relational blindness: dense embeddings miss exact SKUs, clause IDs, and error codes; flat chunks cannot traverse multi-hop dependencies (A → B → C).
  • Ambiguous tool interfaces: a single generic search_all(query: str) tool forces the model to guess query syntax and filters.

Mental model: nervous system vs. library

Agentic Design Patterns build the nervous system (how the agent thinks, loops, and asks for human approval). Knowledge Engineering builds the library and catalog: how raw files become clean books, indexed by topic, keyword, and citation network, with a librarian desk of specialized lookup tools.

Scope vs. the RAG guide

The RAG guide covers the retrieve-then-generate pipeline end to end (embeddings, retrieval, reranking, generation, evaluation). This guide focuses on the data and interface layer underneath it: turning raw sources into clean, traceable, permission-aware knowledge and exposing it through safe agent tools.

01

1. Naive RAG vs. Agentic Knowledge Engineering

DimensionNaive RAG (Prototype)Knowledge Engineering (Production)Memory Hook
ParsingRaw text stream (drops tables & layout)Layout-aware vision/OCR (Docling, Document AI; preserves tables)"Read the page layout, not just the raw bytes"
ChunkingFixed size (e.g., every 500 tokens)Structure-aware (split by section, clause, or intact table)"Cut at chapter seams, never mid-sentence"
ContextRaw text onlyRich metadata & provenance (doc_id, version, date, owner)"Every quote carries its birth certificate"
SearchVector similarity onlyHybrid (Vector + BM25) + metadata pre-filters + Knowledge Graph"Meaning + exact IDs + relationship web"
Agent AccessPassive prompt stuffing (1 generic search)Active, strongly-typed Retrieval Tools (ACI / MCP)"Specialized scalpel tools, not one blunt shovel"

Exam & production trap: a bigger model will not fix bad data

Upgrading the foundation model (e.g., from a fast tier to a frontier tier) cannot fix an upstream knowledge engineering failure. If a parser drops a table column or a 500-token split cuts out a "provided, however, that..." exception clause, a smarter model only hallucinates more persuasively.

02

2. The 3-Phase Framework (7 Steps to Memorize)

Instead of memorizing 7 isolated items, group them into 3 logical phases: Prepare → Index → Expose.

Phase 1: Prepare (Structure & Provenance)
1. Ingestion
Layout / OCR
→
2. Structuring
MD / JSON / Tables
→
3. Structure Chunking
Sections, clauses
→
4. Metadata & Provenance
doc_id, version, ACL
Phase 2: Index (Representation) → Phase 3: Expose (Agent Interface)
5. Hybrid Index
Dense + BM25 + RRF
+
6. Knowledge Graph
Entity → Relation → Entity
→
7. Retrieval Tools
Typed ACI / MCP

P1Phase 1: PREPARE — Make Data Clean, Complete & Traceable

Step 1: Document Ingestion

What: extract content from raw enterprise formats (PDFs, DOCX, HTML, scans, emails, spreadsheets) with layout-aware and OCR-capable parsers instead of raw character-stream readers.

Why: standard text extractors (pypdf) fail silently on scans, multi-column layouts, and complex tables: garbage in, confident hallucination out.

Production pattern (tiered extraction & epistemic gating):

  • Tier 1 — fast stream (~0.05 s): pypdf/pdfplumber on clean, single-column digital PDFs.
  • Tier 2 — layout/vision OCR fallback (2–10 s): route low-density pages, tables, or scans to Docling (local layout model + TableFormer + OCR) or a managed cloud parser (e.g., Google Document AI).
  • Composite extraction quality gate: score OCR confidence, dictionary-word ratio, character entropy, and structural completeness; hard-stop below a threshold (e.g., < 0.70) before indexing or calling an LLM.

Step 2: Normalization & Structuring

What: convert raw extracted text into a clean, canonical hierarchy: Markdown with explicit # / ## / ### headings, serialized Markdown/HTML tables, structured JSON records, and normalized entities (ISO-8601 YYYY-MM-DD dates, standardized currency/units).

Why: LLMs and downstream chunkers rely on structural markers to understand scope: which sub-clause belongs to which article, which cell belongs to which column header.

Key output: a typed document object (such as DoclingDocument) preserving reading order, section hierarchy, bounding boxes, and table grids.

Step 3: Structure-Aware Chunking

What: split along logical and semantic boundaries (sections, subsections, complete tables, atomic clauses), not arbitrary fixed token counts.

Why: fixed-token chunking cuts rules from their exceptions ("The vendor is liable for all damages..." in chunk 1; "...except indirect or consequential damages" in chunk 2) and separates table rows from headers.

  • Header-aware chunking (HybridChunker): starts from the document hierarchy, splits oversized chunks and merges undersized siblings to respect the embedding tokenizer's limit.
  • Intact table preservation: serialize tables whole, or attach column headers to every row group.
  • Parent-child chunking: embed small child chunks (128–256 tokens) for precise matching; return the larger parent section (1,024–2,048 tokens) to the LLM.
  • Contextual retrieval (Anthropic pattern): prepend a short, chunk-specific context before computing both the embedding and the BM25 index. Anthropic's version has an LLM read the whole document plus the chunk and write ~50–100 tokens; a cheap fallback is a breadcrumb such as [Doc: MSA_2026 | Section 8.2: Limitation of Liability].

Step 4: Metadata & Provenance

What: a mandatory, structured metadata envelope on every chunk:

  • Provenance & location: source_uri, doc_id, section_path, page_number, bounding_box.
  • Lifecycle & governance: created_date, effective_date, expiration_date, version, status ("active" vs. "superseded"), owner, access_acl / tenant_id.

Solves two problems:

  • Pre-search deterministic filtering: exclude expired policies, drafts, or another tenant's records before vector scoring runs.
  • Post-generation auditability: exact inline citations ((Source: Section 4.2, Page 14)) that humans or auditor nodes can verify deterministically.

P2Phase 2: INDEX — Make Knowledge Findable by Meaning, Keyword & Relationship

Step 5: Embeddings & Hybrid Indexes

  • Dense vector search: maps text into continuous space (768–3,072 dims, served via ANN indexes such as HNSW or ScaNN) to capture meaning, intent, and synonyms ("termination for cause" ↔ "ending the agreement due to breach").
  • Sparse lexical search (BM25): scores exact token matches using term-frequency saturation, IDF, and length normalization; catches SKUs, part numbers, error codes, clause numbers (Section 12.4(b)), acronyms, and proper nouns.

Why both: dense vectors blur exact alphanumeric IDs; keyword search misses paraphrases. Run both in parallel, fuse with Reciprocal Rank Fusion, then pass the top-K (≈50) through a cross-encoder reranker (e.g., Cohere Rerank, BGE-Reranker, or a managed cloud ranking API) to keep the top-N (≈5).

Step 6: Knowledge Graph & Ontology

What: domain knowledge as explicit nodes (entities) and directed edges (relationships) governed by a formal schema (ontology).

Why: vector and keyword indexes find passages with similar text, but fail on multi-hop relational reasoning, dependency tracing, or aggregation across isolated documents.

  • Ontology (schema / TBox): allowed entity classes (Contract, Party, Clause), predicates (governed_by, supersedes), and constraints (RDFS, OWL, or typed schemas).
  • Knowledge Graph (instances / ABox): the populated network of real entities and edges (stored in a graph database; queried via Cypher, GQL, or SPARQL).
  • Hybrid GraphRAG: use hybrid search to find the entry entity, traverse 1–3 hops along ontology edges, and pass both the subgraph path and source chunks to the LLM. See RAG → GraphRAG.
Reciprocal Rank Fusion (RRF) — merge ranked lists by rank, not raw score
RRF(d) = ∑m ∈ {Dense, BM25} 1 / (60 + rankm(d))
Cosine and BM25 scores live on different scales, so RRF uses only ranks (k = 60 is the conventional constant). Documents ranked well by both retrievers rise to the top.
Multi-hop example — the answer lives in the edges, not in any single chunk
[Service: Checkout-API] ──(depends_on)──► [DB: Payments-Cluster-02]
                                                     │
                                               (hosted_in)
                                                     ▼
[Policy: PCI-DSS-v4] ◄──(governed_by)─── [Region: eu-central-1]

P3Phase 3: EXPOSE — Turn Indexes into Agent Tools

Step 7: Retrieval Tools (the Agent-Computer Interface)

What: wrap hybrid indexes, metadata filters, and knowledge graphs into narrow, strongly-typed, mistake-proof functions (often exposed via MCP) that the agent invokes intentionally.

Why: one vague search_all(query: str) tool is an anti-pattern: the model must guess how to phrase queries, cannot enforce deterministic metadata constraints, and floods its own context window with noisy chunks.

Python (illustrative) — replace search_all(query) with intent-specific, typed tools
def get_policy_by_id(policy_id: str) -> PolicyRecord: ...
    # exact key / BM25 lookup

def search_active_clauses(
    category: Literal["indemnity", "termination", "ip"],
    jurisdiction: str,
    effective_after: date,
    top_k: int = Field(default=5, le=10),
) -> list[ChunkWithProvenance]: ...
    # hybrid search with mandatory pre-filters (status="active", user ACL)

def trace_system_dependencies(service_name: str, max_hops: int = 2) -> SubgraphPath: ...
    # deterministic graph traversal

Structured data tools: parameterized queries vs. NL2SQL

Questions such as "total refunds by region last quarter" need exact filters, joins and aggregates, which embeddings cannot compute. Expose tables through a query tool instead of indexing rows as text, and choose the most constrained tool shape that still answers the questions users actually ask.

Tool shapeWho writes the SQLUse whenMain riskCore controls
Parameterized query tool
get_refunds_by_region(region, quarter)
An engineer, ahead of time; the model only fills typed argumentsQuestions are known and recurring; customer-facing paths; anything that writesCannot answer questions outside the tool catalogEnum and typed arguments, bound parameters, never string concatenation
NL2SQL over a curated layer
(approved views plus metric definitions)
The model, against a small set of documented viewsAnalysts ask varied questions over a well-defined domainA wrong join or metric definition that still returns a plausible numberApproved views only, a metric glossary in context, verified example queries
Open NL2SQL over the schema
(execute_sql)
The model, against any table it can discoverExploration by trusted internal users in a sandboxExpensive scans, data exposure, injected text steering the queryEverything below, plus human review before results are shared

Guardrails for any model-written SQL

03

3. Progressive Scaling Ladder: When Do You Need Which Steps?

Apply progressive complexity (Rule 0 from Agentic Design Patterns): add indexing and graph layers only when corpus scale or query topology proves the simpler level falls short.

Q1

Does the knowledge fit in the context window?

1 to a few documents per run → Level 1. Hundreds to millions of documents → go to Q2.

Q2

Do queries need multi-hop traversal?

Fact, clause, or procedure lookup → Level 2. Entity dependencies, hierarchies, cross-document rules → Level 3.

LevelData & Task ProfileSteps NeededWhat You Skip & Why
Level 1: In-Context ProcessingAnalyzing 1 to a few documents at a time (e.g., one uploaded contract or invoice that fits in context)Steps 1, 2, 4
(Ingest → Structure → Provenance)
Skip 3, 5, 6, 7. Do not chunk and embed a 10-page document just to retrieve 5 chunks from it; parse it cleanly, attach page/section provenance, and pass the structured Markdown directly.
Level 2: Production Agentic RAGSearching hundreds to millions of documents for facts, clauses, policies, or proceduresSteps 1, 2, 3, 4, 5, 7
(+ Chunking, Hybrid Index, Retrieval Tools)
Skip 6 (Knowledge Graph) when self-contained sections found by semantic + keyword search and metadata filters answer the question.
Level 3: Graph-Augmented RAG (GraphRAG)Domains where relationships, dependencies, hierarchies, or cross-document rules drive the answer (supply-chain impact, microservice root cause, regulatory cross-references)All Steps 1–7
(+ Knowledge Graph / Ontology + graph tools)
Nothing skipped: structure-aware hybrid search plus explicit graph traversal, exposed as specialized tools.

Trap: over-engineering the small case

A vector database and knowledge graph for a single 5-page contract add cost and new failure modes (missed chunks) with no benefit. Conversely, stuffing millions of documents into a prompt is impossible; the scale and the query shape choose the level.

04

4. Diagnostic Cheat Sheet: "Symptom → Missing Step"

Use this table in architecture reviews and debugging sessions to pinpoint why an agent is failing.

Agent Failure SymptomBroken StepRoot CauseEngineering Fix
Misses numbers inside tables or hallucinates on scanned PDFs01 Ingestion / 02 StructuringBasic stream parser dropped table structure or returned empty text on scansTiered layout-aware/OCR parsing + pre-LLM quality gate
Retrieves a general rule but misses the exception right below it03 Structure-Aware ChunkingFixed 500-token splitter severed the rule from its sub-clause or table headerSplit on headers/clauses (HybridChunker), keep tables intact, or use parent-child chunks
Cites an outdated 2022 policy or leaks another customer's record04 Metadata & ProvenanceChunks lack lifecycle/ACL tags, or retrieval runs without pre-filteringAttach version, status="active", effective_date, tenant_id; enforce mandatory pre-filters
Finds general topics but fails on exact SKUs, clause IDs, or error codes05 Embeddings & Hybrid IndexPure dense embeddings smooth over exact alphanumeric stringsHybrid search (dense + BM25) fused via RRF + cross-encoder reranking
Fails on multi-hop questions ("If Vendor X defaults, which SLA in Contract Y is triggered via Subsidiary Z?")06 Knowledge Graph & OntologyFlat chunks share no lexical or vector overlap across the intermediate hopsModel entities and relationships in an ontology-governed graph; expose traversal tools
Writes overly broad, unparseable, or hallucinated search queries07 Retrieval Tools (ACI)One generic search(query) tool gives the LLM too much freedom and zero guardrailsNarrow, typed MCP tools with Literal enums, date filters, and clear docstrings (Poka-Yoke)
05

5. Operating the Knowledge Layer: Multimodal, Access, Freshness, Memory & Evaluation

The 7 steps build the knowledge layer once. A production agent also needs it to handle non-text sources, respect permissions, stay current, stay separate from agent memory, and be measured. For pipeline-level depth see the RAG guide: indexing, security, freshness, and evaluation.

5.1Multimodal Sources (Audio, Video, Images)

SourcePrepare it asProvenance to keep
Audio (calls, meetings, voicemail)Speech-to-text transcript with speaker labels (diarization) and timestamps; chunk by speaker turn or topicstart_time, end_time, speaker, recording_id
Video (training, demos, recorded incidents)Transcript + scene/shot segments + keyframe descriptions, or one multimodal embedding per segmentTimestamp range, keyframe URI
Images, diagrams, scanned formsOCR for text; a vision model's caption for figures; or a multimodal embedding model that maps images and text into the same vector spacepage_number, bounding_box, image_uri

Rule: make media addressable

Turn every media file into time- or region-addressable units so a citation points to "minute 12:40" or "Figure 3, page 7", not just "the video".

5.2 Identity-Aware Access & Sensitive Data

  • Filter by the end user's identity, in code. Enforce ACLs inside the retrieval tool as a mandatory filter built from the end user's verified identity (propagated to the tool). Do not query with the agent's broad service credential, and never rely on a prompt like "ignore documents the user cannot see".
  • Sync permissions with content. Ingest ACLs from the source system alongside the text; a permission change must re-propagate to the index, just like a content change.
  • Redact before you index. Remove or tokenize PII and secrets that retrieval does not need before embedding. Once sensitive text is in chunks and vectors, the only fix is delete and re-index.

Trap: one shared index + a superuser credential + a prompt asking the model to "respect permissions" = a data leak waiting to happen.

5.3 Freshness & Index Lifecycle

  • Incremental ingestion: detect changes (content hash, modified timestamp, or change events) and re-parse/re-embed only the changed documents.
  • Deletes and supersession: propagate deletions (remove or tombstone chunks) and flip old versions to status="superseded" so two versions are never both "active".
  • Embedding model change ⇒ full re-embed: vectors from different embedding models (or versions) are not comparable; never mix them in one index. Record embedding_model and ingested_at in metadata.
  • Monitor staleness: track the lag between a source change and the index update.

5.4Knowledge Base vs. Agent Memory

DimensionKnowledge baseAgent memory
SourceCurated enterprise documents and systems of recordThe agent's own interactions (sessions)
ScopeShared across users, filtered by ACLPer user or per session
AuthorityAuthoritative, versioned ground truthUser-specific preferences and facts; can be wrong or stale
Write pathIngestion pipeline (Steps 1–6) with owners and reviewAgent extracts and consolidates facts during or after a session
LifecycleVersions, effective dates, supersessionTTL, consolidation, user deletion requests

Rule: keep the two stores separate

Do not write unverified conversation facts into the shared knowledge base, and do not store company policy in a user's memory. See the 4-tier memory model in Agentic Design Patterns → Memory.

5.5Evaluating the Knowledge Layer (Golden Dataset)

Build & measure

  • Golden set: realistic queries (exact-ID lookups, multi-hop questions, permission edge cases, and questions with no answer in the corpus), each mapped to expected doc_id/chunk IDs and a reference answer.
  • Retrieval metrics: recall@k (did the right chunk reach the top-k?), precision@k, and rank-aware MRR or nDCG (was it ranked high?).
  • Generation metrics: groundedness/faithfulness (claims supported by retrieved text), citation accuracy, answer correctness, and a correct "not found" when the corpus has no answer.

Read the result

  • Low recall@k → Steps 1–5 (parsing, chunking, metadata, index).
  • High recall, wrong answers → generation (prompting, context overload).
  • Permission violations → Step 4 and §5.2.
  • Re-run on every change to the parser, chunker, embedding model, reranker, or tools. See AgentOps for continuous evaluation pipelines.
06

6. Exam Quick-Review

ComparisonKey Distinction
Naive RAG vs. Knowledge EngineeringNaive RAG = raw stream → fixed 500-token chunks → vector-only → prompt stuffing. Knowledge Engineering = layout parsing → structure chunking → provenance → hybrid + graph → typed ACI tools.
Prepare vs. Index vs. ExposePrepare (Steps 1–4) makes data clean & traceable; Index (Steps 5–6) makes it findable by meaning, keyword & relationship; Expose (Step 7) turns indexes into mistake-proof agent tools.
Fixed-token vs. structure-aware chunkingFixed-token cuts every N tokens (severing rules from exceptions and tables from headers); structure-aware splits on headings, clauses, and intact tables.
Metadata pre-filtering vs. post-generation citationBoth rely on Step 4: pre-filtering enforces ACLs, recency, and active status before search; provenance enables deterministic citation checks after generation.
Dense vs. BM25 vs. HybridDense = meaning & synonyms; BM25 = exact SKUs, error codes & clause numbers; Hybrid = both, fused via RRF + cross-encoder reranking.
Hybrid RAG (Step 5) vs. GraphRAG (Step 6)Hybrid RAG retrieves relevant text passages; GraphRAG traverses explicit entity-relationship edges for multi-hop reasoning and dependency analysis.
Ontology vs. Knowledge GraphOntology = the formal schema (node types, edge predicates, constraints); Knowledge Graph = the populated instances that conform to it.
Generic search(query) vs. specialized toolsGeneric search forces the LLM to guess syntax; specialized ACI/MCP tools constrain arguments with typed schemas (Literal, dates, IDs).
Knowledge base vs. agent memoryKnowledge base = curated, shared (ACL-filtered), versioned ground truth; memory = per-user/session facts extracted from interactions, with TTL and consolidation.
Retrieval vs. generation metricsRetrieval = recall@k, precision@k, MRR/nDCG against golden chunk IDs; generation = groundedness, citation accuracy, answer correctness. Measure both separately.
07

7. Pocket Card, Glossary & Practice Quiz

Pocket card — 3 phases, 7 steps
PHASE 1: PREPARE (Clean & Traceable)
  01. Ingestion        Layout + OCR parsing (tables, scans, PDFs)
  02. Structuring      Raw text → Markdown sections / JSON / tables
  03. Chunking         Split by structure (headers/tables), not every N tokens
  04. Provenance       Tag doc_id, date, version, section, ACL

PHASE 2: INDEX (Findable)
  05. Hybrid Index     Dense vectors (meaning) + BM25 (exact IDs) + RRF + rerank
  06. Knowledge Graph  Entity → Relation → Entity (multi-hop rules)

PHASE 3: EXPOSE (Actionable ACI)
  07. Retrieval Tools  Domain-specific, typed MCP tools (Poka-Yoke)

SCALING LADDER
  Level 1 (In-context, 1–few docs):  Steps 1, 2, 4
  Level 2 (Production agentic RAG):  Steps 1, 2, 3, 4, 5, 7
  Level 3 (GraphRAG, multi-hop):     All steps 1–7
Knowledge Engineering
The discipline of turning raw, unstructured data into structured, traceable, and mistake-proof retrieval systems and tools for AI agents.
Layout-aware ingestion (Step 1)
Extracting document content with computer-vision layout detection and OCR (e.g., Docling, Google Document AI, LlamaParse) to preserve reading order and tables.
Normalization & structuring (Step 2)
Transforming raw extracted text into hierarchical Markdown headings, structured JSON, intact tables, and canonical entity formats.
Structure-aware chunking (Step 3)
Splitting documents along semantic and structural boundaries (sections, clauses, intact tables, parent-child hierarchies) rather than fixed token counts.
Metadata & provenance (Step 4)
Structured attributes (doc_id, section_path, page_number, version, effective_date, access_acl) on every chunk for pre-search filtering and post-generation citation checks.
Hybrid index (Step 5)
Dense semantic embeddings plus sparse lexical matching (BM25), merged via Reciprocal Rank Fusion and refined with a cross-encoder reranker.
Knowledge Graph (Step 6)
A network of typed nodes (entities) and directed edges (relationships) representing domain facts and dependencies for multi-hop reasoning.
Ontology
The formal schema governing a knowledge graph: valid entity classes, relationship predicates, hierarchies, and constraints (e.g., RDFS, OWL).
Retrieval tools / ACI (Step 7)
Narrow, strongly-typed, well-documented functions (often via MCP) that give an agent mistake-proof (Poka-Yoke) access to hybrid indexes and knowledge graphs.
Identity-aware retrieval
Enforcing document ACLs inside the retrieval tool using the end user's propagated identity, rather than the agent's broad credential or a prompt instruction.
Golden dataset
Curated queries mapped to expected source chunks and reference answers, used to measure retrieval (recall@k, MRR/nDCG) and generation (groundedness, citation accuracy) after every change.

Related guides

Audio Deep Dive & Study Downloads

Listen to the 55-minute Knowledge Engineering audio deep dive, open the 21-slide deck and sketchnote infographic in the Hub Viewer, or drill scenario-based questions on layout-aware parsing, structure-aware chunking, metadata pre-filters, hybrid search, knowledge graphs, typed retrieval tools, and ACL enforcement.

Knowledge Engineering (Video Walkthrough)
Knowledge Engineering for Production AI Agents (Podcast)
Open Slide Deck & Infographic in Hub Viewer Take the Knowledge Engineering Practice Quiz →

Self-Assessment Questions (Click to Reveal)

Q1. What are the 3 phases and 7 steps of Knowledge Engineering for AI agents?

Prepare: (1) Document Ingestion, (2) Normalization & Structuring, (3) Structure-Aware Chunking, (4) Metadata & Provenance. Index: (5) Embeddings & Hybrid Indexes, (6) Knowledge Graph & Ontology. Expose: (7) Specialized Retrieval Tools (ACI/MCP).

Q2. Why is arbitrary 500-token chunking dangerous for agents?

It splits logical units (tables, or legal clauses and their exceptions) in half, giving the agent incomplete ground truth and causing confident hallucinations.

Q3. Why do production systems use hybrid search (vector + BM25) instead of vectors alone?

Dense embeddings capture meaning and synonyms, while sparse BM25 captures exact keyword, SKU, acronym, and clause-ID matches that embeddings blur.

Q4. When is a Knowledge Graph (Step 6) justified over standard hybrid RAG (Step 5)?

When answers depend on multi-hop relationships, dependency chains, hierarchies, or cross-document relational rules between entities.

Q5. What two problems does Metadata & Provenance (Step 4) solve?

(1) Pre-search filtering (tenant ACLs, active versions, effective dates enforced before retrieval) and (2) post-generation auditability (exact source citations verified by humans or auditor nodes).

Q6. Why expose several specific retrieval tools instead of one generic search(query) tool?

Specific, strongly-typed tools (Poka-Yoke ACI) constrain the agent's search space with typed parameters and enums, preventing malformed queries and guaranteeing the right index and filter strategy runs.

Q7. Which steps do you need to analyze a single 5-page contract that fits in the context window?

Only Steps 1, 2, and 4 (Ingestion → Structuring → Provenance). Skip chunking, vector/hybrid indexing, knowledge graphs, and search tools.

Q8. You switch to a newer embedding model. Can you embed only new documents with it?

No. Vectors from different embedding models are not comparable, so re-embed the whole corpus (or build a new index and cut over). Record embedding_model in metadata.