Skip to main content

How the engine works

The ReAct loop and its context​

The engine is the part of Parlant that turns a customer message into a reply. On every message it works out which of your rules apply, gives the model those rules and their tools, lets the model act, and checks the result before the customer sees it. Read this section to understand why your agent did what it did.

What you'll learn
  • Why Parlant runs one reasoning loop instead of a routed graph
  • The five stages every turn goes through
  • Which page in this section covers each stage
  • How one trace id lets you see everything a turn did
Talk this page through with your coding agent

Parlant's engine runs a ReAct loop. On every customer message, one model reasons about the whole conversation, calls tools when it needs to, reads what came back, and repeats until it has a reply to write.

Unlike a framework such as LangGraph, the execution model is not a graph of nodes and edges. Parlant works more like a coding agent does: one agent, one loop, and tool calls as the model's native way of acting.

Around the loop, Parlant adds smart context discovery and reliability controls. On every turn it decides which of your policies apply, which tools come with them, and which approved phrasings to show. Where you ask for it, it also checks the model's proposed outputs before they take effect.

Why does Parlant use a ReAct loop instead of a routed graph?

A graph often feels natural when you plan an agent (classify the intent, route to a specialized node, and so on). It works for linear tasks. Real customer conversations are not linear or especially structured.

Parlant. The policies the conversation has made relevant go in front of the model together, in their original form. Nothing is lost on the way to the agent's decision.

A routed graph. The router sends the message to the nodes it thinks apply. Each node sees only its own isolated part, and the reply is stitched from their outputs, which can lose information.

For example, a customer may ask about a return, mention a billing charge in the same breath, and then come back to the return. In a graph, every edge between nodes is a seam where conversational context is lost. Every such seam is a chance for the agent to behave inconsistently.

Parlant 4 follows the ReAct execution model instead of a graph, for three main reasons.

Context consolidation. One model sees the whole conversation and every policy that applies to this moment, as a whole. When the customer mixes or switches topics, the model has the entire context in view and can reconcile it. A graph handles each topic in pieces, in separate nodes.

Cost. Look at the graph below with a message that touches two topics. The router runs once to classify it, each activated node runs its own completion over its own prompt, and something has to stitch the outputs into one reply.

That is three or four requests for one customer message, each carrying its own copy of the shared context. The number grows with every topic the message touches.

The loop makes one request. The discovered policies go into a single prompt, and one completion handles all of them. That is cheaper, and it gives one coherent reply instead of several stitched ones.

Parlant does make one extra paid request when a session is created. It warms the provider's prompt cache so that later turns are cheaper. That request shows up in the session's usage before any message is sent.

Graph
4 requests, 3 prompts
Router: classify the intent
Returns node: own promptshared context, again
Billing node: own promptshared context, again
Stitch two outputs into one reply
Loop
1 request, 1 prompt
One prompt: shared context, the returns policy and the billing policy togetherone coherent reply
One customer message that touches returns and billing. The graph spends a request on routing, one per activated node, and one to stitch the outputs, and each node carries its own copy of the shared context. The loop puts both policies in one prompt and answers in one request.

Graphs are often used to keep the prompt focused, so that it is not filled with information from topics that are out of scope right now. Parlant takes care of that for you with automatic context discovery.

Alignment with how models are trained. In the last few years, providers have clearly trained their models on exactly this shape of work: reason coherently about a large, nuanced context, call tools, read the result, continue. The ReAct model uses the model the way it is built to be used.

A graph that breaks the work into narrow single-purpose calls gives up what that training buys. It fights against the way frontier models are trained in practice.

How an agent turn works end-to-end​

A turn is everything the agent does in response to one activation, which is usually a customer message. Every turn moves through the same sequence:

Behavior is controlled with rules, which come in two kinds: observations and policies. Observations and policies introduces them. The pages in this section follow them through a turn.

What this section covers​

Each stage of the turn has its own page:

  • Rule matching: how rules are discovered, evaluated, and resolved on every turn.
  • Policy focus: how the matched rules are kept in front of the model.
  • Tool review: how tools are selected, checked before they run, and folded back into the turn.
  • Message review: how the reply is composed, checked, and delivered.
  • Signals: how the discovery classifier works and how to write signals for it.
  • Evaluation scheduling: how dependent and cross-referential rules are judged in a second pass.

Turn diagnostics​

When a reply surprises you, you want to see exactly what the engine did. Parlant makes this easy. Everything a turn produces shares one trace_id: the customer message, status events, tool calls with their arguments and results, and the reply.

That same id fetches the turn's diagnostic report. It holds the timeline, every log line, the rules discovered with their scores, the rules matched with their rationale, and each review's verdict.

Advanced controls​

Once you understand the engine, Parlant gives you several places to adjust it. Your coding agent can set up any of these: