惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
爱范儿
爱范儿
量子位
Martin Fowler
Martin Fowler
V
V2EX
博客园 - 三生石上(FineUI控件)
I
InfoQ
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
Engineering at Meta
Engineering at Meta

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
AI Safety is a Systems Problem: Building a 4-Layer Runtim...
Otto Plane · 2026-05-24 · via DEV Community

When we talk about LLM security, the conversation usually flattens into semantic prompt analysis or generic out-of-band moderation loops. But if your guardrail strategy relies entirely on an asynchronous post-inference API call or basic string matching, you haven't engineered a security boundary—you've deployed a facade.

If you are shipping agentic systems that mutate state, safety isn't a post-processing feature. It is a fundamental routing and execution infrastructure constraint.

True operational control requires moving past passive monitoring and embedding an explicit, layered runtime defense directly into your execution pipeline. Here is how I am breaking down a deterministic, systems-first engineering architecture.


The Core Thesis: Unvalidated Intent is Remote Code Execution

When you grant an LLM infrastructure access via function calling, native tool integration, or database connections, you fundamentally shift your application's threat profile. You are moving from static data retrieval to dynamic, non-deterministic execution generation.

If an agent is permitted to dynamically construct its own downstream execution paths, a prompt injection ceases to be a simple text-handling bug. It becomes a functional unauthorized remote code execution (RCE) or an unvalidated, destructive database write.

To handle this, we have to isolate the AI's non-deterministic outputs inside strict, deterministic system boundaries. This requires a 4-layer runtime stack mapped directly into the data path.


┌────────────────────────────────────────────────────────┐
│ 1. INGRESS SURFACE   (Payload Parsing, Input Gating)   │
├────────────────────────────────────────────────────────┤
│ 2. OUTPUT BOUNDARY   (Type Enforcement, Token Slicing) │
├────────────────────────────────────────────────────────┤
│ 3. EXECUTION GATE    (Tool Interception, Scope Blocks) │
├────────────────────────────────────────────────────────┤
│ 4. POLICY TRACE      (Deterministic State Auditing)    │
└────────────────────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode


1. The Ingress Surface

Defensive infrastructure must execute before a single token hits an inference endpoint. The Ingress Surface acts as a strict network perimeter and payload filter.

Instead of passing unparsed user inputs directly to an orchestration kernel, the Ingress Surface acts as an inline interceptor designed to handle:

  • Structural Input Validation: Verifying that incoming telemetry, context payloads, and user strings match exact strict type expectations before the orchestration pipeline ingests them.
  • Proactive Payload Sanitization: Scanning text data streams for known indirect injection vectors, escaping malicious characters, and scrubbing structural delimiters that attempt to manipulate underlying system prompts.
  • Pre-Flight Policy Evaluation: Resolving logical policy conflicts and aborting requests prior to spinning up expensive, non-deterministic model inference loops.

2. The Output Boundary

Never trust raw model outputs. Even heavily fine-tuned, specialized models can hallucinate structural syntax, fail to maintain type consistency under stress, or bleed internal system context.

The Output Boundary serves as an explicit egress validation proxy:

  • Type & Schema Enforcement: Mechanically parsing and matching generated model responses against JSON Schemas, Zod types, or Protobuf definitions. If the response structure breaks compilation rules, the proxy catches it instantly.
  • Deterministic Output Slicing: Programmatically truncating, redacting, or blocking data streams that attempt to bypass application boundaries, leak unintended PII, or output systemic configuration data before those frames reach a downstream service or the client UI.

3. The Execution Gate

This is the critical enforcement kernel for any agentic system utilizing function calling or tool invocation. An agent must never have direct network or process visibility into your underlying execution layer.

Instead, the agent emits an execution intent (a tool call request), which is intercepted and evaluated by the Execution Gate:

  • Strict Parameter Gating: Enforcing rigid whitelists for function names and verifying arguments against explicit compile-time boundary constraints. If the agent attempts to supply unapproved arguments or invoke out-of-scope methods, the execution thread is instantly severed.
  • Stateful Authorization Loops: Halting high-impact or destructive operations (such as data mutations or outbound API webhooks) to demand human-in-the-loop validation or pass independent cryptographic verification checks before letting the command dispatch.

4. The Policy Trace

When a non-deterministic pipeline breaks an application state, standard unstructured syslog files or unstructured text blocks are useless for debugging. You need deterministic, highly structural diagnostic observability.

The Policy Trace functions as an immutable, step-by-step audit record of the entire execution cycle:

  • State & Token Archiving: Capturing exact system prompt states, raw token ingress structures, matched policy triggers, intermediate function payloads, and precise Execution Gate responses.
  • Deterministic Reproducibility: Structuring execution logs into deterministic replay graphs so engineers can feed the exact failure parameters back into a development environment, isolate the architectural leak, and patch the policy configuration.

Moving From Theory to the Code Base

Shifting from passive validation to active runtime enforcement means moving your security logic directly into the data path. Instead of running asynchronous cron checks or out-of-band evaluations, you have to build low-latency infrastructure:

  • Inline Network Proxies: Intercepting raw HTTP/gRPC requests before they hit your orchestration layer to strip malicious payloads or abort non-compliant calls.
  • Decoupled Policy Engines: Offloading validation logic to isolated engines (like Open Policy Agent or specialized WASM modules) so policy changes don't require redeploying your core application.
  • Runtime Interceptors: Injecting deterministic hooks into your agent's tool-calling SDKs to intercept, inspect, and mutate function arguments before the execution kernel triggers them.

I am currently developing the technical architecture, core proxies, and SDK integrations for this exact runtime stack over at Open AI Guardrails.

If you are currently writing middleware for runtime verification, compiling policy rules down to code, or building deterministic isolation boundaries for agentic workflows, I’d love to know how you're handling the latency trade-offs. Let’s talk implementation details in the comments below.