Context Engineering for AI Agents

An agent reads a customer email asking to change the quantity on an order to 400. It extracts the number perfectly, updates the order and sends a confirmation. The order had shipped two days earlier. Nothing was wrong with the model. What was missing was context, and that is the problem context engineering for AI agents is meant to solve.

Context engineering for AI agents is the practice of deciding what an agent knows at each step of its work. Most guides cover the technical half of that: instructions, tools, memory and retrieval. This guide covers the half that decides whether an agent survives in an enterprise: the process context. What it is, why agents fail without it, where it comes from, how to build it, how to govern it and how to measure whether an agent has enough of it.

What is context engineering for AI agents?

Context engineering is the discipline of curating everything that enters an AI model's working memory while it runs: system instructions, examples, tool descriptions, retrieved documents and the history of the task so far. Anthropic's engineering team describes it as the natural progression of prompt engineering, because agents that work over many steps need their whole working state managed, not just a well-written instruction.

Context is also finite. The more a model is given, the harder it becomes to find what matters, an effect researchers call context rot. So the craft is selection: the smallest set of information that makes the right action most likely.

For an agent that answers questions, that selection is mostly about documents. For an agent that acts inside a business process, it is mostly about the case in front of it.

Context engineering vs prompt engineering

Prompt engineering is about writing a good instruction. Context engineering is about everything the model sees, at every step, including what it learned two steps ago and what it is about to retrieve next.

The shift happened because of agents. A chatbot answers once. An agent runs in a loop: it reads, decides, calls a tool, reads the result and decides again. Every turn adds information that could be useful or could be noise. A prompt is written once. Context is assembled again at every step.

That is why the term spread so quickly once agents moved from demos to real work. The question stopped being "how do I phrase this?" and became "what does the agent need to know right now?"

The two layers of context for enterprise AI agents

For an agent that handles real operational work, context comes in two layers. Most of the public guidance covers the first. Most production failures come from the second.

Context engineering for AI agents: the two layers of context, technical context (instructions, tools, memory, retrieval) and process context (the case, its state, the usual paths and the rules)

Technical context

Technical context is what the model sees in a single call: the system prompt and examples, the tools and MCP servers it can use, its notes from earlier steps and the documents retrieved at runtime. Engineering this layer well keeps an agent focused, fast and affordable. It is where frameworks, model providers and most tutorials put their attention, and rightly so.

Process context

Process context is what the business knows about the case in front of the agent:

  • The case. Which customer, order, claim or ticket this message belongs to.
  • Its state. What has already happened to it, across the inbox, the ERP and the CRM: the original order, the confirmation, the change requested two days later.
  • The paths. How cases like this usually run, which variants exist and where they tend to go wrong.
  • The rules. What the agent may do on its own, and when a person decides.

A language model cannot infer the state of an order from one email. Someone has to give it.

Gartner's March 2026 research on the context layer for AI agents makes the same split. It names three core components: semantics, which captures what business concepts mean; operational state, which captures what is happening right now; and provenance, which records where information came from and how decisions were made. Most context engineering guidance is about semantics and retrieval. Operational state is where enterprise agents fail.

Why enterprise AI agents fail without process context

Go back to the order that had already shipped. The agent had excellent technical context. It read the email, understood the request and called the right tool. It simply did not know which order was meant, that the order had left the warehouse, or that changes for this customer above a certain value need approval.

The same pattern shows up wherever work arrives as messages:

  • A reorder is processed as a new order, because the agent cannot see that the same purchase order arrived yesterday through another channel.
  • A delivery complaint is answered from the ERP status, while the real update sits in an email thread between the carrier and a planner.
  • An exception that one colleague always handles by hand, from memory, is treated as the standard case.

These are not model failures. They are context failures.

The numbers point the same way. In Confluent's 2026 Data Streaming Report, which surveyed 4,625 IT leaders, 32% of organisations had agentic AI in production. Among those, 77% reported stalled projects, and data quality and governance problems ranked among the top obstacles alongside skills and model reliability. Gartner expects over 40% of agentic AI projects to be cancelled by the end of 2027, citing escalating costs, unclear business value and inadequate risk controls. An agent that cannot see the process cannot be trusted with it, and an agent nobody trusts does not get to scale.

Where process context comes from

Process context does not live in one system. The order is in SAP, the customer in Salesforce, the change request in a shared mailbox and the reason for the exception in someone's reply. Assembling it means reading all of those sources and tying them to the same case.

Process intelligence and the context graph

That is the job of process intelligence. It reconstructs how work actually runs from the communication and system data a business already has, and links every message and record to the case it belongs to. The result is a context graph: a real-time, AI-constructed map of how a business process actually unfolds, built from the messages, transactions, CRM records and ERP objects that make up the operational reality of an enterprise.

Process maps answer: how should this work? Context graphs answer: how does this work? For an agent, only the second question is useful.

The hard part is linking. An email rarely carries the order number in a clean field. A follow-up arrives from a different person, in a different language, three days later. Tekst calls the capability that follows one case across email, ERP and CRM Universal Tracing. Without it, an agent sees a stream of unrelated messages. With it, the agent sees a case. As Servaas Strobbe, Head of Product at Tekst, puts it: "If you don't capture what happens in email and documents, you're automating guesswork."

Why RAG and knowledge graphs are not enough

Two neighbouring approaches are often mistaken for process context. Retrieval-augmented generation fetches documents that resemble the question. That helps an agent with knowledge, such as a policy or a product sheet, but it does not tell it the state of a live case. A knowledge graph describes what things are and how they relate: this customer, these products, that contract. It does not describe what is happening to them this week.

Both have their place in the technical layer. Neither replaces a reconstructed view of the process.

How to engineer process context for AI agents

Process context can be built step by step, and the work starts before any agent is deployed.

  1. Map the process first. Find out how the work actually runs, with real volumes, variants and exceptions, rather than how the procedure describes it. Automated process discovery does this from inbox and system data in days.
  2. Define the case. Decide what one unit of work is: an order, a claim, a ticket. Everything the agent sees should hang off that case.
  3. Link messages to records. Tie every incoming email, attachment and system event to its case, even when there is no shared reference number. This is where most context is lost.
  4. Give the agent state, options and limits. At each step, pass the current state of the case, the actions the agent is allowed to take and the conditions under which it must hand over.
  5. Keep a person in the loop where it matters. Route uncertain or high-value cases for approval, in the tools people already use.
  6. Feed corrections back. When a person corrects the agent, that correction should improve the context for the next case instead of disappearing into an inbox.

Teams that follow this order usually find that the agent itself becomes the easy part. The work is in making the process visible and keeping that picture current.

Context and governance: what an agent may see and do

Context is not only about giving an agent more. It is also about giving it the right amount, and recording what it used. One of the three themes behind Gartner's 2027 trends is governing the autonomous agent platform: the context, controls, identity and security that trustworthy autonomy needs.

For operations, governance comes down to four questions. Which cases may this agent see, and which data within them? Which actions may it take on its own, and up to what value or risk? When must it stop and hand over to a person? And can you show afterwards what it saw and why it acted?

Process context makes all four answerable, because the agent works on a defined case rather than on whatever happened to land in its prompt. Approval steps belong in the flow of work. At Tekst, for example, uncertain cases go to a person in the Sidepanel, which shows the email, the extracted data and one button to approve, and an automation built from an AI assistant through the Tekst MCP is only published after a person confirms it.

An agent that cannot explain what it saw cannot be audited. An agent that cannot be audited does not get access to SAP.

How to measure whether an agent has enough context

Context gaps are measurable, and it pays to measure them before blaming the model. Five signals are worth tracking:

  • Case match rate. The share of incoming messages the agent links to the right case. A low rate means the linking layer is weak.
  • Handover rate. The share of cases the agent passes to a person. Falling over time is good; suddenly rising usually means new variants it has no context for.
  • Correction rate. How often people change what the agent proposed, per step. Corrections cluster where context is missing.
  • Accuracy per step on your own data. Measured on a sample of real cases, not on vendor benchmarks.
  • Exceptions caught. The share of known exception types the agent recognises before acting.

Take a baseline of how the process runs today before the agent goes live. Without it, there is no way to tell whether the agent improved the process or just moved the work around.

AI context platforms: what Gartner's 2027 trend means for operations

In October 2026 Gartner listed AI context platforms among its top strategic technology trends for 2027. Seen from operations, the reasoning is clear: as agents gain autonomy, what they know about the business decides how far they can be trusted. That turns context from a developer concern into an operational one.

A context platform for operations needs to do three things. It has to reconstruct the process from the systems and communication where it runs. It has to keep that picture current as work changes. And it has to make it available to agents in a controlled way. The Model Context Protocol has become a common way to handle that last part, which is why a growing number of enterprise software vendors now offer MCP servers. Tekst offers one too, so AI assistants such as Claude, ChatGPT or Copilot can work with the process context Tekst builds.

This is also where agentic process automation comes in. Process intelligence supplies the context, agents act on it, and the outcome of every action flows back into the picture of the process. Seeing and doing, in one loop.

Where to start with context engineering for AI agents

Start with one process where work arrives as messages and the cost of a wrong action is visible: an order inbox, a claims queue or a customer service mailbox. Map how it really runs before deciding what an agent should do in it. Full process visibility is typically possible in under 10 days.

Then ask one question for every step the agent would take: what would an experienced colleague need to know before doing this? The answer is the process context your agent needs. Engineer that first, and the prompt becomes the smallest part of the problem.

Other blog you might like
What Is Workflow Automation? A Guide for Enterprise Operations

What is workflow automation? A guide that goes beyond trigger-action basics, grounded in how enterprise operations actually run.

Deduction Management in B2B: Best Practices and How to Automate It

Deduction management explained: the types of B2B deductions, why the process fails at scale, best practices, and what AI can automate.

SAP ECC End of Life
SAP ECC End of Life: Why Process Mining Should Come Before Your S/4HANA Migration

SAP ECC end of life explained: the 2027 and 2030 deadlines, your options after 2027, and why process mining before an S/4HANA migration pays off.