Architecture

Teaching AI How Your Business Works: Mapping Rules into the Context Layer

A pile of crumpled translucent policy pages sits beside an orderly rack of frosted-glass rule cards on a dark surface; an orange line runs from a glass speech bubble through the one card pulled forward into a charcoal machine block

Most enterprise AI agents learn company policy the same way: someone pastes it into the system prompt. Discount tiers, approval thresholds, refund windows and compliance exceptions pile up until the prompt reads like a policy manual, and the model treats it the way people treat policy manuals. It skims, weighs every clause against every request, and when two rules collide it picks whichever answer sounds most plausible. Afterwards nobody can say which rule produced the answer.

The fix is architectural. Rules move out of the prompt into a governed context layer, the hard yes or no moves to a business rules engine, and the model keeps the two jobs it does well: reading the request and writing the reply.

Why prompt stuffing breaks as the rules pile up

A language model predicts text. It approximates a rule from the words around it rather than executing it, and the more words there are, the looser the approximation gets. Chroma's July 2025 study Context Rot tested 18 models and found that they "do not maintain consistent performance across input lengths": the same task becomes less reliable as more text surrounds it. A prompt carrying every policy the business has makes each individual rule harder for the model to apply, and the failure is quiet. The agent raises no error. It gives a confident answer that breaks a rule nobody checked.

Weak data makes it worse. In Taming the Complexity of AI Data Readiness (Harvard Business Review Analytic Services, sponsored by Cloudera, March 2026), only 7% of respondents said their organisation's data is completely ready for AI. WRITER's 2026 survey of 2,400 executives and employees found that 97% of executives had deployed AI agents in the past year, while 23% reported significant ROI from them.

Two panels compared. Prompt stuffing: a 14-page system prompt holding every discount, approval and refund rule in one block of text, where the model weighs every rule on every request, a policy change means editing and retesting the prompt, and there is no record of which rule decided the answer. Mapped into the context layer: separate versioned rule records with owners, such as DISC-04 v3 owned by Finance, Gold tier up to 15% without approval, retrieved for this request, where the agent sees only the matching rule, a policy change is one versioned edit, and every answer logs the rule ID it applied.

What a context layer is, and how it differs from a semantic layer

A semantic layer answers what the data means. It fixes "revenue" as the sum of paid orders, so every report and every agent uses the same number. Our five-layer context layer blueprint covers that foundation in detail.

A context layer answers how and when the AI may use the data: who may see the revenue figure, which discount policy applies to this customer, and what the agent does when a required field is empty. A rule that blocks refunds on orders older than 30 days lives here. Each rule is stored as a record with an ID, a condition, an outcome, a version and an owner, in a format a machine can query, such as JSON, YAML or a database table. The agent fetches the one rule that applies to the request in front of it instead of carrying all of them.

That record format is what makes the rules governable. When Finance changes the Gold-tier discount ceiling, someone edits one record, the version number moves, and every agent that queries the layer applies the new ceiling on its next call. Nobody retrains a model or rewrites a prompt.

Perceive, validate, respond: how an agent applies a rule

A model should never decide on its own whether a discount, a refund or a data release is allowed. Splitting the work between probabilistic language and deterministic rules, an approach often called neurosymbolic AI, gives each decision to the component that makes it reliably. In practice every request runs through three steps.

  1. Perceive. The agent reads the request and extracts the facts it needs: the customer, their tier, the deal type and the discount asked for.
  2. Recite and validate. The agent queries the context layer, retrieves the rule that applies and states it, then passes the facts to a business rules engine, such as Drools or a SQL check, which returns approved, rejected or routed for approval.
  3. Respond. The agent writes the reply around the engine's decision, and the run is logged with the rule ID and version it used.
Worked example of one request. The request asks whether Acme, a Gold customer renewing, can get 18% off. Step 1, perceive: the AI agent extracts customer Acme, tier Gold, deal type renewal, discount asked 18%. Step 2, recite and validate: the context layer and rule engine, called over MCP, return rule DISC-04 version 3 owned by Finance, Gold tier up to 15% without approval and above 15% to the account director, so the verdict is needs approval because 18% is above 15%. Step 3, respond: the agent tells the requester that up to 15% is pre-approved and that the 18% request has gone to the account director. An audit log row records the rule, the decision and the approver.

Stating the rule before acting gives a reviewer something to check. When an answer is wrong, the log shows whether the agent fetched the wrong rule or the rule itself was wrong, and those two failures have different owners. The engine's verdict also works as an AI guardrail the model cannot argue its way around, because the model never makes the call.

Where the Model Context Protocol fits

Anthropic open-sourced the Model Context Protocol (MCP) in November 2024 as a standard way to connect AI assistants to the systems where data lives. For business rules, MCP gives the agent one interface for asking a rule server what applies, the same way it would ask a CRM for a customer record. Anthropic's September 2025 engineering post on context engineering makes the wider case: give the agent the smallest set of information that answers the question at hand, fetched when it needs it.

MCP is a convenience, and a context layer works without it. A rules API or an n8n workflow can serve the same records. What matters is that rules live outside the prompt and outside the model's weights, with one owner each.

Some teams ask whether to fine-tune the rules into the model instead. Research on rule distillation (Yang and colleagues, COLING 2025) shows models can be trained to follow textual rules better, which helps with rules that almost never change. Rules that change every quarter belong in the context layer, where an edit takes effect immediately and leaves a version history.

Turning the rules in people's heads into records

The written policy is rarely the whole policy. A Dutch Odoo implementation partner brought us in to automate scheduling for a dental care group: 200 practitioners, 1,500 appointments a week, and treatment series with healing intervals, role matching and urgency limits. Those interdependent rules were more than Odoo's data model was designed to handle. We moved them into a scheduling engine and inverted the logic, so the engine records when each practitioner is unavailable and an AI agent places appointments in the time that remains. Every night five sync workflows feed the planning step, and any appointment the agent cannot place produces a report explaining why. The full case is on our enterprise AI consulting page.

The same method maps the rules behind any agent:

  1. Collect the rules where they live. Policy documents, approval emails, spreadsheets of exceptions, and interviews with the people who apply them every day.
  2. Write each one as a record. Condition, outcome, owner and version, in plain language a business owner can sign off.
  3. Split hard checks from guidance. Limits, approvals and data access go to the rules engine. Tone and preferences can stay with the agent.
  4. Replay past cases. Run last quarter's real requests through the rules and compare the decisions with what your team actually did.
  5. Give every rule an owner. A policy change then has one person who updates one record.

Our AI Audit starts with this mapping for the workflow worth automating first, and how we work shows who owns each stage after it.

Guardrails for regulated industries

In healthcare, the context layer decides which fields an agent may read before any patient data reaches the model. Our post on context layers for protected healthcare environments walks through that boundary, and AI agents in healthcare shows the workflows it supports.

Outside healthcare, the NIST AI Risk Management Framework (AI RMF 1.0, January 2023) and its Generative AI Profile (NIST AI 600-1, July 2024) ask organisations to govern, map, measure and manage AI risk. A versioned rule store with a logged decision for every run gives that review something concrete to inspect: which rule applied, which version, and who owns it. Our enterprise AI governance page covers the approval and audit controls that sit around it.

Frequently Asked Questions About Context Layers and Business Rules

What is a context layer in AI?

A context layer sits between your data and your AI agents. It holds business definitions, permissions and rules as versioned records, so an agent fetches the rule that applies to each request instead of relying on a long system prompt. See our enterprise context layer service for how we build one.

How is a context layer different from a semantic layer?

A semantic layer defines what data means, such as how revenue is calculated. A context layer adds how and when the AI may use it: who may see it, which policy applies, and what to do when data is missing.

Should business rules live in the prompt or in a rules engine?

Hard limits, such as discount ceilings, approval thresholds and data access, belong in a rules engine that returns a fixed decision. The prompt tells the agent how to behave and when to call the engine. That split keeps decisions consistent and makes each one traceable to a rule and a version.

What is context rot?

Context rot is Chroma's name for the drop in model reliability as the input grows. In its July 2025 study of 18 models, performance did not stay consistent across input lengths, which is why packing every rule into one prompt makes each rule less dependable.

Do we need MCP to build a context layer?

No. MCP is a standard interface that many agent frameworks support, which makes rule servers easier to reuse across agents. A rules API or an n8n workflow can serve the same records.

Map the rules your agents need

In a 30-minute discovery call you speak directly with an AI engineer about the workflow you want to automate and the rules it has to follow. If an audit is the right first step, we will tell you and scope it on the call.

Book a Discovery Call

Sources

  1. Hong, Troynikov and Huber, Chroma (July 2025). Context Rot: How Increasing Input Tokens Impacts LLM Performance. 18 models tested.
  2. Harvard Business Review Analytic Services, sponsored by Cloudera (March 2026). Taming the Complexity of AI Data Readiness.
  3. WRITER with Workplace Intelligence (2026). AI adoption in the enterprise. Survey of 1,200 C-suite executives and 1,200 employees.
  4. Anthropic (November 2024). Introducing the Model Context Protocol.
  5. Anthropic (September 2025). Effective context engineering for AI agents.
  6. Yang, Lin, Zhou and Wen (COLING 2025). Distilling Rule-based Knowledge into Large Language Models.
  7. NIST (January 2023). AI Risk Management Framework (AI RMF 1.0). NIST (July 2024). AI 600-1, Generative Artificial Intelligence Profile.

Ready to get started?

A 30-minute discovery call. You bring the process; we bring the plan.

Book a Discovery Call