← Develop AI Apps and Agents o… Latent Shelf · Ch.13

Module Study Guide · Path 2 · AI agents

Develop an AI Agent with the Microsoft Agent Framework

One Agent base class, any provider — the framework unifies Semantic Kernel and AutoGen behind a single consistent interface.

— the module's foundation

The code-first SDK for agents. This module introduces the Microsoft Agent Framework and its components, the capabilities every agent shares and why Foundry is the recommended provider, and how to add tools with the @tool decorator.

Agent base classprovider flexibility@tool decorator14 quiz questions
01The framework

A unified, composable platform

The Microsoft Agent Framework is the next generation of both Semantic Kernel and AutoGen, combining AutoGen's intuitive agent abstractions with Semantic Kernel's enterprise features. All agents derive from a single Agent base class, giving a consistent interface regardless of the underlying model provider.

Key concept · Seven core components

  • Model clients — one interface to many AI providers; switch by changing config, not agent logic.
  • Agent session — native state management for persistent multi-turn context.
  • Context providers — plug-and-play memory that surfaces relevant info dynamically.
  • Function tools — custom functions auto-registered; the framework generates the schema.
  • MCP clients — built-in dynamic tool discovery at runtime.
  • Middleware — intercept, log, and modify agent actions.
  • Workflow orchestration — graph-based multi-agent patterns (sequential, concurrent, group chat, handoff).
02Capabilities

What every agent can do

Regardless of provider, every framework agent supports function calling, multi-turn conversations, structured (schema-validated) outputs, streaming responses, and provider-dependent service tools (code execution, file/web search).

Key concept · Why Foundry is the recommended provider

The framework integrates with Azure AI Foundry projects — authenticate with Azure credentials, create agents via the Foundry Agent Service, and get service-side chat history that persists sessions automatically across turns. Because it eliminates manual conversation-state management, Foundry Agent Service is the recommended provider for production. Chat-completion providers (e.g. Azure OpenAI Chat, Anthropic, Bedrock) lack service chat history and must manage state locally.

Design benefits: composability (use components alone or combined), provider flexibility (swap inference services without rewriting logic), enterprise-grade session/telemetry/type-safety, and a consistent developer experience with no manual wiring of separate memory/tool/model libraries.

03Adding tools

Give the agent capabilities

Tools let an agent use APIs and services through function calling. Built-in tools (Code Interpreter, File Search, Web Search) need no setup; custom tools are plain functions the agent invokes automatically.

Key concept · The @tool pattern

Decorate a function with @tool (name, description, optional approval mode), describe parameters with Annotated + Pydantic Field, and register it — e.g. ChatAgent(tools=[my_function, ...]). Then don't call it manually: the agent decides which tools to use and when, from the conversation context, and the framework handles orchestration and combining results. Best practices: clear descriptions, type hints, error handling, meaningful returns, and one task per tool.

★Test yourself

Chapter 13 quiz

Fourteen questions on the framework, its components and capabilities, and adding tools. Answer first, then expand Show answer.

Part A · Multiple choice

Q1

The Microsoft Agent Framework is the next generation of which two projects?

  • A LangChain and CrewAI
  • B Semantic Kernel and AutoGen
  • C ADK and LangGraph
  • D Copilot and Power Automate
Show answer

B. It unifies AutoGen's abstractions with Semantic Kernel's enterprise features.

Q2

What gives every agent a consistent interface regardless of model provider?

  • A A single Agent base class
  • B A vector index
  • C A content filter
  • D A REST endpoint
Show answer

A. All agents derive from one Agent base class.

Q3

Which component lets you switch AI providers by changing only configuration?

  • A Model clients
  • B Middleware
  • C Context providers
  • D Function tools
Show answer

A — Model clients. A unified interface across providers.

Q4

Why is Foundry Agent Service the recommended production provider?

  • A It's the cheapest
  • B It provides service-side chat history that persists sessions automatically
  • C It's the only one with tools
  • D It requires no auth
Show answer

B. Eliminating manual state management. Chat-completion providers lack this.

Q5

How do you define a custom tool in the framework?

  • A Decorate a function with @tool and register it with the agent
  • B Add it to a vector store
  • C Fine-tune the model
  • D Edit a YAML file only
Show answer

A. With Annotated/Field parameter descriptions; the agent invokes it automatically.

Q6

Which is a built-in tool that needs no setup?

  • A Code Interpreter
  • B A custom CRM function
  • C An OpenAPI spec
  • D A Logic App
Show answer

A — Code Interpreter. Along with File Search and Web Search.

Part B · True or false

Q7

You must manually call custom tools in your code.

Show answer

False. The agent decides which tools to use and when, based on context.

Q8

Switching inference providers requires rewriting your agent logic.

Show answer

False. Provider flexibility means only client config changes.

Q9

Every framework agent supports streaming responses and structured outputs.

Show answer

True. Plus function calling, multi-turn conversations, and (provider-dependent) service tools.

Q10

Clear tool descriptions and type hints help the agent call functions correctly.

Show answer

True. Without metadata the AI can't invoke functions properly.

Part C · Short answer

Q11

Name four of the seven core components of the framework.

Show answer

Any four: model clients, agent session, context providers, function tools, MCP clients, middleware, and workflow orchestration.

Q12

Name three capabilities every framework agent supports.

Show answer

Any three: function calling, multi-turn conversations, structured outputs, streaming responses, and service-provided tools.

Q13

What key advantage does Foundry Agent Service provide over chat-completion providers?

Show answer

Service-side chat history — automatic session persistence, no manual state management.

Q14

Give two best practices for defining custom tools.

Show answer

Any two: clear descriptions, type hints, error handling, meaningful returns, and one task per focused function.