Introduction to AI Agents
Introduction to AI Agents
第1章:AI Agent简介
Every morning, millions of people around the world wake up and ask their smartphones questions. "What's the weather today?" "Set an alarm for 7 AM." "Navigate me to work." These interactions feel natural, almost mundane. But beneath this simplicity lies one of the most significant shifts in computing history: the emergence of AI agents—software systems that don't just respond to commands but perceive, decide, and act with increasing independence.
Consider what happens when you ask a modern digital assistant to plan a weekend trip. A decade ago, this request would have returned a list of web links you had to manually explore. Today, an AI agent might check your calendar, scan weather forecasts, browse hotel booking sites, compare prices, reserve accommodations, and add everything to your itinerary—all without you lifting a finger beyond stating your intent. This transformation from passive tool to active collaborator represents something fundamentally new in our relationship with software.
This book is about understanding that transformation at a deep level. We call it *The Art of AI Agents* because building effective agents requires both scientific rigor and creative judgment. It's not enough to know the algorithms; you must understand when and how to apply them, how to design systems that fail gracefully, and how to create agents that truly serve human needs.
The question at the heart of this opening chapter is deceptively simple: What exactly is an AI agent, and why should software developers care? Throughout these pages, we'll build a shared understanding of agent systems that will serve as the foundation for everything that follows. We'll explore where agents came from, what makes them different from traditional software, and why they're poised to reshape how we build and interact with technology. By the end, you'll not only recognize agents when you see them—you'll understand the design principles that make them work.
---
Understanding the Concept of Agency in AI Systems
The word "agency" comes from the Latin *agere*, meaning "to do" or "to act." When we say something has agency, we mean it has the capacity to act independently toward goals. A human has agency. A corporation, in legal terms, has agency. But what does it mean for a software system to have agency?
Before we can answer that question for AI agents, we need to distinguish between several related but distinct concepts that often get conflated.
The Spectrum of Software Autonomy
Software systems exist on a spectrum of autonomy. At one end, we have purely reactive programs that perform predetermined actions in response to predetermined inputs. A basic calculator is purely reactive—it does exactly one thing based on your exact instructions. It has no memory of past calculations, no understanding of your intentions, and no capacity to surprise you.
Moving along the spectrum, we encounter programs with limited state. A web browser remembers your browsing history. A music app learns your listening preferences. These systems adapt to user behavior, but they still wait for explicit commands. They don't take initiative.
Further along, we find systems that exhibit goal-directed behavior. They don't just respond to commands—they work toward objectives you set. When you ask a navigation app to find the fastest route, it evaluates multiple options and selects the best one according to criteria you didn't explicitly program. It's making decisions, not just executing instructions.
At the far end of the spectrum sit true agents—systems with what researchers call "situated agency." They perceive their environment, maintain internal state about the world, and take actions that affect that world. They operate with significant independence, often over extended periods, adapting their behavior based on what they observe.
Most software today falls into the first three categories. True agents remain relatively rare, but that's changing rapidly.
What Makes an AI Agent Different
An AI agent is distinguished by three core capabilities that, together, create something qualitatively different from traditional software:
Perception refers to the agent's ability to gather information about its environment. This can include reading documents, processing sensor data, receiving user input, querying databases, or accessing external APIs. An agent doesn't live in a vacuum—it has windows into the world.
Reasoning is the capacity to process information, draw inferences, and determine appropriate actions. This is where AI techniques like machine learning, planning algorithms, and knowledge representation come into play. The agent doesn't just store data—it thinks about it.
Action means the ability to actually do something in the world: modify files, send messages, call APIs, control physical devices, or generate content. An agent isn't merely a consultant offering advice—it can implement its decisions.
Traditional software might excel at one or two of these capabilities, but agents integrate all three into a coherent whole. This integration is what enables the morning trip-planning scenario we described earlier. The agent perceives your request, reasons about what needs to be done, and takes multiple actions across different services to accomplish your goal.
The Agency Spectrum in Practice
Let me illustrate this spectrum with a concrete example: email management.
A basic spam filter operates purely reactively. It checks incoming messages against rules and moves suspicious ones to a separate folder. It doesn't learn your preferences—it follows predetermined logic.
A smart email assistant with learning capabilities represents the second level. It observes which emails you mark as important and gradually adjusts its filtering accordingly. It has state, but you still manually archive, delete, or respond to emails.
A rules-based automation system exemplifies goal-directed behavior. You can program it to automatically move all emails from your manager to a priority folder and flag those containing the word "urgent." It works toward your objectives without constant supervision, but only within the narrow bounds you've defined.
A true AI email agent would combine all three capabilities: it would read and understand email content, maintain a sophisticated model of your priorities and relationships, decide which emails deserve your attention based on context, and take appropriate actions—drafting responses, scheduling follow-ups, blocking senders, or escalating urgent matters. You might tell it, "Keep me informed about project Phoenix while shielding me from everything else," and it would interpret that intent across thousands of emails, making judgment calls about relevance and importance.
Most email tools today cluster toward the earlier spectrum positions. But the trajectory is clear: software is moving steadily toward greater agency.
Why Agency Matters
Understanding agency matters for several reasons. First, it helps you recognize what's actually novel about AI agents versus what's just marketing hype. Not every system labeled "AI" deserves the term "agent." Second, it clarifies the design challenges unique to agent systems—challenges around trust, safety, and predictability that don't arise with simpler software. Third, it prepares you to think about the right abstractions when building agent systems yourself.
When we design a traditional application, we focus on functions and data. When we design an agent, we must think about perception channels, reasoning strategies, action repertoires, and—most importantly—the complex interplay between them. This shift in perspective is fundamental, and we'll return to it repeatedly throughout this book.
---
Tracing the Evolution from Reactive to Proactive Systems
The AI agents of today didn't appear suddenly. They emerged through decades of incremental progre