Integrator

Sanitize the percepts before reasoning touches them.

A validation pattern — a dedicated gate that validates all incoming information (percepts) for quality and consistency before it ever reaches the model.

In practiceA support agent's CRM lookup starts returning a `status` field that changed from a fixed enum to free text; the integrator rejects the payload against its schema and raises a typed error, instead of letting the model reason over a value it would silently misread.

Level
04 · Production
Subdomain
Governance & Safety
Also known as
Perception Validator, Context Integrator
Trade-off
Higher data consistency is achieved against additional latency during perception processing.
The mechanism

How it works.

Data from outside passes a gate before the model sees it. The gate checks form and plausibility, and what fails becomes a clear error instead of context.

1 · Define

  1. Describe the expected dataA schema per source
  2. Add plausibility checksRanges, freshness, consistency

2 · On every input

  1. Data arrivesFrom a tool, an API or a sensor
  2. ValidateAgainst the schema and the checks
  3. Pass it onClean data enters the context
  4. Or raise a typed errorThe agent learns what is wrong
Percept
Anything the agent takes in from outside: a tool result, a document, a sensor value.
Typed error
An error that says which field failed and why, so that the agent or a person can react to it.
Fail closed
When the gate cannot judge the data, the data does not pass.
Walk it through

A real run, step by step.

TaskA support agent looks customers up in a CRM. The CRM has started to return free text in a field that used to hold one of three fixed values:
Illustrative run.
Incoming recordCheckReaches the model
Status “active”, updated 3 days agoSchema and ranges passThe record
Status “see notes field”The status is not one of the known valuesAn error: unexpected status
Credit limit of minus 5,000A limit must not be negativeAn error: implausible credit limit
Last update 14 months agoOlder than 12 monthsThe record, marked as stale
What this shows: without the gate the model would have read “see notes field” as a status and reasoned on from there, and nobody would have seen an error. The Integrator is the mirror image of output validation: it checks what comes in, not what goes out. The price is a little latency on every input and a schema per source that has to follow each change of that source.
In code

The pattern in code.

Pydanticpython
from datetime import datetime, timedelta
from enum import Enum
from pydantic import BaseModel, ValidationError

class Status(str, Enum):
    active = "active"
    paused = "paused"
    closed = "closed"

class Customer(BaseModel):
    status: Status
    credit_limit: float
    updated: datetime

class PerceptError(Exception):
    """Raised instead of handing doubtful data to the model."""

def integrate(raw: dict) -> dict:
    try:
        customer = Customer.model_validate(raw)
    except ValidationError as error:
        raise PerceptError(f"CRM record rejected: {error.errors()[0]['loc']}") from error
    if customer.credit_limit < 0:
        raise PerceptError("CRM record rejected: implausible credit limit")
    stale = datetime.now() - customer.updated > timedelta(days=365)
    # only this reaches the model
    return {**customer.model_dump(), "stale": stale}
Fit

Use it, or not.

When to reach for it

  • Data is received from unstructured or unreliable environments.
  • Cognitive data quality is essential to prevent hallucinations downstream.

When it backfires

  • Input data is already strictly sanitized and verified upstream.
Pitfalls

Two ways this pattern will hurt you.

Validation runs but its verdict is ignored

The integrator flags a payload as invalid and the rest of the graph processes it anyway because the flag was never wired into the downstream router.

Countermeasure

Reify the verdict as a typed state field. Add a conditional edge that routes invalid payloads to an explicit error branch.

The gate hardens until it rejects legitimate input

Each malformed payload tightens the schema a little further, until a legitimate variant the upstream system has always sent is rejected too — and the run dead-ends with no path forward.

Countermeasure

Version the schema against the upstream system's documented contract, not against the last bad payload you saw; log rejected payloads with their reason so an over-tight rule becomes visible.

Framework support

Where Integrator is native.

LangGraphcustom nodeAdaptable
Sources

Where this pattern comes from.

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

Search

Search patterns, frameworks, and pages.