AI Agent Examples in Microsoft's AI Agents for Beginners: A Complete Guide

The Microsoft AI Agents for Beginners repository contains 14+ complete, runnable AI agent examples ranging from simple travel assistants to production-grade multi-agent workflows.

Whether you're building your first LLM-powered agent or scaling to complex orchestration patterns, this open-source course provides hands-on implementations using the Microsoft Agent Framework (MAF). Each lesson ships with Jupyter notebooks and Python scripts you can execute immediately against any OpenAI-compatible endpoint.

What AI Agent Examples Are Included

The repository organizes examples into progressive lessons. Here's every major example with its core concept and source location:

Lesson AI Agent Example Primary Source File
01 – Intro to AI agents Travel Agent – fetches destination ideas via tool calls 01-intro-to-ai-agents/code_samples/01-python-agent-framework.ipynb
04 – Tool use Calculator Agent – exposes Python functions as LLM-callable tools 04-tool-use/code_samples/04-python-agent-framework.ipynb
05 – Agentic RAG Search-Augmented Agent – retrieves documents via Azure AI Search 05-agentic-rag/code_samples/05-python-agent-framework.ipynb
07 – Planning & design Itinerary Planner – builds multi-step plans with WorkflowBuilder 07-planning-design/code_samples/07-python-agent-framework.ipynb
08 – Multi-agent workflows Hotel Booking Workflow – conditional and parallel agent orchestration 08-multi-agent/code_samples/workflows-agent-framework/python/01.python-agent-framework-workflow-ghmodel-basic.ipynb
13 – Agent memory Persistent Context Agent – stores conversation history across turns 13-agent-memory/13-agent-memory.ipynb
14 – Advanced MAF features Conditional Router Agent – routes based on tool results with custom executors 14-microsoft-agent-framework/code-samples/hotel_booking_workflow_sample.py
10 – Production-ready agents Expense Claim Agent – deployable with observability and logging 10-ai-agents-production/code_samples/10-expense_claim-demo.ipynb

Every example can be opened directly on GitHub or executed interactively in Jupyter.

Core AI Agent Patterns Demonstrated

The examples implement four fundamental patterns you'll reuse across projects.

1. Tool-Equipped Agents with @ai_function

The simplest AI agent examples wrap Python functions as LLM-callable tools. From hotel_booking_workflow_sample.py in lesson 14:

from agent_framework import ai_function
import json

@ai_function(description="Check hotel room availability for a destination city")
def hotel_booking(destination: str) -> str:
    # Simulated availability check

    has_rooms = destination.lower() in ["stockholm", "seattle", "tokyo"]
    return json.dumps({
        "has_availability": has_rooms,
        "destination": destination
    })

The @ai_function decorator registers the function's signature and description with the agent framework, enabling the LLM to decide when to invoke it.

2. Conditional Workflow Orchestration

Advanced AI agent examples use WorkflowBuilder to route between nodes based on tool outputs. From the same hotel booking source file:

from agent_framework import WorkflowBuilder, executor

builder = WorkflowBuilder()
builder.add_tool(hotel_booking)

# Define nodes

builder.add_node("check_availability", tool=hotel_booking)
builder.add_node("display_booking", executor="display_result")
builder.add_node("suggest_alternative", executor="alternative_suggestion")

# Conditional routing based on tool output

builder.add_edge(
    "check_availability",
    "display_booking",
    condition=has_availability_condition
)
builder.add_edge(
    "check_availability",
    "suggest_alternative",
    condition=no_availability_condition
)

This pattern separates business logic from control flow, making complex AI agents maintainable.

3. Simple Agent Execution (Travel Agent Example)

The entry-level AI agent example in lesson 01 demonstrates direct LLM interaction:

from agent_framework import AgentExecutor, OpenAIChatClient
from agent_framework.types import ChatMessage, Role
import os

client = OpenAIChatClient(api_key=os.getenv("OPENAI_API_KEY"))
executor = AgentExecutor(client)

@executor
def recommend_destination(user_prompt: str) -> str:
    response = client.chat([
        ChatMessage(role=Role.USER, content=user_prompt)
    ])
    return response.choices[0].message.content

This minimal pattern works for single-turn assistants before adding tools or memory.

4. Persistent Memory Across Conversations

The AI agent memory example in lesson 13 shows how to maintain context:

from agent_framework import AgentExecutor
from agent_framework.memory import MemoryStore, SimpleMemory

# Initialize memory store

store = SimpleMemory()
memory = MemoryStore(store)

# Create executor with persistent memory

executor = AgentExecutor(client, memory=memory)

# Each assistant message automatically appends to store

# Previous turns available in subsequent calls

This enables multi-turn dialogues where the agent recalls earlier user preferences.

Where to Start with These AI Agent Examples

Navigate the examples based on your current skill level:

Your Goal Best Starting Example File Path
First AI agent ever Travel Agent (Lesson 01) 01-intro-to-ai-agents/code_samples/01-python-agent-framework.ipynb
Add external APIs/tools Calculator Tool Agent (Lesson 04) 04-tool-use/code_samples/04-python-agent-framework.ipynb
Connect knowledge bases RAG Search Agent (Lesson 05) 05-agentic-rag/code_samples/05-python-agent-framework.ipynb
Build multi-step workflows Itinerary Planner (Lesson 07) 07-planning-design/code_samples/07-python-agent-framework.ipynb
Orchestrate multiple agents Hotel Booking Workflow (Lesson 08) 08-multi-agent/code_samples/workflows-agent-framework/python/01.python-agent-framework-workflow-ghmodel-basic.ipynb
Deploy to production Expense Claim Agent (Lesson 10) 10-ai-agents-production/code_samples/10-expense_claim-demo.ipynb

Open any notebook in GitHub Codespaces, Jupyter, or Google Colab to run immediately.

Summary

The AI Agents for Beginners repository delivers 14 complete, runnable AI agent examples organized as a progressive course:

  • Entry-level examples (Lessons 01–04) demonstrate single-turn agents, tool calling, and basic function registration with @ai_function
  • Intermediate examples (Lessons 05–08) cover RAG, planning workflows with WorkflowBuilder, and multi-agent orchestration
  • Advanced examples (Lessons 10, 13–14) include production deployment patterns, persistent memory with MemoryStore, and conditional routing based on tool outputs

Every example ships as a Jupyter notebook or Python script in the code_samples/ folder of its respective lesson, ready to execute against any OpenAI-compatible endpoint.

Frequently Asked Questions

What programming language are the AI agent examples written in?

All examples are implemented in Python using Jupyter notebooks (.ipynb) and standalone Python scripts (.py). The Microsoft Agent Framework provides a Python-first API with decorators like @ai_function and classes like WorkflowBuilder and AgentExecutor.

Do I need Azure to run these AI agent examples?

No. While the examples reference Azure AI Foundry and use Azure OpenAI model names by default, you can configure any OpenAI-compatible endpoint. The OpenAIChatClient accepts standard API keys and base URLs, so OpenAI, Groq, or local models via Ollama work with minimal configuration changes.

Which AI agent example should I run first?

Start with the Travel Agent in Lesson 01 (01-intro-to-ai-agents/code_samples/01-python-agent-framework.ipynb). It demonstrates the simplest pattern: an AgentExecutor wrapping an OpenAIChatClient with no tools or memory. Once you understand this foundation, proceed to Lesson 04 for tool use and Lesson 07 for workflow orchestration.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →