Give an agent too little context and it guesses. Give it too much and it leaks.
Context engineering is the work of deciding what an AI agent sees at each step: which instructions, records, tool results and memory go into the model's context window, in what form, and what stays out. Anthropic defines it as "the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference." In regulated work there's a second question on top of that one. Some data helps the agent and is still not allowed in front of it.
This guide is for CTOs building agents that handle customer, supplier or case data, starting with what to give an agent and what to keep out, by data type. Last updated 1 December 2026.
Ask them before a source is connected to an agent.
Context engineering is deciding what an AI agent sees at each step, including instructions, records, tool results and memory, in what form, and what stays out; in regulated work it also applies the legal rule for each data type.
In IBM's words, language models "generate responses solely based on the context window they have access to at inference time." That makes the context the agent's whole working world.
The term started to gain traction in June 2025, when Shopify's CEO Tobi Lütke and Andrej Karpathy both backed it publicly. Karpathy called it "the delicate art and science of filling the context window with just the right information for the next step." Anthropic calls it "the natural progression of prompt engineering." Gartner's definition stresses the business side, "designing and structuring the relevant data, workflows and environment so AI systems can understand intent, make better decisions and deliver contextual, enterprise-aligned outcomes."
An agent makes this harder than a chatbot does. It rebuilds its context on every step, tool output lands in the window, and it may keep memory across sessions, so the wrong data has more ways in.
We call the principle behind this context before decision. The agent assembles the right, bounded picture of a customer, supplier or case before anyone weighs it, and a person makes the call on the prepared case. Our context graph guide explains where that picture comes from.
Most context engineering advice is about quality. In regulated work you also need a rule per data type, because privacy, secrecy and competition law decide some rows before quality does. GDPR requires personal data to be "adequate, relevant and limited to what is necessary in relation to the purposes for which they are processed." The FTC's Safeguards Rule tells the financial institutions it covers to limit users' access "only to customer information that they need to perform their duties and functions."
Treat the table as a default; your legal team sets the final rule per market.
| Data type | Rule | What the agent sees | Why |
|---|---|---|---|
| Policy, procedure and risk method | Give | The current approved version, in full | The agent can't apply a rule it can't see |
| Customer identity and due diligence record | Give in part | Only the fields the task needs | Data minimisation and access limits |
| Transaction history | Give in part | A dated window and a summary, not every row | Long inputs reduce accuracy |
| Special category data (health, religion, ethnicity, biometrics) | Keep out | Nothing, unless a lawful exception applies and the task needs it | GDPR Article 9 and UK automated decision rules |
| Card numbers | Give in reduced form | Masked or tokenised number only | Limits what a leak exposes |
| Card security codes, PINs, track data | Keep out | Nothing, including transcripts and logs | PCI DSS bans storing them after authorization |
| Passwords, API keys, tokens | Keep out | Nothing; the tool holds the secret | A prompt can't leak what it never held |
| Suspicious activity report status and drafts | Keep out of every agent outside the filing team | Nothing | SAR confidentiality and tipping-off law |
| Supplier bids and pricing | Give in part | Only the bid under review, never a rival's price | Tender confidentiality and competition law |
| Untrusted outside content (emails, web pages, supplier files) | Give, labelled | Marked as untrusted, in a session that can't send data out | Prompt injection |
| Past decisions and their reasons | Give | The decision, the reason, the date and who made it | Consistency with precedent |
| Another customer's or team's records | Keep out | Nothing; stores are partitioned | Retrieval can leak across user groups |
The first figure shows how a record gets sorted. The source records go through a data type check before anything reaches the agent. The data type check sends task fields to the agent context in full. The data type check sends identifiers and card numbers to reduced form, masked or tokenised. The reduced form then joins the agent context. The data type check sends credentials, card security codes and suspicious activity report status to kept out, where no prompt can reach them. The agent context produces a prepared case, and the reviewer decides.
Sort every source by data type before it reaches the agent. A rule written in the prompt can be argued around, but a field the agent never received can't leak.
Special category data is banned by default. GDPR Article 9(1) says processing data about racial or ethnic origin, religion, health, biometrics and similar categories "shall be prohibited" unless an exception applies. Since 5 February 2026, UK law has said a significant decision based on that data "may not be taken based solely on automated processing" outside narrow conditions.
Card security data has a hard rule. The PCI Security Standards Council says "PCI DSS Requirement 3.3.1 prohibits storage of SAD after authorization, even if encrypted." The Council's guidance says keeping card codes "in any form of digital audio recording" after authorization breaks that rule, so redact them before a call recording or its transcript reaches an agent.
Suspicious activity reports are the row teams miss. US rules say "A SAR, and any information that would reveal the existence of a SAR, are confidential." The FATF says staff should be prohibited by law from disclosing "the fact that a suspicious transaction report (STR) or related information is being filed with the FIU." A customer service agent that can read case notes can tip off a customer by accident.
Don't rely on instructions to keep data private. OWASP warns that system prompt rules against revealing data "may not always be honored and could be bypassed via prompt injection or other methods." If data must not leak, keep it out of the window.
LangChain sorts the techniques into four groups. Writing saves context outside the window, selecting pulls it in, compressing keeps "only the tokens required to perform a task," and isolating splits work across separate contexts.
The second figure shows how they fit together. Write moves notes from the context window to a memory store outside it. Select uses a retriever to pull only the records the next step needs into the context window. Compress turns a long context window into a summary that keeps the decisions and drops the noise. Isolate hands a narrow task from the context window to a sub-agent with its own clean window. The sub-agent returns a short result to the main context window.
Google designed its Agent Development Kit around the same rule. "Every model call and sub-agent sees the minimum context required," and agents must reach for more through tools, "rather than being flooded by default."
Manus found that "any irreversible compression carries risk," because you can't tell which detail will matter ten steps later, so it drops a page's content but keeps its URL. A reviewer can follow that pointer back to the source.
Memory needs its own controls. Anthropic's memory tool documentation tells developers to add validation "that strips sensitive data before your handler writes the file."
A bigger window doesn't fix bad context. Chroma tested 18 models in 2025 and found "their performance grows increasingly unreliable as input length grows." On one memory task, every model scored much higher on a focused prompt of about 300 tokens than on the full input of about 113,000.
The older research points the same way. The 2023 Lost in the Middle study found models use information best at the start or end of the input and worst in the middle. NVIDIA's 2024 RULER benchmark found that of models claiming 32,000-token windows or more, "only half of them can maintain satisfactory performance at the length of 32K." And in the NoLiMa benchmark, GPT-4o fell "from an almost-perfect baseline of 99.3% to 69.7%" at 32,000 tokens when the answer didn't share words with the question.
Bury a customer's one relevant fact among 300 transactions and a risk agent may miss it, so two similar customers get different treatment.
Prompt engineering is writing good instructions. Microsoft's agent course describes it as "a single set of static instructions," while context engineering manages "a dynamic set of information, including the initial prompt."
Ownership changes too. A prompt is one engineer's text, but an agent's context comes from pipelines, tools, retrieval and memory, so it's an architecture decision for the CTO, the data owner and compliance together.
Retrieval-augmented generation is one way to fill the window. The original 2020 paper described models "which combine pre-trained parametric and non-parametric memory for language generation." IBM notes that RAG "doesn't address the system prompts, how message history is managed and how information from other tools is incorporated into the context."
| Prompt engineering | RAG | Context engineering | |
|---|---|---|---|
| What it decides | The wording of instructions | Which documents to fetch | Everything the model sees at each step |
| When it runs | Written once, revised by hand | On each query | On every step of an agent run |
| Typical failure | Vague instructions | Wrong or stale passages | Leaks, overload, poisoned memory |
RAG also brings risk with it. OWASP says retrieval and fine-tuning "do not fully mitigate prompt injection vulnerabilities." Its entry on vector and embedding weaknesses warns that when several user groups share one vector database, "there's a risk of context leakage between users or queries," and recommends "permission-aware vector and embedding stores." In a bank, a relationship manager's agent mustn't retrieve another team's case notes just because they look similar.
Every document an agent reads can carry instructions. The UK's National Cyber Security Centre says current models "simply do not enforce a security boundary between instructions and data inside a prompt," and that prompt injection may never be fully fixed the way SQL injection can.
EchoLeak, CVE-2025-32711, was an "Ai command injection in M365 Copilot" that let an outside attacker "disclose information over a network."
The practical answer is to limit what one agent session can combine. Meta's Agents Rule of Two says agents "must satisfy no more than two of the following three properties within a session," meaning untrusted input, access to private data and the ability to change state or communicate outside.
The third figure shows the rule. Untrusted content enters the agent session from emails, web pages and supplier files. Private data enters the agent session from your own systems. An agent session that holds both should have no path to outside communication without a person in between. When a task needs all three, the agent session stops and a person approves the next step.
The NCSC adds two controls. Use "deterministic (non-LLM) safeguards that constrain the actions of the system," and log "full input and output of the LLM, as well as tool use, API calls etc." OWASP's entry on excessive agency says to "Implement authorization in downstream systems rather than relying on an LLM to decide if an action is allowed or not."
Data owners set the rules; the agent works inside them; a person decides.
| Component | Responsibility | Boundary |
|---|---|---|
| Data owner | Sets the rule for each data type. | Legal signs off per market. |
| Agent | Prepares the case from its bounded context. | Never decides or sends on its own. |
| Reviewer | Decides and records why. | Sees what the agent saw. |
A named person decides on every prepared case; the agent recommends and never decides on its own.
Procurement is a good test, because a supplier evaluation agent sees bids, prices, bank details, ownership records and contract terms.
Bids carry legal weight. EU public buyers must not disclose what suppliers mark confidential, including "technical or trade secrets and the confidential aspects of tenders." The European Commission's competition guidelines treat information on "costs, capacity, production, quantities, market shares, customers" and strategy as commercially sensitive. So an agent scoring one bid shouldn't hold a rival's pricing in the same context, and a shared agent across business units needs separated stores.
Data quality is the other half. Gartner said in 2025 that "fragmented and low-quality data across procurement systems can hinder accurate outputs" for generative AI in procurement. In 2024 it also advised buyers to "Incorporate data privacy standards as key criteria in supplier evaluations." Our vendor due diligence guide shows what a supplier file should contain before an agent sees it.
Illustrative scenario, not a customer result.
This case is made up to show the method. A buyer runs an agent that scores bids in a tender with three suppliers.
In the EU, the AI Act's data, logging and human oversight duties for high-risk systems now apply from 2 December 2027 for Annex III systems, after the 2026 Digital Omnibus delay. When they apply, a deployer that controls input data must ensure it "is relevant and sufficiently representative in view of the intended purpose," and must keep the system's logs for "at least six months."
The Monetary Authority of Singapore published its final AI risk management guidelines in October 2026. Its response to feedback says monitoring of agentic AI should extend to "information flows and decision-making paths across workflows that use AI, such as reasoning processes, actions taken, and tools used." The UK ICO's draft guidance on automated decisions says to "keep a record of how the human was involved in the decision," and that spot-checking alone isn't enough.
In the Bank of England and FCA survey published in October 2026, 80% of respondents had agents in production providing decision support, where "AI agents recommend actions, humans decide and execute," and only 2% deployed agents with broad autonomy.
Read together, these point to one record. Keep what the agent saw, which tools it called, what it recommended and who decided. Our guide to decision traces covers what to store.
FluxForce is the platform your departments run AI agents on. The agents investigate and prepare the work, a person makes the call, and every step leaves evidence an examiner can replay.
The platform works in five public stages, take in, understand, weigh, prove, and report and learn, with governance controls and data protection on every step. The fourth figure shows the order. Take in passes the source records to understand. Understand passes one bounded view of the customer or supplier to weigh. Weigh passes the recommendation and its reasons to prove. Prove passes the evidence record to report and learn.
Context before decision happens in understand. The data type rules in the table above apply there, before anything is weighed, and prove keeps what the agent saw in tamper-evident form.
The closest of our solutions here is Customer Risk Assessment. A US bank's AML programme must include "Understanding the nature and purpose of customer relationships for the purpose of developing a customer risk profile." Building that profile is a context problem. On our solution page, the agent "Uses the risk factors and weights in your policy," and "Each rating lists the factors that drove it." Its page says "Upgrades to High go to a person for sign-off" and "Any rating can be replayed as it stood on a given date." See how Customer Risk Assessment works.
On fit, our first app line is financial crime and compliance. AI agents that investigate AML, sanctions, fraud and KYC alerts and prepare the case. Your analyst makes the call, with evidence an examiner can replay. You decide how much each agent does on its own, and every one has a kill switch. Procurement agents run on the same platform in the same pattern, and we can't point you to customer results for them yet. Your data rules, risk method and approvers stay yours.
Agentic AI and real-time decisioning explains why hand-offs break at speed, and the AI agents directory shows the agents on the platform.
Data minimisation and the special category ban.
EU regulation, in force.
2026-12-01
Prompt rules can be bypassed; keep data out.
Industry standard list, 2025 edition.
2026-12-01
| Metric | Definition | Decision guardrail |
|---|---|---|
| Reviewer change rate | Share of prepared cases a reviewer changes. | A rising rate pauses wider use. |
Context engineering decides what an agent knows when it prepares a case, and so what a reviewer ends up judging. In regulated work the data type rule comes before any quality tuning. Give the task what it needs, pass identifiers and card numbers in reduced form, and keep credentials, SAR status and rival bids out of the window entirely. Then keep a record of what the agent saw, so the person who decides can show why.
Context engineering is deciding what an AI model sees at each step, including instructions, records, tool output and memory, and what stays out. Anthropic describes it as curating "the optimal set of tokens (information) during LLM inference."
In an LLM app, it covers everything that reaches the model besides the user's question, such as the system prompt, retrieved documents, message history and tool results. A model only knows what's in its window at that moment, so the app has to assemble it each time.
Prompt engineering writes the instructions. Context engineering decides the full set of information around them on every step, and in regulated work it also decides which data the agent may never see.
A person. The agent applies your method and prepares the rating with its reasons, and a person signs off. Upgrades to the High band go to a person for sign-off.
No. RAG is one way to select context, and context engineering also covers instructions, memory, tool output and what stays out.