Defining the Agent's Environment › Environment Boundaries
AI Agent HandbookAll chapters Defining the Agent's Environment › Environment BoundariesOne section · Sections in this chapter6 / 11 ↓
One of the most important design decisions is setting boundaries for your agent's environment. What should it have access to? What should be off-limits?
Consider these questions:
Access Scope: Should your assistant read all your emails or only work-related ones? Should it access all files on your computer or just a specific folder?
Action Permissions: Should it be able to send emails on your behalf automatically, or should it always ask for confirmation first? Can it delete files, or only read them?
External Reach: Can it make purchases online? Can it post to social media? Can it access the internet freely, or only specific approved websites?
These boundaries aren't just technical constraints. They're about safety, privacy, and trust. A well-designed environment gives the agent enough capability to be useful while preventing it from causing harm or violating your preferences.
Let's see how we might implement basic boundaries:
## Using Claude Sonnet 4.5 for its superior agent reasoning capabilities
class BoundedEnvironment:
"""An environment with explicit boundaries and permissions"""
def __init__(self, allowed_folders=None, require_confirmation=None):
self.allowed_folders = allowed_folders or ["/documents/work"]
self.require_confirmation = require_confirmation or ["send_email", "delete_file"]
self.pending_actions = []
def can_access_file(self, file_path):
"""Check if agent can access this file"""
return any(file_path.startswith(folder)
for folder in self.allowed_folders)
def request_action(self, action_name, **params):
"""Agent requests to take an action"""
if action_name in self.require_confirmation:
# Queue for user approval
self.pending_actions.append({
"action": action_name,
"params": params,
"status": "pending"
})
return "Action queued for confirmation"
else:
# Execute immediately
return self.execute_action(action_name, **params)
def execute_action(self, action_name, **params):
"""Actually perform the action"""
# Implementation would go here
return f"Executed: {action_name}"
## Create a bounded environment
env = BoundedEnvironment(
allowed_folders=["/documents/work", "/documents/personal"],
require_confirmation=["send_email", "delete_file", "make_purchase"]
)
## Agent tries to send an email
result = env.request_action("send_email",
to="colleague@company.com",
subject="Meeting notes")
print(result) # "Action queued for confirmation"Action queued for confirmation
By setting clear boundaries, we create an environment where the agent can be both capable and safe.