Step 2: Context
How documents become retrieved evidence, why one vector per document fails, a measured fix, and what an agent should remember.
An agent misses a document you know is in the store. Why does the model not see the evidence it needs? Often the cause is how the documents were prepared for search. Documents are cut into pieces, turned into numbers, stored and searched. Each of those choices changes the answer. On our own measurements, they change it more than anything else available. The most common failure is simple. A document about several things gets one averaged summary, so a question about one of them matches it weakly. This is the second step on the intelligence ladder.
The pipeline, in order
Parse. Turn the source file into text and keep its structure. A table that becomes a run-on sentence has lost the link between each figure and its label. No later stage recovers it. Parsing quality sets the ceiling for every later stage. So it is spot-checked for as long as the system runs, never assumed.
Chunk. Split the text into pieces that can be retrieved. Too large, and one piece covers several topics. Too small, and a piece loses the context that gave it meaning. No single recipe works across every collection of documents. So the split is tested, not just configured.
Embed. Turn each piece into a vector, also called an embedding. A vector is a list of numbers. It places the piece in a space where nearby means similar in meaning. Every vector records the version of the model that produced it. Changing that model invalidates the whole index.
Index. Store the vectors for fast nearest-neighbour search. Store the source's access rights alongside them. Indexes that respect who may see what belong to the data platform layer (R02).
Retrieve. Turn the question into a vector the same way. Find the nearest pieces and pass them to the model.
foundation · flow
From a document to a retrieved answer
Each stage sets the ceiling for the next; parsing errors are never recovered downstream.
- 1
Parse
Text out of the file, structure intact.
Gate · Spot-checked forever
- 2
Chunk
Split into retrievable pieces, per corpus.
Gate · Evaluated, not configured
- 3
Embed
Each piece becomes a vector, versioned.
Gate · Encoder version pinned
- 4
Index
Stored with the source permissions inside.
Gate · Filter before search
- 5
Retrieve
Meaning and keyword search, fused.
Gate · Beats a matched control
Diagram description: Five pipeline stages from parse through chunk, embed and index to retrieve, each with the failure it guards against. The sequence contains 5 stages: 1, Parse: Text out of the file, structure intact., followed by the Spot-checked forever gate; 2, Chunk: Split into retrievable pieces, per corpus., followed by the Evaluated, not configured gate; 3, Embed: Each piece becomes a vector, versioned., followed by the Encoder version pinned gate; 4, Index: Stored with the source permissions inside., followed by the Filter before search gate; 5, Retrieve: Meaning and keyword search, fused., followed by the Beats a matched control gate.

One vector per document averages away the topic
Embedding a whole document gives roughly the average of everything in it. That is fine when a document is about one thing. Company documents are rarely about one thing.
Picture a customer file holding identity details, two years of transactions, a prior alert and a complaint. One vector for that file sits at the centre of all four topics. It is a close match for none of them. Ask about the complaint, and the file matches weakly. Three quarters of its vector is about something else.
We measured it. We grew documents from one topic to ten, with the collection, the embedding model and the scoring held fixed. Search quality fell from 0.815 to 0.294. The score used is nDCG@10. It rates the first ten results from 0 to 1. Giving each document several vectors instead of one brought it back to 0.803. The documents and the model were the same. Only the representation changed.
The cause is what theory predicts. Take a question and the best single piece of its target document. Their similarity stayed flat as topics were added, from 0.476 to 0.466. The whole-document vector, called a pooled vector, fell from 0.476 to 0.225. The signal was still there in the pieces. Averaging hid it.
Test the fix against a fair control

Splitting a document into several pieces gives it more vectors. More vectors means more chances to match. So the fair question is not whether several vectors beat one. It is whether pieces built around one purpose each beat the same number of plain pieces.
We ran that control. On real prose, the pieces built around one purpose each did worse. They scored 0.635 against 0.667 for plain chunks. We published that result. The method matters more than the result. Any design you adopt must beat a matched control on your own queries. A matched control has the same number of pieces per document. Without it, you have measured the effect of more pieces, not of the design.
Add keyword search
Meaning-based search is poor at exact strings, such as an account number. On queries naming a specific attribute, keyword search scored 0.997. Meaning-based search scored 0.314 on the same queries. Run both and merge the two rankings. This is called hybrid retrieval. It costs almost nothing, and it removes a silent failure. A meaning-only system does not return an error when it misses an account number. It returns something plausible instead.
What the agent remembers
What an agent keeps from earlier work reaches the model like any document. It also carries duties a document does not. Memory is graded here by how long it lasts.
The current conversation and the evidence fetched for this turn are working data. So is a working session of hours or days, within limits on where and how long it is held. Memory that outlives the session is different. A lasting profile of a customer or a case is a record. It has an owner, and duties for consent, retention and deletion. Governed memory is built in the agent data engineering layer (R14). Knowledge and memory covers it in depth.
Four rules follow, and each rests on published evidence.
Keep the source text. Store the original and add search keys to it. On a published long-term memory benchmark, this improved recall by 9.4 percent and answers by 5.4 percent. Replacing the text with extracted facts or summaries made results worse (LongMemEval, ICLR 2025).
Record when a fact was true. Keep the time something happened apart from the time it was stored. A fact that has been replaced is then marked out of date. The history behind an earlier decision survives. Acting on an out-of-date fact is a known production failure.
Check a memory before it is kept. Every write carries its source. It waits in quarantine, a holding area, until it is checked and promoted. The reason is measured. Planting false entries in under 0.1 percent of a memory store gave attacks over 80 percent success (AgentPoison, NeurIPS 2024).
Topics help search. They are not memory. Topics are labels, stored so they can be rebuilt. A graph is added only where questions follow exact relationships, such as ownership or dependency. The decision on graphs and embedding search records that verdict.

Worked example: an audit investigation
An audit investigation at a utility or energy company needs the original finding and its site and date. It also needs the applicable procedure, the action history and the closure evidence. A set of similar sentences can suggest a topic. It can still miss the context needed to explain it.
Retrieve the relevant passages and records using the investigator's current permissions. Keep source identifiers and times. Compare plain chunks and keyword search before adding several representations per document. A graph or specialist embedding is useful only if it improves the actual questions.
A reviewer should be able to see why the evidence supports the proposed pattern. Missing evidence stays a gap. It must not become a confident conclusion about a systemic issue. See systemic audit issues.
Where to go deeper
Context patterns for agents has nine patterns. Each has its measurement and the conditions under which it fails. From data to memory covers the engineering. How to test a context design is the method. The memory-pipeline architecture sets out how memory is kept and checked. When a knowledge graph earns its keep covers topics, graphs and memory.
When this step is done
Your representation beats a matched control on your own queries. Anything the agent keeps is sourced, dated and checked. What still fails is about acting, not knowing.
An agent may find the right documents and still draw the wrong conclusion. It may call the wrong tool or stop too early. That is not a context problem. It is step 3.
Evidence and limits
Mixed evidence The retrieval figures are our own. They can be reproduced from the published benchmark. They were reproduced on two machines with two processor architectures. They come from one collection of documents and one embedding model, so test on your own material. The memory findings are published work by others, cited where they appear.
Next step
When the agent knows enough but acts badly, go to step 3: tools and the loop.
Explore this topic
- Original context measurements are author-reported experiments; see the research reports.
- Added documents reducing accuracy until curation: arXiv 2606.11350.
- Keeping raw text and adding derived keys, against replacing it with facts or summaries: LongMemEval, ICLR 2025.
- Poisoning under 0.1 percent of a memory store: AgentPoison, NeurIPS 2024.
- How memory is kept, dated and quarantined: the memory-pipeline architecture and from data to memory.
- Topics and graphs as derived indexes, not memory: when a knowledge graph earns its keep and the graph decision.
- Moffatt v. Air Canada, BC Civil Resolution Tribunal, 14 February 2024.
- Industrial scenarios on this page are proposed designs, illustrated in the use cases.
Cite this page
Written by Murali Sid, Founder and AI Systems Architect, last updated 15 October 2026. Licensed CC BY-SA 4.0, so quote it freely with attribution.
Murali Sid (2026). Step 2: Context. Agentic Architecture Skills. https://www.agenticarchitectureskills.com/ladder/contextMachine-readable version of this page: /ladder/context.md