MAF
Back to Site Start Module 1

Controls: Left/Right, Space, Home/End, O, F

Microsoft Agent Framework Workshop

Build AI Solutions with
Microsoft Agent Framework

Production AI Agents: Theory to Live Deployment

A guided session that explains core concepts and then builds a practical agent end to end — from model connection to live deployment.

Theory Hands-on Labs Python Azure AI
Dileepa Bandara

Dileepa Bandara

Associate AI Engineer

Random Software Ltd

Session Agenda

A structured flow from theory to production deployment.

1. Core Theory

  • What are Agents? — Core definitions and mechanisms
  • What is Microsoft Agent Framework? — SDK architecture & capabilities
  • Core Agent Loop — Cognitive reasoning patterns (Think-Act-Observe)
  • Tool Calling & MCP — Exposing deterministic local/remote functions
  • Memory & Workflows — Persistence layers and graph-based orchestration

2. Practice & Delivery (Build Tracks)

  • Meet OpsAgent — The operations assistant we build together
  • Track A: Foundations (M1-3) — Setup, GitHub Models & Core Agent
  • Track B: Remote Tools (M4-5) — Local Tool Calling & hosted MCP
  • Track C: Complex Pipelines (M6-8) — Sessions, Memory & Workflows
  • Track D: Production (M9-10) — Chat interfaces & Azure Functions
  • Reference Architecture & Pacing — Full system integration & demo pacing

Theory 1

What are Agents?

An agent is an autonomous software component that uses an LLM as its central reasoning engine to perceive its environment, make decisions, call APIs, and iteratively reason toward completing complex goals.

🧠 LLM Core Plan · Reason · Decide
📋 Planning

Decomposes complex goals into ordered, logical steps and iteratively refines strategy

🛠️ Tools

Calls APIs, reads files, runs health checks, and executes Python functions on demand

💾 Memory

Session history for context continuity and long-term persistent data via ContextProvider

👁️ Perception

Observes environment, tool outputs, and external signals to adapt reasoning in real-time

Theory 2

What is Microsoft Agent Framework?

An open-source framework for Python and .NET that helps teams build production-grade AI systems using autonomous agents and explicit workflows.

  • Two Core Capabilities: Use Agents for conversational and tool-driven tasks, or Workflows for deterministic multi-step orchestration.
  • Foundational Building Blocks: Model clients, agent sessions, context providers, middleware, and MCP clients for robust, stateful runtime behavior.
  • Next-Generation Platform: Combines AutoGen's simple abstractions with Semantic Kernel's enterprise features such as type safety, telemetry, and human-in-the-loop support.
🤖 Agents

LLM-driven units that reason, call tools and MCP servers, and produce responses with autonomous planning.

🧭 Workflows

Graph-based execution for type-safe routing, checkpointing, and coordinated multi-agent or function pipelines.

🧱 Core Runtime

Sessions, memory context providers, middleware, and MCP clients provide safe, stateful, extensible foundations.

🚀 Why It Matters

Direct successor to Semantic Kernel + AutoGen with stronger enterprise controls and explicit orchestration patterns.

Theory 3

Core Agent Loop: Think → Act → Observe → Respond

Agents run a continuous execution loop. Each cycle processes inputs, selects actions, captures results, and decides whether to respond or continue reasoning.

1
🧠
Think
Analyze context, reason about next step
2
Act
Call tool, invoke API, or query MCP
3
👁️
Observe
Capture output, evaluate results
4
💬
Respond
Output answer or loop back to Think

Theory 4

Exposing Tools for Actionable AI

Tool calling converts static text generation into deterministic Python execution. Register functions using @tool and the SDK auto-generates JSON schemas for the LLM.

👤
User Query
"Check server health"
🤖
OpsAgent
Sends chat history + tool schemas to LLM
🧠
LLM Decides
Returns tool_call JSON with arguments
🔧
@tool Function
Executes check_health("api-01")
Grounded Answer
Verified, deterministic result returned to user
@tool(approval_mode="never_require")

Theory 5

What is MCP (Model Context Protocol)?

An open standard that decouples agent hosts from tool integrations. Instead of custom bindings, MCP servers publish resources, tools, and prompts over JSON-RPC.

🖥️
Agent Host
OpsAgent + Framework SDK
🔄 JSON-RPC
Protocol
📄 Resources 🔧 Tools 💬 Prompts
⚙️
MCP Server
Microsoft Learn Docs
🗄️
MCP Server
SQLite / Filesystem
MCPStreamableHTTPTool(url="https://learn.microsoft.com/api/mcp")

Theory 6

Memory: Session vs Persistence

Production agents require proper state management. The framework provides dual memory layers for human-like conversational continuity.

Session Memory

  • Chat history within a single run
  • Context window messages cached
  • Uses AgentSession
  • Resets when session ends
Lifetime: Single session
VS
💾

Persistent Memory

  • Knowledge across separate visits
  • User facts & configuration saved
  • Uses ContextProvider hooks
  • SQLite, Cosmos DB, or file stores
Lifetime: Across sessions
💬 User Input New prompt query
➡️
🧠 AgentSession In-memory chat history
➡️
🔌 ContextProvider Fact injector / logic hooks
➡️
🗄️ Persistent DB SQLite / Cosmos DB store

Theory 7

Orchestrating Complex Agent Workflows

For multi-step operational pipelines, workflows structure execution as directed graphs using @executor decorators and WorkflowBuilder.

🔍
Triage Input
Python @executor
Tags severity: CRITICAL / HIGH / INFO
🤖
OpsAgent
LLM Agent
Generates resolution steps
📤
Capture Output
Python @executor
Extracts & yields final result
WorkflowBuilder(start_executor=triage_input, output_from=[capture_output])

Practical Goal

What we are building: OpsAgent

OpsAgent is an AI-powered operations & engineering assistant. It helps developers troubleshoot issues, retrieve documentation via MCP, analyze systems, and automate workflows — all grounded in real data.

🩺

Diagnose

Error codes, service health, log analysis

📚

Retrieve

Microsoft Learn docs via MCP server

🔄

Orchestrate

Multi-step workflow pipelines

💬

Converse

Multi-turn memory & persistent state

Python 3.12GitHub ModelsCustom ToolsMicrosoft Learn MCPWorkflowsAzure Functions

Build Track A

Modules 1–3: Foundations & Core Agent

Establish a modern Python environment, connect to cloud-hosted LLMs, and define your first OpsAgent.

M1
Environment Setup Install uv, configure Python 3.12, install dependencies
M2
GitHub Models Connection Obtain PAT tokens, configure inference endpoints, test OpenAI client
M3
Core OpsAgent Definition Define Agent with instructions, run streaming & non-streaming

Build Track B

Modules 4–5: Grounding with Tools and MCP

Transform OpsAgent from chat-only to a functional operations worker with tool calling and live documentation retrieval.

M4
Tool Calling Define @tool functions: health checks, deployment checklists, error diagnosis
M5
MCP Integration Connect MCPStreamableHTTPTool to Microsoft Learn MCP server

Build Track C

Modules 6–8: Sessions, Memory & Orchestration

Add state management layers for multi-turn chats, persistent memory, and structured workflow graphs.

M6
Multi-Turn Conversations Enable history tracking with InMemoryHistoryProvider
M7
Persistent Memory Database-backed persistence: SQLite / Cosmos DB stores
M8
Workflow Graphs Wire @executor nodes into WorkflowBuilder pipelines

Build Track D

Modules 9–10: Web Interfaces & Production Hosting

Build beautiful frontends and deploy the backend to scalable cloud endpoints.

M9
Chat User Interface Streamlit, Chainlit, and FastAPI chat interfaces with streaming
M10
Host Agent on Azure Deploy as Azure Functions HTTP endpoint with AgentFunctionApp

Reference Architecture

OpsAgent Full System Architecture

The complete architecture connects UI layers, orchestration, the agent SDK, tool integrations, and cloud resources.

Layer 1
UI Layer Chainlit · Streamlit · FastAPI · REST API
Layer 2
Orchestration WorkflowBuilder · Triage · Routing · Pipelines
Layer 3
Agent Framework Core Agent · AgentSession · Memory · ContextProviders
Layer 4
Tools @tool · Health · Deploy · Diagnose
Layer 5
MCP Protocol Microsoft Learn · Remote APIs
Layer 6
LLM & Hosting GitHub Models (GPT-4o-mini) · Azure Functions

Presenter Flow

Suggested live demo pacing (60 min)

Divide time between theory foundations, building blocks, and deployment steps for maximum engagement.

00–10 min
Agent & MCP Theory Overview
10–20 min
Environment & Model Connection
20–30 min
Custom Tools & MCP Search
30–40 min
Memory & Session State
40–50 min
Workflow Graphs & Web UI
50–60 min
Azure Functions Deployment

Question

Before the Microsoft Agent Framework, which (two) Microsoft frameworks were used to build AI agents?

Answer

Common Microsoft approaches

Semantic Kernel and AutoGen.

Question

What's the difference between a session provider and a context (user memory) provider?

Answer

Session vs Context

Session providers (e.g., AgentSession / InMemoryHistoryProvider) store ephemeral chat history for the current interaction. Context (user memory) providers persist facts, preferences and user data across sessions using a database (SQLite, Cosmos DB) and are used to inject long‑term knowledge into the agent's context.

1 / 17 Welcome