Executive Summary & Key Architectural Takeaways
- Put ambiguity in the probabilistic agent and put invariants in deterministic code; never rely on system prompts to enforce statutory or financial rules.
- Decompose production agent systems across five strict planes: Delivery/Identity (L1), Orchestration (L2), Control Shell (L3), Kinetic Execution (L4), and Telemetry/Eval (L5).
- Intercept every lifecycle transition with pre-model, pre-tool, and post-tool callbacks that can be unit-tested in CI/CD without calling a live LLM.
- Isolate core domain schemas, SHACL shapes, and OPA/Cedar policies in Layer 3 so your governance architecture survives model and SDK replacement.
Executable Control Shell Wrapping a Bounded Agentic Reasoning Core
1. The Boundary Allocation Rule: Put Ambiguity in the Agent, Put Invariants in Code
When engineering teams transition an AI prototype into regulated enterprise operations, their most common architectural mistake is treating the foundation model as the entire application runtime. They stuff authentication rules, JSON formatting constraints, pricing ceilings, retry policies, and compliance disclaimers into a 4,000-word system prompt and hope the model obeys every clause on every turn.
Why Prompt-Only Governance Degrades Over Time
Prompt-only governance fails because probabilistic sequence models do not execute hard boolean invariants; they weight competing contextual signals across an attention window. As conversation length grows, as edge-case documents are retrieved, or as an upstream provider updates model weights, adherence to complex multi-clause prompt constraints drifts unpredictably. Worse, sycophantic alignment pressure often causes models to relax policy rules when a user pushes back insistently.
Separating Volatile Models from Enduring Institutional Rules
Production agent engineering begins with a strict Boundary Allocation Rule: allocate unstructured linguistic interpretation, multi-source synthesis, and candidate action drafting to the probabilistic model, and allocate identity binding, state transitions, domain invariant validation, authorization, and retry safety to deterministic, version-controlled code. AnExecutable Control Shell wraps the bounded reasoning core so the model can propose actions creatively while the deterministic shell guarantees that no invalid state transition ever reaches production systems.
2. Inside the 5-Layer Production Agent Boundary
To make this separation operational across distributed engineering teams, our reference architecture partitions every agent system into five explicit horizontal layers connected by typed contracts:
- Layer 1 · Delivery & Identity Boundary: Terminates transport connections, authenticates the caller into an immutable
ActorContext, binds tenant scope, enforces ingress rate limits, and assigns an end-to-end correlation ID before any prompt is assembled. - Layer 2 · Bounded Agent Orchestration: Executes the Deterministic Context Compiler (enforcing a strict 60/30/10 token budget), manages the explicit workflow state graph, coordinates specialist subagents, and invokes the LLM core to produce a candidate
ActionProposal. - Layer 3 · Deterministic Control Shell & Semantic Gate: Intercepts every proposed tool invocation or state mutation to enforce JSON Schema types, canonical entity URI resolution, closed-world W3C SHACL shapes, OPA/Cedar authorization policies, and runtime budget ceilings.
- Layer 4 · Kinetic Enterprise Execution: Dispatches authorized Proof-Carrying Action Envelopes against enterprise APIs, databases, knowledge graphs, and MCP servers using write-boundary idempotency keys, postcondition verifiers, and semantic compensation handlers.
- Layer 5 · Observability & 7-Layer Evaluation Plane: Captures structured OpenTelemetry trajectory spans, attributes Cost-per-Successful-Task (CPST), runs shadow canaries, and promotes anomalous traces into CI/CD golden regression suites.
The 6-Step Turn Finite State Machine
Every single agent turn progresses through a deterministic six-step finite state machine—INGRESS_AUTH → COMPILE_CONTEXT → PROPOSE_ACTION → VALIDATE_GATE → COMMIT_KINETIC → EMIT_TELEMETRY—ensuring that no execution path can bypass Layer 3 inspection.
3. Lifecycle Callback Interception: Pre-Model, Pre-Tool, and Post-Tool Gates
Modern agent runtimes implement the Layer 3 Control Shell through deterministic lifecycle interception hooks surrounding the model and tool execution boundary (such as before_agent_callback, before_model_callback, before_tool_callback, and after_tool_callback in Google ADK, node pre-validation guards and interrupt() checkpoints in LangGraph, or tool guardrail tripwires in the OpenAI Agents SDK).
Each callback point enforces a distinct class of invariant:
- Pre-Model Interception (
before_model): Verifies that remaining token, step, and wall-clock deadline budgets are positive; executes sub-millisecond deterministic SPARQL/SHACL pre-filters ($0.0002) to short-circuit requests that can be answered or rejected without paying for an LLM call; and screens inbound prompts for PII/DLP policy compliance. - Pre-Tool Interception (
before_tool): Validates the candidateActionProposalagainst closed-world SHACL shapes and OPA/Cedar policy rules, injects hidden Layer 1 security credentials and deterministic idempotency keys, or halts execution with a typed abstention code (ABSTAIN_SHACL_VIOLATION,ABSTAIN_POLICY_CEILING). - Post-Tool Interception (
after_tool): Verifies downstream postconditions, attaches untrusted taint labels to retrieved external payloads, redacts sensitive fields before the tool output re-enters the model context window, and commits authoritative state deltas to the workflow store.
4. Degradation Ladders, Circuit Breakers, and Model-Free Control Testing
Because foundation model APIs experience latency spikes, regional capacity exhaustion, and occasional behavioral regressions after provider updates, a production control shell must include deterministic resilience governors.
The Four-State Operational Degradation Ladder
Rather than failing open or crashing completely during incidents, Layer 3 governs runtime autonomy across a four-state degradation ladder: NOMINAL (full bounded autonomy within ADR ceilings) → RESTRICTED (all state-mutating proposals downgraded to human-cosigned preview mode) → READ_ONLY (write tools disabled; retrieval and diagnostic synthesis only) → HARD_KILL (immediate deterministic fallback to static rules or human queue routing). Per-tenant, per-agent, and per-tool kill switches allow SRE teams to transition any workflow down this ladder in under a second.
Testing the Control Plane Without Invoking an LLM
A critical engineering dividend of separating Layer 3 from Layer 2 is that the entire control shell is 100% deterministic code. In Layer 1 of our 7-Layer Evaluation Stack, CI/CD pipelines run thousands of adversarial unit fixtures—malformed tool payloads, cross-tenant ID spoofing attempts, expired bitemporal prices, and budget exhaustion traces—directly against the Layer 3 gate in under ten seconds with zero LLM token spend.
5. Framework-Agnostic Survival Across Eight Agent Ecosystems
Agent orchestration SDKs evolve every few months, whereas enterprise domain ontologies, statutory compliance rules, and system-of-record contracts must endure for a decade. When engineering teams entangle their business rules inside framework-specific prompt templates or proprietary agent abstractions, migrating from one runtime to another requires a ground-up rewrite.
By encapsulating domain semantics in modular OWL/SHACL artifacts, expressing authorization in standard OPA or AWS Cedar policy files, and defining tool pre/post-conditions as portable TypeScript or Python envelopes in Layer 3, the control shell remains completely independent of the Layer 2 orchestrator. Whether a workflow is orchestrated via Google ADK workflow agents, LangGraph state graphs, OpenAI Agents SDK handoffs, Anthropic Claude with MCP servers, Microsoft AutoGen, CrewAI Flows, LlamaIndex Workflows, or Temporal durable activities, the identical Layer 3 Control Shell governs execution without modification.