Your AI Agent is running right now, who’s watching it?
Why packet inspection and static pre-deployment scans miss multi-step agent exploits, and the seven layers of runtime AI security.
In Part 1, we looked at prompt injection and how attackers exploit an AI through its inputs. In Part 2, we examined agentic identity and the question of who the AI is pretending to be. Both perspectives are valuable, but they remain largely static.
Production AI is not a still image. An AI application is a moving structure running across models, users, data, tools, APIs, autonomous agents, and external services. That reality brings forward a critical question: what is the AI actually doing right now?
This is where runtime AI security comes in.
A simple AI application looks manageable on paper: a user talks to an application, which queries an LLM, which returns a response. A realistic enterprise deployment is vastly different. The model is embedded in a compound system connected to internal knowledge bases, autonomous agents, vector databases, APIs, and external tools. Every single connection introduces a new security boundary.
Traditional application security controls might register that an HTTPS request was made, an API was called, or a specific user authenticated. What they cannot determine is the underlying AI context:
- Why the model generated the request in the first place
- Whether the user prompt or retrieved document contained an injection attack
- Whether sensitive data entered the context window
- Whether an agent is being coerced into performing unauthorized tasks
- Whether a sequence of individually harmless tool calls forms an exploit chain
Runtime Changes the Security Problem
Traditional application security asks whether a specific network request or packet is malicious. Runtime AI security requires an entirely different layer of operational questioning: Is this prompt malicious? Is the output unsafe? Is sensitive data leaking? Is the agent drifting outside its intended boundaries? Is this tool call legitimate, and is the overall sequence of actions suspicious?
Security is no longer solely about inspecting packets. It is about understanding contextual AI interactions.[01]
01 Note: Why WAFs miss context shifts
A WAF sees valid JSON over HTTPS on port 443. Only an AI-aware runtime control sees that the reasoning chain shifted after reading an untrusted attachment.
Consider a simple indirect attack. An employee asks an internal assistant to summarize an external customer report. The request itself is benign. However, hidden inside that external document is an instruction written specifically to hijack the model. The model processes the injected instructions, bypasses its guardrails, and returns restricted internal data directly to the user.
Nothing in the original prompt triggered an alert. The exploit emerged entirely during execution.
You Cannot Secure What You Cannot See
Before protecting an AI environment, you must discover it. In practice, enterprise environments fragment fast. An organization might run three foundation models, twelve applications, dozens of agents, multiple vector databases, and dozens of internal or third-party endpoints. Worse, several of these components were likely deployed by engineering teams without security oversight.
AI security posture begins with rigorous discovery. You cannot simply ask which models are approved. You need an active inventory:
- Which applications are calling AI endpoints?
- Which agents exist, and what data sources can they access?
- What tools are available to them, and what identities do they assume?
- Which third-party services are connected, and what dependencies exist between them?
- Discovery is the foundational requirement for everything that follows.
Inspection and Policy Enforcement
Once an AI system is active, its runtime interactions become security telemetry. A runtime security layer inspects prompts before they reach the model and inspects responses before they reach the user. This layer evaluates the exchange for prompt injection, sensitive data exposure, malicious payloads, unsafe URLs, and policy violations. Crucially, this inspection happens live during the interaction, not as a static check during development.
Detection alone is insufficient. If a system identifies a prompt injection and merely logs the event, it has only produced a detailed breach report. The practical question is policy enforcement: what action should the system take?[02]
02 Note: Detection vs. inline enforcement
Passive telemetry after an irreversible API call is post-mortem logging. Enforcement has to sit inline before the outbound tool sinks fire.
Depending on risk and confidence, responses should vary. A low-risk anomaly might warrant passive logging, while a high-confidence injection targeting restricted databases requires immediate sanitization, blocking, or escalation. The control layer requires enough context to make that distinction without breaking user workflows.
AI Agents Make This Harder
When we introduce autonomous agents, the challenge escalates. An ordinary chatbot generates text; an agent executes actions. It searches databases, reads customer records, compiles files, and calls APIs. The core focus shifts from “Was the response safe?” to “Was the executed action safe?”
Consider an agent equipped with two common capabilities: get_customer_data() and send_email(). Neither function is dangerous in isolation. However, if an attacker manipulates the agent’s context, the model can chain these functions together, retrieving private records and emailing them directly to an external server. The individual tool calls appear normal but the malicious sequence is not something which you would like.[03]
03 Note: Compositional tool-chain risk
Rule-based per-endpoint allowlists approve both functions individually. Only stateful sequence tracking flags read-private-records followed by external-send.
This attack surface expands further with standardized tool interfaces like the Model Context Protocol (MCP). If an attacker tampers with tool definitions, inputs, or outputs, the agent makes automated decisions based on compromised context. Securing tool execution requires evaluating identity, permissions, intent, and behavioral sequence together.
Red Teaming and Runtime Security Are Not Competitors
Pre-deployment evaluations and runtime protections are complementary controls. Red teaming asks how an AI system can be broken before it reaches production. Runtime security asks whether an active attack can be detected and mitigated in real time.
When red-team testing reveals that an agent can be manipulated into leaking data, runtime guardrails provide operational protection while the development team works on a structural fix. Testing exposes weaknesses; runtime controls protect against live exploitation; monitoring feeds insights back into the next testing cycle. AI security functions as a continuous feedback loop rather than a one-time certification.
The Architecture Required for Production AI
A defensible enterprise AI architecture requires visibility across seven distinct layers:
- AI Asset Discovery: Complete inventory of models, applications, agents, datasets, endpoints, and dependencies.
- AI Security Posture: Continuous analysis of exposed, misconfigured, or over-permissioned assets.
- Pre-Production Security: Automated red teaming and attack simulations before deployment.
- Runtime Inspection: In-line evaluation of prompts, model outputs, data flows, and tool calls.
- Policy Enforcement: Real-time rules to allow, sanitize, block, or escalate requests based on risk.
- Identity and Authorization: Explicit mapping of user identity, agent execution identity, and operational permissions.
- Continuous Monitoring: Behavioral tracking over time to spot contextual drift and emerging exploit patterns.[04]
04 Note: Unified trace IDs across all 7 layers
Correlating trace IDs across prompt, model call, and tool execution turns seven separate logs into one replayable incident timeline.
When an attacker attempts to exploit an agent, this layered visibility allows security teams to trace the full attack path, connecting the user identity, prompt text, model reasoning, tool invocation, and underlying data access into a single coherent incident.
Moving Past the Model
The core takeaway from modern AI security is that risks do not stay inside neat categories. Prompt injection is not purely an input problem. Agent compromise is not purely an IAM problem. Data leakage is not purely a DLP problem. These vulnerabilities move horizontally across data, models, applications, agents, and enterprise tools.
A model generating a bad response is a quality issue. An agent generating an unauthorized real-world action against enterprise infrastructure is a critical incident.
AI security cannot end with deploying an evaluated model. The environment must discover what exists, regulate what it can access, monitor what it executes, and intervene before an automated decision causes material harm.
Part 4 explores the reverse side of this problem: before evaluating what an AI system does at runtime, how do we verify the integrity of the data, weights, and artifacts that shaped the model in the first place?
Jump into Chapter 3 with Milo
Dodge these hazards in Storytime with Milo.