Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Tool Permissions
Tool permissions control what each agent is allowed to do. Not every agent should have access to every tool. Restricting tool access is one of the most important safety practices in agent design.
Permission Principles
The core principle is least privilege: give each agent only the tools it needs to complete its goal, and nothing more.
A research agent that only reads web pages does not need write access to the database.
A report-generating agent does not need the ability to send emails directly.
A customer support agent should not have access to financial systems unless it is specifically authorised.
Permissions should be:
- Explicit: defined upfront, not inferred
- Minimal: limited to what the task requires
- Audited: every tool call should be logged with the tool name, arguments, and result
- Revocable: permissions can be reduced if misuse is detected
Permission Registry
# Simple tool permission registry
class PermissionRegistry:
def __init__(self):
self.permissions = {} # agent_role -> set of allowed tools
def register(self, role: str, allowed_tools: list):
self.permissions[role] = set(allowed_tools)
def can_use(self, role: str, tool_name: str) -> bool:
return tool_name in self.permissions.get(role, set())
# Setup
registry = PermissionRegistry()
registry.register("research_agent", ["web_search", "read_file", "summarise"])
registry.register("email_agent", ["get_contact", "send_email", "log_sent"])
registry.register("admin_agent", ["web_search", "read_file", "write_file",
"get_contact", "send_email", "delete_record"])
# Check permissions
print(registry.can_use("research_agent", "web_search")) # True
print(registry.can_use("research_agent", "send_email")) # False
print(registry.can_use("admin_agent", "delete_record"))# True