Blog
Saved0

Context engineering for AI agents: why context assembly is more than RAG

Retrieval found every right document, and the waiver still skipped credit committee. Why relevant text isn't sufficient context, and how to assemble what an agent decision actually needs.

LinkedIn
On this page
  1. The retrieval was right. The decision context was wrong.
  2. What's the difference between RAG and context assembly?
  3. Start from the decision, not the search query
  4. Enterprise context comes in many shapes
  5. Who is allowed to see this context?
  6. Is the latest data always the right data?
  7. Evidence informs. It never gives orders.
  8. Transformations and budgets change meaning
  9. When is context sufficient to act?
  10. Record what the model actually saw
  11. Common anti-patterns
  12. Ten rules for governed context assembly
  13. The result: decisions built on enough, not just on related
  14. Frequently asked questions
  15. How Frozion assembles the context behind each action
  16. Sources
The short answer

Context engineering means building everything an AI decision needs, not just retrieving related text. RAG finds candidate documents. Context assembly starts from the decision, pulls in structured state, features, history and policy alongside documents, checks scope and freshness, keeps instructions separate from evidence, and refuses to proceed when mandatory facts are missing.

The retrieval was right. The decision context was wrong.

A corporate-lending application reviews a borrower's request for a 90-day covenant waiver. The agreement allows a temporary waiver only if the borrower hasn't had another in the past 12 months and current exposure stays under $50 million.

Retrieval does its job. It finds the signed agreement, the latest amendment and the borrower's letter. The model extracts the waiver clause accurately and classifies the request as a routine exception.

The facts that decide the case live elsewhere. Current exposure is $58.4 million, in a feature store. A previous waiver was granted eight months ago, in the case system. The risk grade sits behind a structured service. The rule requiring committee review lives in policy. None of it reaches the model or the decision.

The proposal is well-formed, the citations are real and every dashboard is green. The request goes to routine approval instead of mandatory credit committee.

What's the difference between RAG and context assembly?

RAG answers which documents look related to a request; context assembly answers what one specific decision needs, whether the requester may use it, and whether it's complete. RAG is one input to that process, not the whole of it.

Retrieval-augmented generation is valuable. It brings current enterprise information into a model call, improves relevance and supports citations. But retrieval asks "what's related?" An enterprise decision also has to ask what's mandatory, allowed, current, authoritative and safe to show the model.

QuestionWhat retrieval answersWhat context assembly must also answer
RelevanceWhich passages or records look related?Which source types does this decision require?
EligibilityWhich indexed items match the filter?Which items may influence this person, tenant, purpose and location?
CompletenessHow many results came back?Are the required facts, rules and contrary evidence all present?
FreshnessWhich revision was retrieved?Does each item meet this decision's time requirements?
MeaningWhat text came back?What role, units, trust level and precedence does each item carry?
BoundaryWhat did the retriever return?What exact package reached the model after trimming and ordering?

Start from the decision, not the search query

A search-first design begins with a question, a query and a top-k value. A decision-first design begins with what must be evaluated and what has to be true before an answer or action is allowed.

For the waiver, the agreement text is necessary but nowhere near sufficient. The decision also needs current exposure, waiver history, risk grade, the applicable policy, the requester's authority, the legal entity and the decision date. Documents explain the rule. Structured systems supply the facts the rule applies to.

Separate mandatory context from useful context. A missing market commentary makes the answer less rich. A missing exposure figure makes automation impermissible. Treating both as ordinary retrieval misses hides that difference.

Enterprise context comes in many shapes

Decisions rarely live entirely in documents. A governed design doesn't force every source into one store. It gives each kind of source its own contract and joins them into one typed package.

Context typeExamplesWhat to keep with it
Instructions and constraintsTask, output schema, policy-derived limitsVersion, owner, and strict separation from evidence
User request and assertionsThe ask, uploads, selected accountWho said it, when, and whether it's been checked
DocumentsContracts, policies, letters, reportsSource, revision, scope and how it was chunked or extracted
Live operational stateBalances, limits, case status, approvalsPoint-in-time value, record revision, authority
Features and derived factsExposure, risk indicators, ratiosDefinition version, lineage, effective time
Memory and prior decisionsConversation summary, earlier rulingsWhat it applies to, status, expiry
Tool resultsAPI responses, status checksWhich tool, when, and whether a change was committed
Policy and authority factsTenant, role, purpose, residencyAuthoritative source and validity

Documents and records have to meet through explicit meaning, not prompt concatenation. A clause describing a 12-month lookback and a count of prior waivers only line up if the time window, legal entity, borrower ID and units match. Matching words don't prove compatible meaning. For how the two kinds of data share one execution, see structured and unstructured context.

Documents, records, features, memory, tool results and policy flow through scope, freshness, precedence and sufficiency checks into one context package
Retrieval is one input. Assembly builds the decision boundary.

Who is allowed to see this context?

Apply scope (tenant, legal entity, purpose, classification and residency) before anything is ranked, not after. A source can be relevant and still be off-limits, and filtering late lets forbidden items shape the result even if they're never shown.

If permission filters run only after global candidate ranking, off-limits items can still consume top-k slots and push permitted evidence out. The same applies to caches, features, memory and tool results. And permission is layered: a document a user may read on screen may still be barred from a particular model provider or a prompt cache. Eligibility is a first stage of assembly, not a cleanup step. The retrieval side of this is covered in permission-aware retrieval.

Is the latest data always the right data?

No. Each fact needs the right time, not the newest timestamp: a contract from last year, a balance from seconds ago and today's policy revision can all be correct together. What matters is that their time meanings fit the decision.

Distinguish when a value was observed, when it took effect, which decision date you're evaluating, how stale it may be and what invalidates it. A legal clause stays valid for years; an available balance doesn't. A policy revision can exist before its effective date. Reconstructing a past decision needs the facts as they were then. Authorizing an action now needs present-state checks.

Time questionWhy it matters
When was it observed?A fresh read may describe an earlier period
When did it take effect?A revision may exist before it applies
Which decision time?Replay and live execution need different states
How stale may it be?Clauses last; balances don't
What invalidates it?A new record revision, approval or policy change

Evidence informs. It never gives orders.

A context package mixes instructions, evidence, user claims, model-written summaries, prior decisions and tool results. They aren't interchangeable, and prompt order shouldn't decide which one wins.

A retrieved document can contain text that reads like an instruction; OWASP lists this indirect prompt injection as the top LLM risk. A memory can hold a superseded conclusion. A model summary is useful but less authoritative than the record it summarizes. A tool result can be current and still be advisory rather than committed.

  • Keep contradictory evidence visible when the decision needs judgment.
  • Never let imperative text in a document become application policy.
  • Never let stale memory override a newer record.
  • Never treat a summary as equal to its source.
  • Record which rule resolved each conflict.

Transformations and budgets change meaning

Chunking, OCR, translation, redaction, summarization, unit conversion, aggregation and mapping all change what context means. Version them and record what they did. A balance query, date calculation or unit conversion shouldn't be handed to a model just because a model will read the final package; settle those exactly first.

Token, latency and cost limits look like serving concerns, but they decide which facts survive. An optional market report mustn't displace a mandatory contract exception. A long conversation history mustn't crowd out current state or policy. Allocate budget by role and importance, not relevance score. More context isn't better context: the goal is the least context sufficient for the decision, which also limits what leaks and what it costs.

When is context sufficient to act?

Context is sufficient when it meets the decision's declared requirements for coverage, freshness, scope and consistency, checked before the model is asked to judge. A successful query or a non-empty result proves nothing on its own.

Sufficiency depends on the decision. Contract review may need the agreement and every effective amendment. A credit decision needs exposure, risk grade, prior exceptions and policy. A support draft can tolerate missing background; a payment release can't. Check the assembled package and return a typed outcome:

OutcomeMeaningNext step
ReadyRequirements metProceed to judgment or policy
Source unavailableA required source can't be reachedWait, use an approved alternative, or review
StaleA value is past its freshness limitRefresh or stop
DeniedScope or policy forbids a sourceExclude; continue only if still sufficient
ConflictSources disagreeReconcile by rule or send for judgment
IncompleteA mandatory fact is missingFetch more, review or abstain

Fallback must never quietly weaken the requirement. If the exposure service is down, the application shouldn't carry on with documents alone unless that degraded mode is explicitly allowed, with its own controls.

A gate checks the assembled package and routes it to proceed, fetch more, verify, human review or abstain
A typed sufficiency check runs before any judgment or action.

Record what the model actually saw

The rules describe what's permitted. A record of each run shows what actually happened: which items were eligible, which were selected, transformed, excluded and in what order, and the exact package the model received. That distinction matters for replay. Running today's query against today's index can't reconstruct yesterday's context. Investigating a past decision needs the original revisions, features, memory and final package, or an honest statement of what can no longer be reproduced. See context provenance.

Common anti-patterns

Anti-patternWhy it failsWhat to do instead
RAG is the context architectureDocuments become the whole decision boundaryDeclare every required source type per decision
Top-k means completeA count says nothing about mandatory factsCheck sufficiency against declared requirements
Latest means correctFacts have different valid timesDefine freshness and point-in-time rules per source
Everything is textState, features and policy get flattened or droppedUse typed context items and governed joins
Order decides authorityThe last or longest item wins silentlyDeclare roles, trust levels and precedence
Fallback means carry on with lessA failed source silently lowers the barPublish typed degraded modes, escalation or abstention
Filter after rankingOff-limits items crowd out permitted onesApply scope before ranking and selection
Context logic lives in prompt codeNobody can review joins, filters or budgetsMake the context plan versioned and inspectable

Ten rules for governed context assembly

  1. Start from the decision and its required facts, not a search query.
  2. Treat retrieval as one input among several.
  3. Type documents, state, features, memory, tool results and policy separately.
  4. Apply scope and residency before anything is ranked.
  5. Give every fact a time meaning and a freshness limit.
  6. Declare roles and precedence; never let evidence give orders.
  7. Version every transformation and record what it changed.
  8. Budget by importance, not relevance score.
  9. Check sufficiency before judgment, with typed outcomes.
  10. Record the exact package each decision used.

RAG stays essential. The mistake is asking it to carry responsibilities it wasn't built for. A governed context pipeline starts from the decision, combines every kind of source, keeps identity and policy intact, reconciles time and meaning, checks sufficiency, and records the exact boundary the model received.

What you get isn't just a better prompt. It's an inspectable part of the application: reviewed before it ships, enforced at runtime and reconstructable afterwards. Retrieval supplies candidates. Context assembly decides what's allowed to become part of the judgment.


Frequently asked questions

What is the difference between RAG and context engineering?

RAG answers which documents look relevant to a request. Context engineering answers what a specific decision needs: which sources are mandatory, which the requester may use, how current each must be, how conflicts resolve, and whether the assembled package is complete enough to act on.

Why isn't top-k retrieval enough for enterprise AI agents?

A top-k result counts candidates, not coverage. Ten relevant passages can still miss a balance, a prior exception or a policy rule held in another system. Completeness has to be checked against the decision's declared requirements, not inferred from a non-empty result.

How should an AI agent handle missing or stale context?

Stop and say so with a typed outcome rather than continuing on less. Depending on the rules, the agent fetches more, verifies, routes the case to a person with the gap shown, or abstains. Continuing with documents alone should be an explicit, approved degraded mode.

How does this work for agents we already run?

Route the agent's tool calls through a governed runtime over MCP or HTTPS. Before each consequential call, the runtime assembles a checked context package from your documents, records, features and policy, scoped to the requester, and keeps a record of exactly what the agent saw.

With Frozion

How Frozion assembles the context behind each action

Frozion's Context Store & Assembly puts a checked context package behind every action, and evidence never gives orders. Structured facts come from typed operational collections in Collections & Query Builder, with join and result contracts and query receipts. Features come from the Feature Store, authored in SQL or visually, with freshness limits you define. Authorization applies roles, conditions, taxonomy scope, purpose and record-level checks, and Provenance & Evidence keeps one tamper-evident record of the facts behind each decision.


Sources

  1. NIST AI Risk Management Framework (AI RMF 1.0)AI risk as a lifecycle responsibility tied to context of use.
  2. NIST AI 600-1, Generative AI ProfileRisks across retrieval, integration, provenance and privacy.
  3. OWASP LLM01:2025 Prompt InjectionRetrieved content can carry instructions that steer a model.
  4. OWASP LLM08:2025 Vector and Embedding WeaknessesRetrieval and embedding risks, including cross-tenant leakage.
  5. NIST SP 800-53 Rev. 5Information-flow enforcement, least privilege and audit records.
  6. W3C PROV-ONeutral model for derivation and use of context items.
  7. JSON SchemaMachine-readable contracts for typed context items.
  8. RFC 8785, JSON Canonicalization SchemeStable hashing of the exact package a model received.
More in Data & context

Data & context

Context assembly 2
Retrieval & data access 3
State, memory & features 2

Other topics

Pick up where you left off: