AI Security Explained · Episode 02

Inside Gen AI: LLMs, RAG, MCP and Autonomous Agents

Follow one employee request through a language model, enterprise search, and an AI agent to see where data access and tool permissions need to be enforced.

Companion video · 8:24

Securing Generative AI in the Enterprise

Follow one request through the system

Imagine asking an enterprise AI assistant, “Which security policies apply to this application, and can you open a ticket for what we need to fix?” It sounds like one request. The assistant may search internal documents, send excerpts to a model, and call a ticketing service. If it asks another agent for help, the request crosses another boundary. In the first episode, we mapped what an AI system can do. Here I want to follow what happens when someone actually uses it.

A large language model, or LLM, generates a response one token at a time. A token can be a word, part of a word, or punctuation. During inference, the model works with the information the application fits into its context window, including instructions, the user’s question, and any retrieved material. It can write a convincing summary of a policy while missing an exception. Give the user a citation they can check. Enforce data access and tool permissions in the surrounding application and services.

A foundation model learns general patterns during pre-training. Its developers may then use examples to improve how it follows instructions or use feedback to shape its responses. When you select a model for enterprise use, record the version you evaluated and repeat your checks when a new one is introduced.

Give the model the information the user can access

Retrieval-augmented generation, or RAG, lets an application bring current information into a request. One pipeline prepares the knowledge base by splitting approved documents into passages and indexing them. Many systems use embeddings, numerical representations that help find passages with similar meaning even when they use different words. At request time, the retrieval service selects relevant passages and passes them to the model as context.

For the policy assistant, check the employee’s identity and document permissions at retrieval, before any text enters the model’s context. In a shared index, derive the tenant and access scope from trusted identity data. Enforce tenant scope at the retrieval service or data layer so an application filter is one of several safeguards. A similarity score tells you which passages are related to a question. Your access policy determines which passages the employee can see. Carry permission changes and deletions through to the index and affected caches. Decide who can add or change a source, because retrieved text can also influence the model’s behavior.

One pipeline indexes documents with access metadata. A second verifies the user and filters retrieval by tenant and document permissions before the model receives the passages.
During indexing, preserve the access metadata you’ll need at request time. During retrieval, enforce it before passing any passages to the model. View full-size diagram

Choose what needs to change

A prompt can ask the assistant to cite a policy and format its answer as a checklist. RAG supplies current policy passages while leaving the model’s weights unchanged. Fine-tuning changes learned behavior. One approach, Low-Rank Adaptation (LoRA), leaves the base model frozen and trains a smaller set of parameters. It can help adapt a model to a repeatable task. For policies that change regularly, I would begin with a governed document source and RAG. If the task calls for fine-tuning, track the training data and model artifacts, control who can change them, and evaluate the adapted model before release.

The context window has limited room. A long history, several policy excerpts, and repeated tool results can compete for it. Decide which material the assistant needs for the current request and set input and output limits. If the application stores information between requests, treat that memory as another data store with access controls and a retention policy.

Give agents limited authority to act

Drafting a ticket gives the employee something to review. Creating one changes a system. An agent can propose a tool call, receive the result, and decide whether another step is needed. The ticketing service still needs to check whether the requested operation is allowed. Give the agent a dedicated identity and limit it to the operations it needs. An assistant that files tickets in an approved queue has a clear job. Changing a production access rule calls for a separate, explicit approval.

Set limits on the number of steps, how long the workflow can run, and how much it can spend. Record who requested the action, which agent proposed it, which policy allowed or denied it, and what happened. Minimize sensitive content in logs. Provide a way to stop a workflow and revoke the agent’s access.

An agent planner proposes a tool call. A policy service checks scope and business rules and requests human approval when required. The tool service enforces authorization before executing.
The policy service evaluates the proposed action. The service that performs it enforces authorization and returns a result. View full-size diagram

Separate tool access from agent delegation

Model Context Protocol (MCP) gives an AI application a common way to connect to servers that expose tools or resources, such as a tool for creating a ticket. Agent2Agent (A2A) lets independently implemented agents exchange tasks, status, and results. The assistant might use A2A to ask a compliance agent to identify the relevant policy owner and use MCP to request a ticket through a separate integration.

Review those connections separately. For MCP, approve the server and capabilities, restrict credential scopes, and review changes to the tools. For A2A, verify the peer’s identity and scope what it may receive or do on the caller’s behalf. Enforce authorization at the service that owns the data or action.

MCP connects an AI host to document and ticketing services. A2A lets one agent delegate a task to another and receive task status and results.
Tool integrations and agent delegation have separate identities, permissions, and data-handling requirements. View full-size diagram

Trace the boundaries in your next review

Pick one real request and follow it from sign-in to the last action. Mark where the retrieval service checks document access, where the model gateway limits model use, and where a target service decides whether to execute an action. Include any delegated work in the same trace so you can see which team owns each decision and which records would help if something goes wrong.

A signed-in user reaches an AI application connected to a model gateway, permission-aware retrieval, an action policy service, and remote agents with separate trust checks.
An example enterprise architecture with separate enforcement points for model usage, document access, tool calls, and agent delegation. View full-size diagram
  • Show which identity is used at each step and which service checks its permissions.
  • Mark where approval, time limits, and logging apply before any action runs.

Further reading

This article draws on Thameem Ansari’s AI Security Study Guide, Complete Edition V1, Section 1.2 (pp. 29–43).