NewInteractive Agents Live

Insight

Context Is the Agent: How to Manage Context for Production AI Agents

The hardest problem in production AI is not the model. It is getting the right rules and knowledge to the model at the moment of every decision. Here is why most agents get it wrong, and the architecture that gets it right.

InteractiveAI14 min read

The bottleneck moved

The constraint stopped being the model. Most teams have not moved with it.

Two years ago, the constraint on an AI feature was the model. You waited for it to get smart enough. That wait is largely over. The constraint has moved, and most teams have not moved with it.

The new constraint is context: the specific rules, steps, definitions, and data the model can see at the exact moment it makes a decision. An agent answering a billing question needs your refund policy, the customer's plan, and the escalation rule for that tier. It does not need anything about onboarding, fraud, or the other nine hundred rules in the book. Give it everything and it drowns. Give it the wrong slice and it invents.

Getting that selection right, turn after turn, for years, is the whole game in production. It is also where most agents quietly fail. Not in the demo, where the rulebook is small and the script is clean. In month three, when the policies have piled up and the conversations stop looking like the happy path.

The two ways it fails today

Both dominant approaches work in a demo and break in production, for opposite reasons.

There are two dominant ways teams manage context. Both work in a demo. Both break in production, for opposite reasons.

Stuff everything into the prompt

The first approach loads every rule, edge case, and policy into one monolithic system prompt. It is simple, and it scales badly. As the prompt grows, the model can no longer weigh competing priorities: instructions get lost, and reliability degrades exactly as you ask the agent to do more. There is a security cost too. The entire rulebook is present on every call, so whatever a prompt injection can reach is everything.

Hard-code the path in advance

The second approach overcorrects. It takes discretion away from the model with a rigid routing graph that sends each turn down a fixed path to a node holding a narrow slice of context. Precise, until a real person does a real-person thing: a compound question, an abrupt topic switch, a backtrack. The flow has no branch for it. And when the router guesses wrong, the node is missing the one rule that mattered, and the answer is confidently incorrect.

“Not the full library. Not a routed slice. The exact subset.”

Bernardo Branco, Co-Founder and Chief AI Officer, InteractiveAI

Either way, the agent works with the wrong context, and both reliability and cost pay for it. The prompt-stuffed agent pays on every call by shipping its whole rulebook to the model. The graph-routed agent pays whenever reality steps outside its wiring.

A better unit: context per decision

Assemble the exact context each decision needs, fresh, on every single turn.

The fix is to stop treating context as something you assemble once and attach to a session, and start treating it as something you assemble fresh for each decision.

Context engineering, in general, is the practice of controlling what enters the model's context window. Most implementations do it at build time: you write a large prompt, wire some retrieval, and ship a fixed arrangement. Dynamic Context Engineering does it at runtime, per decision. On every turn, an evaluation engine reads the precise state of the interaction and assembles only the rules and knowledge that turn requires. What stays out is as deliberate as what goes in.

Three distinctions matter, because it is easy to mistake this for things it is not:

  • It is not naive RAG. Retrieval fetches a fixed top-K of documents against a query embedding. Dynamic Context Engineering composes context from authored policies, routine state, session variables, tool results, and retrieved knowledge, ranked against the decision at hand, not a similarity score alone.
  • It is not a session context window. A session window is a passive container that fills up as the conversation runs. This is an active composition layer that decides, each turn, what belongs in the model's view and what does not.
  • It is not a build-time artifact. The prompt is not written once and frozen. The subset is rebuilt every turn from versioned parts, so the same agent behaves correctly on turn one and on turn fifty.

The machinery, per turn

None of it is hidden. Here is what actually happens on one turn.

None of this is abstract, and none of it is hidden. Here is what actually happens on a single turn, and every step of it is inspectable.

A turn begins when the engine receives an event, a customer message in a conversation or a system trigger in an autonomous run, and ends when the agent produces a reply. In between, the engine runs a bounded loop, capped by default at five iterations, so it can react to what tools return without ever running away.

One turn, inside the engineSteps 1 to 3 loop, max 5x
  1. 1

    Match policies

    Every policy is a condition and an action. The engine tests conditions against the current state and loads only the ones that match. The rest stay out.

  2. 2

    Evaluate routines

    Multi-step procedures are graphs. The engine decides whether to enter one, advance a step, or backtrack, and the model sees only its current step and immediate options.

  3. 3

    Run tools and reasoning

    Tool calls (served over MCP) and structured reasoning steps execute. Their results rejoin the state, and the policies they govern are re-matched.

  4. 4

    Assemble and answer

    Once the loop settles, one model call generates the reply, grounded in exactly the context the engine assembled for this turn. Nothing else.

The engine loops over matching, routine evaluation, and execution as tool results change the state, up to a bounded number of iterations, before it drafts a single grounded reply.

The atomic unit in all of this is the policy: a condition paired with an action, both written in plain language and stored as a versioned document. Nothing exotic.

A policy, in full
id: refund-window
condition: >
  The customer asks to return an order that was
  placed more than 30 days ago.
action: >
  Explain that returns are available within 30 days
  of purchase, so this order is outside the window,
  and offer store credit as the alternative.
criticality: HIGH

Because that condition is evaluated every turn it is in scope, the rule cannot be quietly forgotten as the conversation wanders. High-criticality rules, the compliance and safety ones, fire whenever they apply and re-fire after the tools they govern run. That per-turn re-matching is the guarantee everything else rests on: enforcement is structural, handled by the engine, not left to the model to remember.

When the loop settles, a single model call generates the reply, grounded in exactly what the engine assembled for that turn: the system prompt, the matched policy actions, the active routine step, glossary terms, session variables, retrieved knowledge, and tool results. Nothing else is in the room. The defaults are deliberately modest, a handful of policies evaluated per batch, a handful of knowledge snippets retrieved only when a turn needs them, so the context stays small even when the library behind it is enormous.

The eight parts the engine composes from

Eight authored components, versioned and owned by the people accountable for them.

The engine does not invent context. It composes it from eight authored, versioned building blocks, each scoped to the agent and owned by you.

ComponentWhat it holds, and when it loads
PromptsThe agent's persistent identity and baseline: name, tone, language, format, guardrails. Scoped to the stages where they apply.
PoliciesThe atomic unit of behaviour, a condition paired with an action. Matched against the state every turn; only the ones that apply load.
RoutinesMulti-step procedures modelled as graphs. The model sees its current step and immediate options, never the whole map.
GlossaryShared vocabulary that grounds how the agent reads input and how policy conditions are interpreted across the agent.
MacrosReusable blocks of authored wording, written once and reproduced verbatim, such as a fixed disclosure or an approved phrasing.
VariablesContextual state across the interaction: customer attributes, session data, flags, scores. Turns generic rules into data-driven ones.
ToolsExternal connectors served over MCP. They enter context only when a policy that needs them activates, which cuts false tool calls.
Knowledge BaseThe authored retrieval surface that grounds answers in your own documents. Optional, and one input the engine composes against, never a substitute for policies.

All eight are versioned, and the engine assembles them per turn, never all at once. That is the difference between a prompt you edit and an asset you operate: the behaviour lives in named, inspectable parts, not buried in a wall of instructions.

A rigorous startup buys a lean runtime

Pay the expensive work once, up front, instead of on every message.

Doing this well is not free. The architecture is built to pay the cost at the right time, once, rather than on every message.

Before an agent serves its first turn, a startup evaluation pass rewrites and validates everything the team authored: the instructions, the routine conditions and actions, the transitions. It structures all of it into a form the runtime can match against cheaply, and the platform will not accept traffic until that pass completes. Think of it as CAPEX. The expensive, model-heavy work happens once, up front.

At runtime, the OPEX is small by design. The engine is not reasoning about your entire rulebook on every message. It matches the few policies the turn needs and traverses a routine it has already built. That is why per-turn cost stays roughly flat even as the library grows for years, and why the same agent can run cheaply at scale.

Startup is the investment. Runtime is where it pays off.

What it buys you

Four consequences of the same move, and they compound.

Assemble the right context on every turn and four things follow. They are not independent features. They are consequences of the same move, and they compound.

  • Precision. A focused context is a focused model. With no competing rules diluting attention, answers stay accurate and on-policy, turn after turn, instead of degrading as the rulebook grows.
  • A shrinking security surface. Each turn presents only the rules that moment needs, so the blast radius of any single call is small. The library can grow for years while what an attacker can reach on any one turn stays bounded. The asset gets larger; the exposure does not.
  • Scale without instruction fatigue. Because per-turn context stays roughly constant, the rulebook can grow into the thousands of policies without the model losing the thread. Capability scales while reliability holds.
  • Interpretable by design. Every turn is captured as a structured trace tied back to the versioned rules that fired. When something goes wrong, you read the trace and edit the rule. You do not reverse-engineer a paragraph of prompt text and hope.

Put the three approaches side by side and the difference is not a matter of taste. It is structural.

System promptRouting graphInteractive Agents
Context each turnThe entire rulebook, on every call.Whatever the current node was pre-wired to hold.Only the rules the current decision matches, rebuilt each turn.
Rule enforcementThe model must recall every rule while juggling all of them.Enforced only if the router lands on the right node.Structural: in-scope rules fire every turn and re-fire after the tools they govern.
Conflict resolutionLeft to the model to reconcile.Left to the model inside the node.Engine-enforced precedence, set by you in advance. Non-conflicting rules still apply.

Context is the agent

The context is not an input to the agent. It is the agent.

This reframes what an agent even is. An Interactive Agent is not a prompt with tools bolted on. It is a body of context, authored by the people who know the business and assembled by the engine at the moment of each decision.

Get that right and the agent stops being a black box you hope behaves. It becomes operational IP: structured, versioned, executable, and owned by you. It improves as your policies improve, which is why the agent you ship on day one is the weakest it will ever be. In production, managed this way, it only gets stronger.

If you want the mechanism in depth, read Dynamic Context Engineering and how context becomes an authored, versioned asset on the platform. If you want to build one, the Quickstart takes you from an empty manifest to an agent answering real turns.

Two next steps

See context engineered on your own workflow.

Primary

Bring one workflow that breaks your current agent, a compound request, or a policy that must never be missed, and watch it handled turn by turn.

Secondary

Go from an empty manifest to an agent answering real turns, with policies, routines, and tools, in the developer Quickstart.