Defining the Agent's Environment › What Is an Environment?
Michael BrenndoerferJuly 13, 20252 min read
AI Agent HandbookAll chapters Part 8 of 15Environment and Interaction - The Agent's World
Defining the Agent's Environment › What Is an Environment?One section · Sections in this chapter2 / 11 ↓
Sections in this chapter11
An environment is the space where an agent operates and interacts. For our personal assistant, this environment is digital: it includes your calendar, your email inbox, the files on your computer, the internet, and most importantly, your requests and instructions.
Let's make this concrete with a simple example. Imagine you ask your assistant: "What's on my calendar today?"
In[3]:
Code## Using Claude Sonnet 4.5 for its superior agent reasoning capabilities
import os
from anthropic import Anthropic
client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
def get_calendar_events():
"""Tool that retrieves today's calendar events"""
# In a real system, this would query your actual calendar
return [
{"time": "9:00 AM", "title": "Team standup"},
{"time": "2:00 PM", "title": "Client presentation"},
{"time": "4:30 PM", "title": "Code review"}
]
## The agent perceives the user's request
user_request = "What's on my calendar today?"
## It decides to use the calendar tool
events = get_calendar_events()
## It formats a response based on what it found
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=200,
messages=[{
"role": "user",
"content": f"Format these calendar events nicely: {events}"
}]
)
print(response.content[0].text)Out[3]:
Console# 📅 Calendar Events **9:00 AM** — Team standup **2:00 PM** — Client presentation **4:30 PM** — Code review
In this interaction, the agent's environment includes:
- The user's input: Your question about the calendar
- The calendar system: The data source it can query
- Its own capabilities: The tools and knowledge it has access to
- The response channel: How it communicates back to you