What Is an AI Agent? › A Glimpse Under the Hood
Michael BrenndoerferJune 3, 20251 min read
AI Agent HandbookAll chapters Part 1 of 15Introduction to AI Agents
What Is an AI Agent? › A Glimpse Under the HoodOne section · Sections in this chapter5 / 12 ↓
Sections in this chapter12
What does this look like in code? Here's a simplified preview of an agent's decision-making loop. This is conceptual pseudo-code to illustrate the pattern (we'll build the real implementation step by step in later chapters using the Claude Agent SDK):
In[2]:
Code## Simplified agent loop (conceptual preview - not runnable code)
## In later chapters, we'll implement this using Claude Agent SDK
def agent_loop(user_request):
# 1. Perceive: Understand the request
intent = understand_intent(user_request)
# 2. Reason: Decide what to do
plan = create_plan(intent)
# 3. Act: Execute the plan
for step in plan:
if step.needs_tool:
result = call_tool(step.tool_name, step.parameters)
else:
result = generate_response(step)
# 4. Adapt: Check if we succeeded
if not successful(result):
plan = revise_plan(plan, result)
return final_responseDon't worry about understanding every line. This is just to show that agents follow a structured process of perceiving, reasoning, acting, and adapting. Throughout the book, we'll use the Claude Agent SDK with Claude Sonnet 4.5 or Claude Opus 4.1 to implement agent loops and tool integration, GPT-5 for basic prompting examples, and Gemini 2.5 Flash or Gemini 2.5 Pro when we explore multimodal capabilities.