Recommended resources
The freely available resources this lesson will direct you to.
Introduction
In our last lesson, we explored how to select the right cognitive architecture—like Reactive or Plan-and-Execute—for an agent, based on its "job description." This decision dictates how the agent thinks. Now, we must address a critical follow-up question: what is the agent allowed to do?
Continuing with our 'agent-as-employee' mental model, once you've hired an employee and defined their role, you don't give them the keys to the entire building. You grant them access only to the specific rooms, tools, and information necessary to perform their job. This is the essence of the Principle of Least Authority (PoLA), a cornerstone of computer security.
This lesson's learning outcome is to explain the principle of least authority as applied to agent tool access and decision boundaries. Given your background in computer science, you are already familiar with this principle in traditional systems. Our focus will be on its unique and critical application to agentic AI, where the system's core component—the LLM—is probabilistic and not fully predictable. We will examine how to enforce these boundaries at the level of system architecture, tool access, and even the agent's internal capabilities.
1. The Architectural Foundation for Least Authority
A common mistake when building agentic systems is to rely on prompt instructions to enforce security. Asking an agent, "Please do not access sensitive customer data," is like building a bank vault out of tissue paper. The inherent unreliability of LLMs, coupled with vulnerabilities like prompt injection, means that true security must be architectural. The system must be designed so that violations are impossible, not just discouraged.

A direct consequence of this philosophy is the need to avoid a common architectural anti-pattern: treating the agent runtime as your entire backend. When the user's browser communicates directly with a single, monolithic agent that handles everything from user authentication to business logic and tool use, you create a system with no internal boundaries to enforce.
To understand this problem and its solution, the following video provides an excellent architectural overview.
We Need to Talk About AI Agent Architectures
The video 'We Need to Talk About AI Agent Architectures' from AWS Developers begins by highlighting the security and reliability risks of a simplistic agent architecture. It then proposes a more robust, multi-layered approach.
Please watch the first two segments: The Anti-Pattern (00:00 - 01:43): Pay attention to why having the agent runtime act as the entire backend is problematic for production systems. Separation of Concerns (09:25 - 10:49): This section outlines the general guidelines for what logic belongs upstream of the agent versus within the agent itself. This is the foundation for creating architectural boundaries.
The solution, as the video suggests, is to treat the agent as a specialized capability within a larger, well-designed system. By placing components like an API Gateway, firewalls, and a dedicated backend service (e.g., an AWS Lambda function) between the user and the agent, you create distinct layers where you can enforce policies.
This architectural separation allows for a powerful implementation of PoLA. For instance, you can use one authentication mechanism for the user-facing API (e.g., OAuth) and a completely different, more restrictive mechanism for the internal service that invokes the agent (e.g., IAM roles). This ensures a user's token can't be used to bypass your security layers and call the agent directly.
The next segment of the same video provides a detailed, practical walkthrough of building exactly this type of architecture.
We Need to Talk About AI Agent Architectures
Now, let's dive into the implementation details. This extended segment demonstrates how to evolve from a vulnerable architecture to one that properly enforces security boundaries.
Watch the segment from 11:03 to 22:55. This is a longer clip, but it provides a concrete, code-level demonstration that will be valuable. Focus on the security problem identified at 17:11: The issue of using the same token for both the API Gateway and the agent runtime, which allows a user to bypass the gateway. Analyze the solution: The introduction of a thin Lambda function to act as an intermediary, enabling different authentication mechanisms for different layers. This is a textbook example of enforcing least authority through architecture.
2. Enforcing PoLA for Tool Access
With a secure architecture in place, we can now focus on the agent's "job permissions": its access to tools. Giving an agent raw API keys or long-lived credentials grants it excessive and dangerous authority. The goal is to provide the agent with the minimum permissions necessary for the specific task at hand, for the minimum time required.
A rigorous approach to this problem moves beyond manual permission setting and into formal, automated systems. The research paper "A Least Privilege Framework for Authorizing Tool Calling Agents" introduces such a system.
[PDF] A Least Privilege Framework for Authorizing Tool Calling Agents
This paper, which presents a framework called MiniScope, formalizes the challenge of securing tool-calling agents. It argues that enforcement must be mechanical and rigorous, rather than relying on LLM interpretation or simple user confirmations.
First, read Section 1 (Introduction) to understand the fundamental security challenge. Then, skim Section 6.2 (Comparison against LLM-inferred Permission). The key insight here is that LLMs, when asked to determine the required permissions for a task, consistently grant overprivileged access. This underscores why PoLA cannot be delegated to the agent itself.
The paper's core contribution is the concept of a permission hierarchy. By analyzing the APIs a tool exposes (often through existing structures like OAuth scopes), we can build a formal graph of permissions, from the most restrictive (e.g., read-only) to the most permissive (e.g., read-write-delete). Given a plan of action from an agent, an external solver can then compute the optimal, least-privileged set of permissions required to execute that plan.
[PDF] A Least Privilege Framework for Authorizing Tool Calling Agents
Let's look closer at the concept of permission hierarchies. This formal, graph-based representation of authority is a powerful mental model that should resonate with your computer science background.
Please read Section 3.2 (Permission Hierarchy). Pay close attention to Figure 3, which shows the reconstructed hierarchy for Google Calendar. Notice how the hierarchy is derived from functional inclusion (which scope's methods are a subset of another's) rather than just the naming convention.
While the MiniScope paper provides the theory, how does this look in practice? The following video demonstrates a robust architectural pattern that isolates the agent from credentials, effectively implementing the principle.
How to secure your AI Agents: A Technical Deep-dive
This technical deep-dive from Google for Developers presents a secure pattern for agent tool use that aligns with the principles we've been discussing.
Watch the segments from 12:43 to 15:59. Focus on the flow: The agent decides to use a tool and passes a session ID, not a credential. The tool itself requests an access token from an identity provider. The agent and the end-user are completely isolated from the actual authentication token. This pattern enforces least authority by ensuring the agent never possesses the power to act outside the context of the specific tool call.
Another powerful architectural pattern for enforcing PoLA is the separation of planning from execution into distinct, quarantined agents.
3. Enforcing PoLA for Decision Boundaries
So far, we've focused on an agent's external authority (tool use). But what about its internal authority—its decision-making process? This is a more subtle and complex frontier. While prompt-based constraints are a part of the solution (which we'll cover in Module 4), a more fundamental approach involves controlling the agent's core computational capabilities at inference time.
The paper "No More, No Less: Least-Privilege Language Models" explores this very idea, proposing a new paradigm for deploying LLMs.
[PDF] No More, No Less: Least-Privilege Language Models - arXiv
This paper takes the principle of least privilege to a deeper level. It argues that for true safety and control, we need to be able to dynamically adjust the model's internal 'reasoning power' based on the task at hand.
Please read the Introduction and Sections 3.1 and 3.2. Focus on these key concepts: The critique of existing methods (output filtering, etc.) that leave the model's underlying dangerous capabilities intact. The definition of privilege as reachable internal computation. The proposed monitor-allocator-enforcer decomposition for deployment-time control.
This research points towards a future where PoLA isn't just about external permissions, but about intrinsic capability. The idea is that for a simple task, you wouldn't deploy the full computational power of a massive model. Instead, the system would allocate just enough "privilege" (e.g., by restricting the effective rank of weight matrices or limiting accessible activation paths) for the model to complete the task successfully, and no more.
This approach offers several advantages:
- Reduced Attack Surface: Suppressed capabilities cannot be exploited by adversarial prompts.
- Efficiency: Using less computational power can lead to lower latency and cost.
- Differential Access: The system can grant a trusted user (e.g., a domain expert) higher privilege to unlock more advanced capabilities for the same query that a regular user would be denied.
While implementing such systems is still an active area of research, understanding this concept is crucial for designing next-generation agentic systems where decision boundaries are not just suggested but are deeply embedded in the model's operational mode.
Conclusion
In this lesson, we have translated the classical computer security principle of least authority into the modern context of agentic AI. You have learned that securing an agent is not a matter of asking nicely; it's a matter of rigorous, multi-layered architectural design.
Key Takeaways:
- Enforce PoLA Through Architecture: Security must be built into the system's design with distinct layers and boundaries, rather than relying on fallible prompt instructions.
- Isolate Agents from Credentials: For tool access, agents should act as initiators, not credential-bearers. The authority to act should be brokered by the surrounding architecture and validated by the tools themselves.
- Formalize and Automate Permissioning: Concepts like permission hierarchies allow for the automated, provably minimal granting of permissions for a given task, moving beyond error-prone manual configuration.
- Control Decision Boundaries at the Core: Advanced application of PoLA involves controlling the agent's internal reasoning capabilities, dynamically allocating just enough computational "privilege" for the task at hand.
Preview of the Next Lesson
We have now defined an agent's "job" (Module 2, Lesson 2), its cognitive architecture (M2, L3), and its operational authority (this lesson). With these foundational pieces in place, we are ready to move to Module 3: Designing Agent Information Environments. In the next lesson, we will begin by learning how to audit a business process to identify all the inputs, context, and knowledge an agent needs to perform its job effectively—the "briefing packet" for our newly-hired, properly-scoped agent.