Controller

Polices the agent's actions against policy as the run unfolds.

Continuously monitors the behavior of the agent and transparently aligns it with ethical principles and compliance rules. Realized at scale as a dedicated governance agent (watching for policy violations) or security agent (flagging anomalous behavior) that supervises other agents and escalates to a human only on a trip.

In practiceA financial-advice agent passes every draft recommendation through a compliance controller that checks it against a regulatory ruleset, halting the run and alerting a reviewer on any rule trip.

Without itWithout a controller, policy violations from autonomous agents in sensitive domains surface only after consequences — a fine, a harmful disclosure, or a regulatory breach — rather than at the point of the offending action.

Level
04 · Production
Subdomain
Governance & Safety
Also known as
Ethics Monitor, Value Alignment Observer
Trade-off
Stricter ethical compliance is gained at the expense of operational overhead and complex rule definitions.
The mechanism

How it works.

A second agent or a rule engine watches what a working agent is about to do and checks it against a set of rules. It lets the action pass, or it stops the action and calls a person.

1 · Set up

  1. Write the rulesPolicy and compliance as checks
  2. Place the controllerBetween the agent and the outside world

2 · On every action

  1. The agent proposesA draft answer or a tool call
  2. The controller checksAgainst every rule
  3. Pass or tripNo rule fired, or one did
  4. On a trip: halt and escalateA person decides, and the reason is logged
Rule
A check with a clear answer, for example: no single position above 10% of the portfolio.
Trip
A rule fired. The action is held. It is not silently corrected.
Escalation
Handing the held action to a person, together with the draft and the rule that fired.
Walk it through

A real run, step by step.

TaskA financial-advice agent writes four draft recommendations. A compliance controller checks each before it reaches the customer:
Illustrative run.
Draft saysRule checkedVerdict
“A broad index fund fits your long horizon.”Suitability for the customer's risk classPasses
“Put 60% into this single stock.”At most 10% in one positionTrips: held for a reviewer
“This fund guarantees 8% a year.”No promise of guaranteed returnsTrips: held for a reviewer
“The fees are 0.2% a year, see the fact sheet.”Fee disclosure is presentPasses
What this shows: a person sees two of four drafts, the two that need a decision. The controller is separate from the agent that wrote the drafts, so one manipulated prompt does not switch off both. The price: every action waits for the check, the rules have to be written and kept current, and a rule nobody wrote is not checked.
In code

The pattern in code.

Plain Pythonpython
RULES = [
    ("concentration", lambda draft: max(draft.positions.values(), default=0) <= 0.10),
    ("no_guarantees", lambda draft: "guarantee" not in draft.text.lower()),
    ("suitability", lambda draft: draft.risk_class <= draft.customer_risk_class),
]

def controlled(agent, request):
    draft = agent(request)
    tripped = [name for name, check in RULES if not check(draft)]
    audit.append("controller", "check", {"draft": draft.id, "tripped": tripped})
    if tripped:
        return escalate(draft, rules=tripped)  # halted: a person decides
    return draft  # no rule fired: the draft goes out
Fit

Use it, or not.

When to reach for it

  • Agents act autonomously in socially or commercially sensitive environments.
  • Transparency regarding decision-making is required.
  • A fleet of agents needs a supervisory layer that does not require a human at every step.

When it backfires

  • The agent operates exclusively in safe, low-risk sandbox environments with no external impact.
Pitfalls

Two ways this pattern will hurt you.

The controller silently blocks; the agent retries forever

The controller rejects a call but returns a generic error. The agent treats it as a transient failure and retries with the same payload.

Countermeasure

Classify rejections as policy-final or transient. Policy-final must surface as a typed signal the agent can react to — not as a retryable error.

An action path that skips the controller

The controller wraps the main tool calls, but a side path — a directly-invoked tool, a sub-agent, a cached action — reaches the outside world without passing through it. The one unguarded path is where the incident happens.

Countermeasure

Enforce the controller at a single choke point every side-effecting action must traverse, rather than decorating call sites one by one; fail closed if an action arrives unrouted.

Framework support

Where Controller is native.

LangGraphvia policy nodesAdaptable
Sources

Where this pattern comes from.

  1. Agentic Design Patterns: A System-Theoretic FrameworkIn the source list

Search

Search patterns, frameworks, and pages.