Agents act, and their actions must stay under independent control. This is the seven-layer loop that keeps them there.
How this page fits. HexTyx's AI Runtime Security guide covers the whole AI application lifecycle. This page covers the agent-specific architecture: how authority, context, runtime control and retesting fit into one loop for AI agents that act. For the testing layer in depth, see AI agent vulnerability scanning. HexTyx is a security vendor, and the testing results mentioned come from our own apps with synthetic data.
A compromised chatbot might produce an unsafe answer. A compromised AI agent could use legitimate permissions to perform an unauthorized action, and repeat it across connected systems before a human notices. Agents retrieve documents, call APIs, run code, send messages, update records and coordinate with other agents. That is why they need an architecture, not a checklist.
The goal is not to make a model impossible to manipulate. It is to ensure manipulation does not become unauthorized access, exfiltration or privilege escalation. A model can be manipulated; the security boundary must still hold.
It is a layered, continuously improving approach that covers an agent's whole operating life: discover exposure, test defenses, authorize actions independently, watch behavior, contain incidents and verify fixes. "Immune system" describes the coordination, not a promise of immunity.
No single piece is enough. A scanner can find weaknesses without blocking production attacks. A monitor can spot behavior without authority to stop it. An authorization layer can restrict actions and leave an injection undiscovered. The value is in connecting them into a loop.
| Question | Traditional application security | AI agent security |
|---|---|---|
| What influences behavior? | Inputs, code, configuration, dependencies | Those, plus prompts, retrieved context and model-generated decisions |
| How are actions chosen? | Mostly predefined logic | Often chosen dynamically by the agent |
| What creates risk? | Vulnerabilities, identity abuse, misconfiguration | Those, plus instruction manipulation, context poisoning, tool misuse, unsafe autonomy |
| What to monitor? | Requests, identities, systems, transactions | Those, plus agent-to-tool behavior, context provenance, action sequences |
| How to validate? | Code analysis, testing, operational controls | Traditional testing, plus AI-specific adversarial tests and workflow validation |
Conventional security hasn't become obsolete. AI adds decision and trust boundaries it can't fully observe.
You can't protect what you can't identify. Inventory agents, model endpoints, MCP servers, APIs, vector stores, memory, service identities and downstream systems. For each agent record the owner, data it can reach, tools and scopes, read/write/delete/send capability, autonomy level and emergency-disable mechanism. Capture effective permissions, not the intended ones.
Configuration review can't show whether an agent withstands adversarial behavior. Test direct and indirect injection, retrieval manipulation, unauthorized tool calls, parameter tampering, memory contamination and cross-agent paths, and validate outcomes, not just detection. Did the agent retrieve protected data? Did it reach an unauthorized recipient? Which control stopped or allowed it? A failed attack isn't proof of protection.
This is the heart of the design. The model recommends; independent controls decide. A natural-language instruction must never override identity, access policy, transaction limits or approval requirements. Use least-privilege identities, resource-level checks on every consequential operation, server-side parameter validation, allowlists for tools and destinations, separate read and write permission, approval gates for irreversible actions and short-lived credentials. An agent may draft a refund recommendation, but the transaction service, not the model's memory of a rule, enforces the cap.
Agents consume content from several trust domains. Validate provenance before ingestion; enforce user- and task-level access at retrieval (being in a vector database doesn't make a document available to every agent); treat retrieved content as untrusted data, never as instructions; apply retention, tenant isolation and deletion to persistent memory; and check outputs before delivery. See RAG attack vectors and AI agent memory security.
Useful signals include agent identity and initiating user, tool and resource, validated parameters, data sensitivity and destination, policy decision, unusual volume, unexpected tool sequences, delegation changes and repeated denials. A tool-by-tool policy may allow retrieval and email separately, while a sequence-aware control catches "hundreds of records, then an email to an unfamiliar recipient." Monitoring needs a response path, because an alert alone doesn't stop an action.
Define proportionate responses: deny a call, require fresh authorization, pause for review, revoke a token, restrict to read-only, disable an integration, quarantine an agent, preserve evidence. Decide in advance who can suspend an agent and how credentials are rotated and service restored. See circuit breakers for rogue AI agents and AI security incident response.
A fix can regress after a prompt change, model upgrade, new tool or permission change. Discover changes, reassess affected boundaries, rerun targeted tests, confirm authorization and containment still work, prioritize by exploitability and impact, and retest fixes. The aim isn't the most scans. It is current evidence that the controls on consequential behavior still hold.
Take a research agent with document, CRM and email access. A malicious document tries to turn legitimate access into a transfer.
| Stage | Control that breaks the chain |
|---|---|
| Hostile content enters retrieval | Source validation and retrieval security |
| Content tries to redirect the agent | Adversarial testing and context-handling controls |
| Agent requests sensitive records | Independent authorization and data-access policy |
| Agent tries to send data out | Destination policy and approval gate |
| Unusual activity occurs | Runtime monitoring and sequence analysis |
| A weakness is found | Remediation and regression testing |
No control is assumed perfect. The architecture means one failure doesn't automatically become an incident: an attempt meets several independent boundaries, not one instruction saying "don't do that."
HexTyx has tested 28 domain apps with synthetic data and live LLM agents. In our Relay app a forged admin_worker handoff was accepted until we added a signature gate, and in our Vault app an injected fake confirmation led the agent to move $5,000. Both are failures at the authorization layer, which is why layer 3 doesn't rely on the model. They show failure modes, not rates for your environment.
Pick metrics tied to risk reduction: agent inventory coverage, high-risk permission exposure, adversarial test coverage, confirmed attack-path count, remediation verification rate, policy-denial effectiveness at the enforcement point, time to contain, unreviewed consequential actions and evidence freshness. More findings after wider testing can mean better visibility, and a low count means little if coverage is narrow. See CISO evidence and metrics.
Prioritize controls around the actions that could cause the most harm, then widen coverage. For a first look at exposure, use the AI Agent Security Exposure Assessment, which works from information you supply and is an initial review, not proof that controls work.
An immune system is an architecture, not a product label. It spans identity, policy enforcement, data controls, telemetry, response and testing. HexTyx contributes on the assessment and validation side. Discovering a weakness, detecting an attack and blocking an action are different capabilities, so verify which component provides each in your own deployment. See AI agent tool security, AI API security and OWASP Agentic Top 10 compliance.
Run the free playground scanner against your AI application, or read the related guides.