Machine Learning pathway increased my salary by 40%
Enterprise Data, Knowledge Engineering, Memory and Context Intelligence
Every agent failure that looks like a reasoning problem is usually an evidence problem. The agent was given the wrong document, the stale policy, the wrong customer or twelve paragraphs of nothing.
This chapter covers the foundations an agent estate rests on: enterprise data architecture, structured and unstructured data, governance and quality; retrieval-augmented generation and its advanced variants; hybrid search, embeddings and vector databases; knowledge graphs, ontologies and semantic modelling; agent memory across episodic, semantic, procedural and working tiers; context engineering and window optimisation; memory persistence and retrieval; data lineage, freshness and access control; and the discipline of grounded, evidence-based responses.
What this covers
- Who this is for
- Data architects, knowledge engineers, platform engineers building retrieval and memory, and process owners who cannot explain why the agent got a fact wrong.
- What it assumes
- Chapters 01 to 08, plus working familiarity with data modelling and search.
- What you will be able to do
- Design a retrieval layer that returns the right evidence with provenance, model knowledge where relationships matter, architect memory tiers with governance, engineer context for reliable decisions, and measure whether grounding actually holds.
- Reading time
- About 28 minutes including the question bank and glossary.
What the agent needs from enterprise data
Agent work has four data requirements that conventional analytics architecture does not always satisfy. It needs entities resolved to a single identity, because an agent that treats two records for the same customer as different people will make a wrong decision. It needs point reads at low latency, not batch extracts. It needs provenance — where this value came from, when, and under which permission. And it needs access control that can be evaluated per field and per purpose, because retrieval happens at inference time rather than inside a report.
Structured data is usually accessible and well governed; the problem is that it is distributed across the systems of record with no shared identity for the entity the agent cares about. Unstructured data is the opposite — abundant, poorly governed, and the place where most decisions actually live. A workable architecture treats both as evidence sources behind a retrieval service, rather than letting agents query systems directly.
The retrieval service is the layer worth investing in. It owns entity resolution, permission-aware filtering, document parsing, chunking, indexing, freshness, and citation. Building it once, rather than per use case, is the single largest lever on agent quality — and the reason most early agent programmes plateau is that they skipped it.
- Entity resolution
- Determining that records from different systems describe the same real-world entity.
- Retrieval service
- A governed layer that resolves identity, filters by permission and returns evidence with citation.
- Provenance
- Source, version, timestamp and access scope attached to retrieved content.
- Point read
- A low-latency fetch of specific records rather than a batch extract.
Retrieval-augmented generation that actually grounds
Basic RAG — chunk, embed, retrieve top-k, generate — works in demonstrations and disappoints in production. The failure modes are consistent: chunks that cut across clauses, retrieval that returns similar-looking but irrelevant passages, no way to tell an approved policy from a draft, and no filtering by the caller's entitlement. Each is an engineering problem with a known fix.
Advanced patterns address them. Structure-aware chunking preserves headings, tables and clause boundaries. Hybrid search combines lexical matching, which is essential for identifiers and exact terms, with vector similarity, which handles paraphrase. Metadata filters enforce entitlement, currency and document type before results enter context. Reranking applies a second-stage relevance model to the candidate set. Query rewriting expands ambiguous user phrasing into retrieval terms the corpus actually uses.
Grounding also requires the generation side to be constrained. The agent should be instructed — and where possible structurally required — to cite the passages it used, to answer only from retrieved evidence, and to state when the evidence is insufficient. A refusal with a reason is more valuable than a fluent guess, and it is the behaviour that most needs testing.
| Symptom | Cause | Fix |
|---|---|---|
| Relevant text missed | Chunking destroys structure | Structure-aware chunking |
| Identifier lookup fails | Vector search only | Hybrid lexical plus vector |
| Draft policy cited as current | No metadata filters | Filter by status and version |
| Entitlement breach | Filters after retrieval | Enforce filters in the query |
| Plausible answer, no source | Unconstrained generation | Citation requirement and refusal path |
Knowledge graphs, ontologies and semantic modelling
Vector retrieval answers questions about similarity. It cannot answer questions about structure: which policy applies to which subsidiary, which approval chain governs this commitment, which suppliers belong to the same corporate group, which product supersedes which. These are relational questions, and a graph answers them by traversal with an evidence path attached.
An ontology is the model behind the graph: the entity types, the relationships between them and the rules that constrain them. In enterprise practice a light ontology is usually enough — a defined set of types and relations, an identifier strategy and controlled vocabularies — and a heavy formal ontology is usually a distraction. The value comes from the same discipline as any data model: agreed definitions and single ownership.
Graphs also improve grounding. A returned path — customer, contract, obligation, clause — is evidence rather than similarity, and it is explicable to a reviewer. The cost is curation: graphs decay without ownership, and a stale graph produces confident wrong traversals, which is worse than a missing answer.
Start with the relationships your decisions actually depend on — typically three or four — rather than modelling the enterprise. A small, owned, current graph outperforms a comprehensive stale one.
Memory architecture: episodic, semantic, procedural, working
Episodic memory records what happened on a case: documents received, decisions taken, evidence rejected. It is the basis of continuity and audit. It should be immutable-ish, append-only and retained per policy, because its purpose is reconstruction.
Semantic memory holds durable facts: the customer's contracted terms, the supplier's certifications, the policy that applies. It must be authoritative and versioned, and it should be read from the system of record rather than copied into an index that then drifts. Where a copy is necessary for performance, it needs a freshness contract.
Procedural memory is knowledge of how to do something. In agent systems this is best expressed as tools and versioned procedures rather than as prose the model must follow, because a tool enforces its steps while text merely suggests them. Working memory is the context of the current step: the goal, the relevant evidence and the constraints. It should be curated aggressively, because context quality degrades as it grows.
| Tier | Holds | Authority | Retention |
|---|---|---|---|
| Working | Current step context | Derived, disposable | Run lifetime |
| Episodic | Case history and decisions | Record of what happened | Per case retention policy |
| Semantic | Durable facts and policy | System of record, versioned | Per record policy |
| Procedural | How to perform tasks | Tools and versioned procedures | Per procedure version |
Context engineering and window optimisation
Context engineering is the practice of deciding what an agent sees at each step, in what form, with what ordering and what status. It has more effect on quality than model choice in most enterprise systems, and it is the part most teams under-invest in because it produces no visible artefact.
Four practices carry most of the value. Summarise tool output into typed fields rather than pasting payloads. Order context by decision relevance, with instructions first and the most decisive evidence nearest the task. Use delimiters and labels so the model can distinguish instruction, evidence, prior result and constraint. And remove what no longer matters — earlier speculative branches, superseded documents, redundant confirmations.
Window size is a poor substitute for curation. Larger windows increase cost and latency and, beyond a point, reduce accuracy as relevant material is diluted. The engineering goal is a small context containing exactly the evidence required, with a citation for each claim the agent is expected to make.
- Summarise before insert; never paste raw payloads into context.
- Order by decision relevance; instructions first, decisive evidence closest.
- Label channels explicitly: instruction, evidence, prior result, constraint.
- Drop superseded and speculative material rather than carrying it forward.
- Require citations for any claim the agent will act on.
Lineage, freshness and access control
Lineage answers where a value came from. For agents it must extend to the evidence path: which version of which document, retrieved when, under which entitlement, used to support which claim. Without it, a challenge to an outcome cannot be answered, and model debugging becomes guesswork.
Freshness is a correctness property, not a nicety. Each source needs a stated staleness tolerance and a mechanism to enforce it: a re-index on change, a timestamp filter in retrieval, or a hard rule that a document older than a threshold cannot be cited as current policy. Most embarrassing enterprise agent errors are stale-data errors.
Access control must be evaluated in the retrieval query, not afterwards. Filtering results after retrieval means the agent has already read content the caller was not entitled to see, which is a personal-data exposure even if it never appears in the output. Field-level restriction matters for HR, health and financial data where purpose limitation applies.
Measuring whether the answer was actually grounded
Groundedness is measurable. For each answer, check that every factual claim maps to a retrieved source, that the source is current and authorised, and that no claim relies on model memory. Sample this routinely, stratify by use case, and report a groundedness rate alongside correctness.
Retrieval quality needs its own metric, separate from answer quality, or failures get misattributed. Recall at k on a labelled query set, precision of the top five results, and the proportion of queries with no adequate evidence tell you whether the problem is retrieval or generation. In practice most defects are retrieval defects.
Build the evaluation corpus from real cases including the awkward ones: scanned forms, amended contracts, multi-entity customers, superseded policies. A corpus of clean PDFs will produce a retrieval layer that fails on the first real document, and the failure will appear as model error rather than as an ingestion defect.
- Groundedness rate: share of claims traceable to a current, authorised source.
- Retrieval recall at k and top-five precision on a labelled query set.
- No-evidence rate: queries where the corpus could not support an answer.
- Stratify by document type and entity complexity, not just in aggregate.
Key focus areas
- Entity resolution
- One identity per real-world entity across systems — the precondition for correct decisions.
- Retrieval service
- A governed layer owning parsing, chunking, indexing, filtering and citation.
- Structure-aware chunking
- Splitting on headings, tables and clause boundaries to preserve meaning.
- Hybrid search
- Lexical plus vector retrieval, essential for identifiers and exact terms.
- Metadata filters
- Entitlement, status and currency enforced in the query, not after retrieval.
- Reranking
- Second-stage relevance ordering before results consume context.
- Citation discipline
- Every actionable claim traceable to a retrieved passage, with refusal where evidence is missing.
- Knowledge graphs
- Relationship traversal for structural questions similarity search cannot answer.
- Light ontology
- A small set of agreed types, relations and vocabularies — not enterprise-wide formalism.
- Memory tiers
- Working, episodic, semantic and procedural memory with distinct authority and retention.
- Context curation
- Summarise, order, label and prune; window size is not a substitute.
- Lineage
- The evidence path from claim to source version, retrieval time and entitlement.
- Freshness contracts
- Stated staleness tolerances with enforcement mechanisms per source.
- Groundedness measurement
- Claim-to-source coverage, stratified retrieval metrics and no-evidence rate.
Key takeaways
- Most agent reasoning failures are evidence failures.
- Resolve entities before automating decisions about them.
- Build one governed retrieval service rather than one per use case.
- Structure-aware chunking matters more than embedding model choice.
- Hybrid search is required wherever identifiers or exact terms appear.
- Enforce entitlement filters inside the query, never after retrieval.
- Require citations and permit refusal when evidence is insufficient.
- Use a graph for structural questions; a light ontology is usually enough.
- Keep the four memory tiers separate with distinct authority.
- Express procedure as tools and versioned steps rather than prose.
- Curate context aggressively; larger windows cost more and reason less well.
- Label instruction, evidence and constraint channels explicitly.
- Lineage must extend to the evidence path, not only the value.
- Enforce freshness; most embarrassing errors are stale-data errors.
- Measure groundedness and retrieval recall separately, or you will fix the wrong component.
Glossary
- Chunk
- A retrievable unit of text produced by splitting a document.
- Citation
- An explicit reference from a claim to the source passage that supports it.
- Context window
- The bounded input available to a model at one step.
- Context engineering
- Designing the content, ordering and labelling of what a model sees per step.
- Embedding
- A vector representation used for semantic similarity.
- Entity resolution
- Matching records across systems to one real-world entity.
- Episodic memory
- Record of what happened during a specific case.
- Freshness contract
- A stated staleness tolerance for a source with an enforcement mechanism.
- Groundedness
- The degree to which output claims are supported by retrieved evidence.
- Hybrid search
- Combining lexical and vector retrieval and merging the candidate lists.
- Knowledge graph
- A graph of typed entities and relations supporting traversal queries.
- Lineage
- The traceable path from a value or claim back to its source and version.
- Metadata filter
- A constraint on retrieval by attribute such as status, type or entitlement.
- Ontology
- A formal model of entity types, relationships and constraints in a domain.
- Procedural memory
- Knowledge of how tasks are performed, usually expressed as tools.
- Recall at k
- The proportion of relevant documents appearing in the top-k retrieved results.
- Reranker
- A model that reorders retrieved candidates by relevance before use.
- Semantic memory
- Durable facts and policy independent of any single case.
- Vector database
- Storage optimised for similarity search over embeddings.
- Working memory
- The active context used during a single step.
5 questions to test the model
An agent retrieves a draft policy and treats it as current. Which control failed?
Why is hybrid search usually necessary in enterprise retrieval?
Which memory tier should hold the authoritative contracted terms for a customer?
What is the correct fix when entitlement filtering happens after retrieval?
Which pair of metrics separates retrieval failure from generation failure?
Questions this page answers
Do we need a vector database or is search enough?
How large should chunks be?
Is a knowledge graph worth the effort?
How do we handle documents that change frequently?
What about scanned documents and images?
Should the agent see whole documents or passages?
How do we prevent the agent using stale facts about a customer?
How is memory different from a database?
What belongs in episodic memory?
How much context is too much?
Should retrieved content be quoted to the user?
How do we test retrieval?
What is the role of query rewriting?
How do we handle multi-tenant data separation?
Do we need data lineage tooling?
How do we keep the evaluation corpus current?
What is the most common ingestion defect?
How should knowledge freshness be surfaced to users?
What about model memory versus retrieval?
How does this chapter connect to Chapter 10?
What does Entity resolution mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (What the agent needs from enterprise data)?
What does Retrieval service mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (What the agent needs from enterprise data)?
What does Provenance mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (What the agent needs from enterprise data)?
What does Point read mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (What the agent needs from enterprise data)?
What does Relevant text missed mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Retrieval-augmented generation that actually grounds)?
What does Identifier lookup fails mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Retrieval-augmented generation that actually grounds)?
What does Draft policy cited as current mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Retrieval-augmented generation that actually grounds)?
What does Entitlement breach mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Retrieval-augmented generation that actually grounds)?
What does Plausible answer, no source mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Retrieval-augmented generation that actually grounds)?
What does Working mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Memory architecture: episodic, semantic, procedural, working)?
What does Episodic mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Memory architecture: episodic, semantic, procedural, working)?
What does Semantic mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Memory architecture: episodic, semantic, procedural, working)?
What does Procedural mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Memory architecture: episodic, semantic, procedural, working)?
What does Entity resolution mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Key focus areas)?
What does Retrieval service mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Key focus areas)?
What does Structure-aware chunking mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Key focus areas)?
What does Hybrid search mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Key focus areas)?
What does Metadata filters mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Key focus areas)?
What does Reranking mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Key focus areas)?
What does Citation discipline mean in Enterprise Data, Knowledge Engineering, Memory and Context Intelligence (Key focus areas)?
Sources and standards
- Retrieval-Augmented Generation literature
Foundational and survey material; used for technique framing rather than quantified claims.
- Model Context Protocol — resources and prompts
Standardised access to resources used in retrieval designs.
- ISO/IEC 42001 — data and information requirements
Data governance expectations within an AI management system.
- Digital Personal Data Protection Act 2023 — data principles
Purpose limitation, minimisation and retention obligations.
- Knowledge graph and ontology engineering guidance
Ontology and semantic modelling references.
- Vector search and hybrid retrieval documentation
Implementation guidance for hybrid queries and reranking.
Continue through the twelve chapters
Chapter 10 covers deployment, AgentOps, evaluation pipelines, observability and the performance engineering that keeps an agent estate reliable.
Continue this lesson with a subscription
Multi Agentic Enterprise Workflow Automation is part of the paid catalogue. You have read the free preview. A subscription opens the rest of this lesson, the classroom slides and the assessment questions.
- The full lesson for this topic and every other catalogue topic
- Every classroom slide deck and worked example
- All assessments, with a verifiable certificate on completion
The Free-To-Learn library stays open to everyone and is not affected by this.
