Constraint engineering
Encoding Temporal and Regulatory Constraints in LLM Workflows: A Technical Guide
Rules written only in prompts are requests. Production controls need explicit representations, observable evidence, and a verifier that can return a reproducible verdict.
This guide focuses on two demanding classes of constraints: time and regulation. It implements the hard-constraint pillar from the agentic reliability framework.
Soft prompt-based constraints vs hard solver-proven constraints
A soft constraint expresses a preference. Concision, tone, explanation depth, and preferred suppliers can be scored and traded against other goals. A hard constraint defines the feasible boundary. Permission, statutory deadlines, spending ceilings, separation of duties, and prohibited data use cannot be averaged away.
Classify each rule before implementation. Record its source, scope, subject, object, condition, operator, threshold, exceptions, priority, and required evidence. Ambiguous words such as prompt, reasonable, material, and appropriate need an operational definition or a human decision point.
Use the least subjective verifier that fits. Recompute arithmetic. Validate identifiers against registries. Check fields against schemas and permissions. Evaluate timestamps and dependencies with code. Use a constraint solver when several rules must be satisfied together.
A model judge can interpret nuanced policy text, but its result should remain reviewable. Require structured output, cited evidence, and uncertainty. Never use an average semantic score to override a deterministic hard-rule failure.
The constraint-blindness guide explains why repeating a hard rule in more prompts does not create enforcement.
How the Constraint Engine works under the hood
Normalize each hard rule into a predicate over scenario state, agent actions, and trace events. A predicate should return pass, fail, or unknown, plus the evidence used. Unknown is important when the trace lacks data needed for a defensible verdict.
Build a dependency graph between constraints and variables. This identifies which agent outputs or tool results provide the values each rule needs. It also exposes rules that no component can currently evaluate.
Run feasibility before execution when variables and domains are known. A solver searches for an assignment that satisfies all hard predicates. If none exists, extract a small conflicting set so the scenario author can see which requirements cannot hold together.
Run verification during and after execution. Event-level checks can stop prohibited actions before they occur. Post-run checks can assess outcomes, aggregates, and evidence completeness. Store every result with constraint version, verifier version, trace location, and observed values.
Separate the rule definition from framework-specific adapters. LangGraph, CrewAI, AutoGen, and custom orchestrators produce different traces. Normalize them into one event model so the verifier does not need to be rewritten for every framework.
Encoding temporal rules
Represent time as typed facts, not prose fragments. Distinguish event time, processing time, effective time, expiry time, and deadline. Record timezone and clock source. A bare timestamp cannot answer whether a policy was effective when the decision occurred.
Common temporal operators include before, after, within, no earlier than, no later than, until, and overlaps. Sequence rules can state that approval must precede execution. Freshness rules can require that a source version be no older than a defined interval.
Model durations and calendars explicitly. "Within two business days" needs a jurisdiction, holiday calendar, start event, and inclusion rule. "After consent" needs the consent version, subject, scope, and revocation state.
For concurrent agents, use causal identifiers as well as timestamps. Clock skew can make two distributed events appear reversed. Parent step IDs, version numbers, and state transitions provide stronger ordering evidence.
Encoding regulatory rules
Start with the authoritative source and preserve citation context. Break each obligation into actor, action, data, purpose, condition, exception, evidence, and retention. One paragraph may produce several constraints with different owners.
Map rules to decision points. A privacy restriction belongs at data access and disclosure steps. An approval rule belongs before the controlled action. A recordkeeping rule belongs when evidence is created and retained. Checking everything only at final output is too late.
Encode exceptions as explicit branches with higher evidence requirements. An emergency exception should not be a boolean shortcut. It should record who invoked it, the qualifying condition, scope, duration, notification, and later review.
Version rules by effective date and jurisdiction. A run should be evaluated against the rule set that applied to its decision, not whichever policy text is current during a later audit.
The guide to regulatory review for AI agents explains how signed records and examiner-ready narratives use this evidence. The broader evaluation framework connects these controls to scenarios and traces.
Related evaluation guides
- The 4 Pillars of Agentic Reliability: A Blueprint for Production AI
- Preventing "Constraint Blindness" in Autonomous AI Agents: Patterns and Anti-Patterns
- Building AI Agents You Can Defend in a Regulatory Review
- What is Multi-Agent Evaluation? A Complete Guide for 2026
- The Definitive Glossary of Multi-Agent Evaluation Terms (2026 Edition)