Understanding AI Agents: What They Are and How to Pick the Right Framework
An AI Agent combines a large language model, tools, and memory to turn natural language requests into actions, with three core components—environment, sensor, actuator—seven agent types, usage criteria, and guidance on selecting between Microsoft Agent Framework and Azure AI Agent Service, plus runnable demos.
What Is an AI Agent?
Microsoft defines an Agent as a system that enables a large language model (LLM) to "take action". In simple terms, Agent = AI brain + tools + memory.
Agent is a system that lets LLMs "do work".
Unlike ordinary AI chat that only replies, an Agent can call tools, query databases, send emails, run code—turning "saying" into "doing".
Analogy: ordering food – a regular AI just recommends a restaurant, while an Agent actually places the order.
Three Core Components
Environment : the space where the Agent operates (e.g., ticket‑booking platforms such as Ctrip or Fliggy).
Sensor : the Agent's ability to "see" the environment (e.g., checking flights, comparing prices, estimating on‑time rates).
Actuator : the Agent's ability to "act" (e.g., placing orders, making payments, sending confirmation messages).
All three are required; missing any makes the Agent ineffective.
Seven Agent Types
1. Simple Reflex Agent
Pure rule‑driven, no memory, no learning. Example: "When a complaint email arrives, forward it to customer service" – identical behavior each time.
2. Model‑Based Reflex Agent
Remembers past data and can detect trends. Example: noticing a flight route’s price frequently rises.
3. Goal‑Based Agent
Has a goal and plans steps. Example: user says "I want to go to Sanya", the Agent searches flights, books hotels, arranges transfers.
4. Utility‑Based Agent
Optimizes for the best outcome, weighing trade‑offs such as price versus travel time.
5. Learning Agent
Learns from feedback. Example: after the user says "I don’t want a 10 pm flight next time", the Agent avoids that time in future suggestions.
6. Hierarchical Agent
A large Agent delegates subtasks to smaller specialized Agents. Example: cancelling a trip is broken into cancelling flight, hotel, and car rental.
7. Multi‑Agent System
Multiple Agents cooperate or compete. Cooperation: hotel‑booking, flight‑booking, and ticket‑booking Agents jointly plan an itinerary. Competition: several Agents bid to find the cheapest hotel.
When Should You Use an Agent?
Problem cannot be solved by a fixed workflow (e.g., planning a non‑standard business trip).
Task requires multiple steps across different systems (e.g., gathering weekly development progress from Jira, computing metrics, generating a report, and emailing it).
System needs continuous learning and improvement (e.g., a customer‑service Agent that refines answers based on user feedback).
Choosing a Framework
Microsoft recommends two paths:
Microsoft Agent Framework (MAF) – a Python SDK for quickly writing Agents.
Azure AI Agent Service – a managed platform that runs Agents in Azure.
Microsoft Agent Framework (MAF)
Key features:
Define tools as Python functions.
Support collaboration among multiple Agents.
Built‑in Azure identity authentication.
Ideal for rapid prototyping.
Example code (simplified):
import asyncio
from agent_framework.azure import AzureAIProjectAgentProvider
from azure.identity import AzureCliCredential
# Define a tool function
def book_flight(date: str, location: str) -> str:
"""Book a flight"""
return f"已为您预订 {date} 去 {location} 的机票"
async def main():
provider = AzureAIProjectAgentProvider(credential=AzureCliCredential())
agent = await provider.create_agent(
name="travel_agent",
instructions="帮用户订机票,准备好就调用 book_flight 工具",
tools=[book_flight],
)
response = await agent.run("我想预订 2025 年 1 月 1 日去纽约的机票")
print(response)
asyncio.run(main())The three essential steps are:
Define the tool function ( book_flight).
Create the Agent with a name, instructions, and the tool list.
Invoke the Agent.
Azure AI Agent Service
Key features:
Supports many models (OpenAI, Llama, Mistral, etc.).
Built‑in Azure AI Search, Bing Search, and code execution.
Enterprise‑grade security and permission management.
Suitable for production and Azure‑integrated scenarios.
MAF tells you "how to write an Agent"; Azure AI Agent Service tells you "where to run it".
Which One to Pick?
If you are a beginner and want a quick start, choose MAF.
If you need enterprise deployment and Azure integration, choose Azure AI Agent Service.
Often you start with MAF for prototyping and later migrate to the Service.
Minimal Working Demo
A runnable restaurant‑assistant demo using Azure AI Agent Service:
import asyncio
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
def get_specials() -> str:
"""Today's specials"""
return """
特色汤:蛤蜊浓汤
特色沙拉:科布沙拉
特色饮品:印度奶茶
"""
def get_item_price(menu_item: str) -> str:
"""Query price of a menu item"""
return "$9.99"
async def main():
credential = DefaultAzureCredential()
project_client = AIProjectClient.from_connection_string(
credential=credential,
conn_str="你的连接字符串",
)
# Create Agent
agent = project_client.agents.create_agent(
model="gpt-4o-mini",
name="餐厅助手",
instructions="回答关于菜单的问题",
tools=[get_specials, get_item_price],
)
# Create conversation thread
thread = project_client.agents.create_thread()
for user_input in ["你好", "今日特色汤是什么?", "价格多少?", "谢谢"]:
print(f"用户:{user_input}")
project_client.agents.create_message(
thread_id=thread.id,
role="user",
content=user_input,
)
# Run Agent
project_client.agents.create_and_process_run(
thread_id=thread.id,
agent_id=agent.id,
)
# Retrieve response
messages = project_client.agents.list_messages(thread_id=thread.id)
print(f"Agent:{messages.data[0].content[0].text.value}")
asyncio.run(main())Sample interaction:
用户:你好
Agent:您好!有什么可以帮您的?
用户:今日特色汤是什么?
Agent:今日的特色汤是蛤蜊浓汤。
用户:价格多少?
Agent:这款汤的价格是 $9.99。
用户:谢谢
Agent:不客气!欢迎下次光临。The demo shows the core ability: understand natural‑language instructions, invoke tools, and return results.
Practical Scenarios for Non‑Developers
Work:
Summarize weekly project reports and email them.
Gather competitor news and draft an analysis.
Life:
Compare prices across shopping carts and pick the cheapest.
Plan a business trip by checking flights, booking hotels, and arranging transport.
Learning:
Translate an English paper, extract key points, and generate a summary.
Create a personalized Rust learning path based on current skill level.
Key idea: you state a natural‑language request, the Agent executes it.
Boundaries – When Not to Use an Agent
Standardized, fixed‑process tasks (e.g., generate a monthly sales Excel file) – a script is more reliable.
High‑risk operations where a mistake is costly (e.g., deleting the last line of a file).
Ill‑defined requests without clear requirements.
Microsoft’s practical advice: "If a tool can do it, don’t use an Agent." Flexibility comes with complexity and uncertainty; try simpler solutions first.
Summary
Agent is a system that turns AI "talk" into "action".
Three components: environment, sensor, actuator.
Seven agent types each with distinct strengths.
Use Agents for open‑ended problems, multi‑step workflows, and continuously learning systems.
Choose MAF for learning and prototyping; choose Azure AI Agent Service for production and Azure integration.
A runnable demo demonstrates a restaurant‑assistant Agent.
Agents excel in work, life, and learning scenarios but are unsuitable for fixed processes, high‑risk tasks, or vague requirements.
Related Resources
Microsoft AI Agent tutorial GitHub repository: https://github.com/microsoft/ai-agents-for-beginners
Azure AI Agent Service documentation: https://aka.ms/ai-agents-beginners/ai-agent-service
Microsoft Agent Framework documentation: https://learn.microsoft.com/azure/ai-services/openai/how-to/responses
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
