ai-agents-for-beginners

Exploring AI Agent Frameworks

(Click the image above to view video of this lesson)

Explore AI Agent Frameworks

AI agent frameworks are software platforms designed to simplify the creation, deployment, and management of AI agents. These frameworks provide developers with pre-built components, abstractions, and tools that streamline the development of complex AI systems.

These frameworks help developers focus on the unique aspects of their applications by providing standardized approaches to common challenges in AI agent development. They enhance scalability, accessibility, and efficiency in building AI systems.

Introduction

This lesson will cover:

Learning goals

The goals of this lesson are to help you understand:

What are AI Agent Frameworks and what do they enable developers to do?

Traditional AI Frameworks can help you integrate AI into your apps and make these apps better in the following ways:

That all sounds great right, so why do we need the AI Agent Framework?

AI Agent frameworks represent something more than just AI frameworks. They are designed to enable the creation of intelligent agents that can interact with users, other agents, and the environment to achieve specific goals. These agents can exhibit autonomous behavior, make decisions, and adapt to changing conditions. Let’s look at some key capabilities enabled by AI Agent Frameworks:

So in summary, agents allow you to do more, to take automation to the next level, to create more intelligent systems that can adapt and learn from their environment.

How to quickly prototype, iterate, and improve the agent’s capabilities?

This is a fast-moving landscape, but there are some things that are common across most AI Agent Frameworks that can help you quickly prototype and iterate namely module components, collaborative tools, and real-time learning. Let’s dive into these:

Use Modular Components

SDKs like the Microsoft Agent Framework offer pre-built components such as AI connectors, tool definitions, and agent management.

How teams can use these: Teams can quickly assemble these components to create a functional prototype without starting from scratch, allowing for rapid experimentation and iteration.

How it works in practice: You can use a pre-built parser to extract information from user input, a memory module to store and retrieve data, and a prompt generator to interact with users, all without having to build these components from scratch.

Example code. Let’s look at an example of how you can use the Microsoft Agent Framework with FoundryChatClient to have the model respond to user input with tool calling:

# Microsoft Agent Framework Python Example

import asyncio
import os

from agent_framework import tool
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential


# Define a sample tool function to book travel
@tool(approval_mode="never_require")
def book_flight(date: str, location: str) -> str:
    """Book travel given location and date."""
    return f"Travel was booked to {location} on {date}"


async def main():
    provider = FoundryChatClient(
        project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
        model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
        credential=AzureCliCredential(),
    )
    agent = provider.as_agent(
        name="travel_agent",
        instructions="Help the user book travel. Use the book_flight tool when ready.",
        tools=[book_flight],
    )

    response = await agent.run("I'd like to go to New York on January 1, 2025")
    print(response)
    # Example output: Your flight to New York on January 1, 2025, has been successfully booked. Safe travels! ✈️🗽


if __name__ == "__main__":
    asyncio.run(main())

What you can see from this example is how you can leverage a pre-built parser to extract key information from user input, such as the origin, destination, and date of a flight booking request. This modular approach allows you to focus on the high-level logic.

Leverage Collaborative Tools

Frameworks like the Microsoft Agent Framework facilitate the creation of multiple agents that can work together.

How teams can use these: Teams can design agents with specific roles and tasks, enabling them to test and refine collaborative workflows and improve overall system efficiency.

How it works in practice: You can create a team of agents where each agent has a specialized function, such as data retrieval, analysis, or decision-making. These agents can communicate and share information to achieve a common goal, such as answering a user query or completing a task.

Example code (Microsoft Agent Framework):

# Creating multiple agents that work together using the Microsoft Agent Framework

import os
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential

provider = FoundryChatClient(
    project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
    model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
    credential=AzureCliCredential(),
)

# Data Retrieval Agent
agent_retrieve = provider.as_agent(
    name="dataretrieval",
    instructions="Retrieve relevant data using available tools.",
    tools=[retrieve_tool],
)

# Data Analysis Agent
agent_analyze = provider.as_agent(
    name="dataanalysis",
    instructions="Analyze the retrieved data and provide insights.",
    tools=[analyze_tool],
)

# Run agents in sequence on a task
retrieval_result = await agent_retrieve.run("Retrieve sales data for Q4")
analysis_result = await agent_analyze.run(f"Analyze this data: {retrieval_result}")
print(analysis_result)

What you see in the previous code is how you can create a task that involves multiple agents working together to analyze data. Each agent performs a specific function, and the task is executed by coordinating the agents to achieve the desired outcome. By creating dedicated agents with specialized roles, you can improve task efficiency and performance.

Learn in Real-Time

Advanced frameworks provide capabilities for real-time context understanding and adaptation.

How teams can use these: Teams can implement feedback loops where agents learn from interactions and adjust their behavior dynamically, leading to continuous improvement and refinement of capabilities.

How it works in practice: Agents can analyze user feedback, environmental data, and task outcomes to update their knowledge base, adjust decision-making algorithms, and improve performance over time. This iterative learning process enables agents to adapt to changing conditions and user preferences, enhancing overall system effectiveness.

What are the differences between the Microsoft Agent Framework and Microsoft Foundry Agent Service?

There are many ways to compare these approaches, but let’s look at some key differences in terms of their design, capabilities, and target use cases:

Microsoft Agent Framework (MAF)

The Microsoft Agent Framework provides a streamlined SDK for building AI agents using FoundryChatClient. It enables developers to create agents that leverage Azure OpenAI models with built-in tool calling, conversation management, and enterprise-grade security through Azure identity.

Use Cases: Building production-ready AI agents with tool use, multi-step workflows, and enterprise integration scenarios.

Here are some important core concepts of the Microsoft Agent Framework:

Microsoft Foundry Agent Service

Microsoft Foundry Agent Service (formerly Azure AI Agent Service) is a managed platform for building, deploying, and scaling agents. It supports prompt agents, voice-based prompt agents, and hosted agents, with supported models and tools from Microsoft Foundry.

Foundry provides identity, scaling, and observability. Your choice of agent type determines whether Foundry manages orchestration or runs your own agent code.

This course uses Microsoft Agent Framework with Foundry Agent Service V2. Deploy your framework code as a hosted agent when you want Foundry-managed hosting.

Preview status depends on the capability. The Microsoft Copilot harness (preview) is an optional runtime, not the status of the whole service.

The SDK snippets and thread/run concepts below illustrate the older Agent Service API, not the course’s V2 Responses API stack. Use the linked current prompt-agent documentation for that model. The older example creates an agent with a user-defined tool:

import asyncio
from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

# Define tool functions
def get_specials() -> str:
    """Provides a list of specials from the menu."""
    return """
    Special Soup: Clam Chowder
    Special Salad: Cobb Salad
    Special Drink: Chai Tea
    """

def get_item_price(menu_item: str) -> str:
    """Provides the price of the requested menu item."""
    return "$9.99"


async def main() -> None:
    credential = DefaultAzureCredential()
    project_client = AIProjectClient.from_connection_string(
        credential=credential,
        conn_str="your-connection-string",
    )

    agent = project_client.agents.create_agent(
        model="gpt-5-mini",
        name="Host",
        instructions="Answer questions about the menu.",
        tools=[get_specials, get_item_price],
    )

    thread = project_client.agents.create_thread()

    user_inputs = [
        "Hello",
        "What is the special soup?",
        "How much does that cost?",
        "Thank you",
    ]

    for user_input in user_inputs:
        print(f"# User: '{user_input}'")
        message = project_client.agents.create_message(
            thread_id=thread.id,
            role="user",
            content=user_input,
        )
        run = project_client.agents.create_and_process_run(
            thread_id=thread.id, agent_id=agent.id
        )
        messages = project_client.agents.list_messages(thread_id=thread.id)
        print(f"# Agent: {messages.data[0].content[0].text.value}")


if __name__ == "__main__":
    asyncio.run(main())

Core concepts

Microsoft Foundry Agent Service has the following core concepts:

Use Cases: Microsoft Foundry Agent Service is designed for enterprise applications that require secure, scalable, and flexible AI agent deployment.

What’s the difference between these approaches?

It does sound like there is overlap, but there are some key differences in terms of their design, capabilities, and target use cases:

Still not sure which one to choose?

Use Cases

Let’s see if we can help you by going through some common use cases:

Q: I’m building production AI agent applications and want to get started quickly

A: The Microsoft Agent Framework is a great choice. It provides a simple, Pythonic API via FoundryChatClient that lets you define agents with tools and instructions in just a few lines of code.

Q: I need enterprise-grade deployment with Azure integrations like Search and code execution

A: Microsoft Foundry Agent Service is the best fit. It’s a platform service that provides built-in capabilities for multiple models, Azure AI Search, Bing Search and Azure Functions. It makes it easy to build your agents in the Foundry Portal and deploy them at scale.

Q: I’m still confused, just give me one option

A: Start with the Microsoft Agent Framework to build your agents, and then use Microsoft Foundry Agent Service when you need to deploy and scale them in production. This approach lets you iterate quickly on your agent logic while having a clear path to enterprise deployment.

Let’s summarize the key differences in a table:

Framework Focus Core Concepts Use Cases
Microsoft Agent Framework Streamlined agent SDK with tool calling Agents, Tools, Azure Identity Building AI agents, tool use, multi-step workflows
Microsoft Foundry Agent Service Flexible models, enterprise security, Code generation, Tool calling Modularity, Collaboration, Process Orchestration Secure, scalable, and flexible AI agent deployment

Microsoft agent types at a glance

Microsoft classifies agents by platform, so the same word can describe different choices. Start with one question: who owns the orchestration and runtime — Microsoft or you? Orchestration means deciding what happens next: call a model, use a tool, or delegate work. The runtime is the environment that carries out those steps.

Keep that question separate from the behavior-based agent types in Lesson 01. A goal-based travel assistant might use several different Microsoft platforms. Here, you’re choosing how to build and run it, not changing its goal. First decide how much of the agent’s execution you need to own, then compare the platform options.

Microsoft 365 Copilot

If your users work in Microsoft 365 Copilot, choose between extending Copilot’s own engine and connecting an agent with its own engine. Both approaches can put an agent where people work; the important difference is who controls its models and orchestration.

Type What it is Who runs it Build with
Declarative agent Adds your instructions, knowledge, and actions to Copilot’s orchestrator and models. Inherits Microsoft 365 security, compliance, and Responsible AI requirements. Microsoft runs the engine in Microsoft 365. No extra agent hosting. Agent Builder or Copilot Studio; Work IQ Dev Tools is the current recommendation for supported pro-code scenarios.
Custom engine agent Lets you choose models, orchestration, knowledge, and skills for complex, autonomous, or agent-to-agent scenarios. Your chosen engine runs outside Copilot’s built-in orchestration. Custom solutions require hosting outside Microsoft 365; Copilot Studio provides a managed option. Copilot Studio, Microsoft 365 Agents SDK/Toolkit, Microsoft Agent Framework.

Don’t choose only by the app where the agent appears. A Teams or Outlook experience doesn’t automatically mean a declarative agent. If you need your own models and orchestration behind that experience, consider a custom engine agent instead. With a custom engine, you’re also responsible for ensuring that your solution meets its security, compliance, and Responsible AI requirements.

Microsoft Foundry Agent Service

In Azure, Foundry Agent Service offers a similar choice between configuration and code. Choose a prompt agent when instructions, a model, and tools describe what you need. Choose a hosted agent when your application needs to supply the framework and orchestration.

Type What it is Who runs it Choose it when
Prompt agent A versioned configuration of model, instructions, and tools, invoked through the Responses API. Foundry runs orchestration and runtime. You want the fastest path without deploying orchestration code.
Voice-based prompt agent A real-time voice agent connected through Voice Live. Foundry manages voice orchestration. You need spoken interactions without hosting voice orchestration.
Hosted agent Your code and framework, such as Microsoft Agent Framework or LangGraph, running in a container. You own the agent logic; Foundry supplies the endpoint, identity, scaling, and observability. You need your own framework, state, middleware, or multi-agent orchestration. This is the deployment path for the course’s Agent Framework code.

Calling Foundry doesn’t require a saved agent. Call the Responses API directly if your application supplies the model, instructions, and tools on each request. Keep this option distinct from a saved prompt agent: the agent definition lives in your application rather than in a versioned Foundry agent resource.

[!NOTE] Foundry declarative workflows (preview) retired on 1 December 2026. Use code-based orchestration with Microsoft Agent Framework instead. This retirement doesn’t affect code-based orchestration in hosted agents. See the workflow migration guidance.

Microsoft Copilot harness — a runtime, not a new agent type

A harness is the engine around the model that runs the agent loop. The Microsoft Copilot harness (preview) decides the next step at runtime, calls tools, applies skills, works with files in a sandbox, and delegates tasks to subagents. Microsoft runs that loop and sandbox; you supply the knowledge, skills, and tools.

In Foundry (public preview), announced on 28 October 2026, the harness is an optional runtime for prompt agents. Your resource stays a prompt agent, and you still invoke it through the Responses API. Selecting this runtime doesn’t turn your agent into a hosted agent.

It adds built-in file-system, shell, web-fetch, and subagent tools, alongside supported MCP tools and reusable skills packaged as folders with SKILL.md. Each conversation gets a separate sandboxed workspace. Connect this idea to context engineering in Lesson 12: skills give the agent reusable procedures and supporting context for its work.

In Copilot Studio (preview), the harness is an alternative to the standard harness. Describe the agent in natural language rather than authoring explicit conversation topics. Skills replace prompt tools, hooks replace topics, and code interpreter is built in. Memory (preview) adds context from previous interactions; review Lesson 13 for the underlying memory concepts. Building, testing, evaluating, and using these agents can consume Copilot Credits through usage-based billing.

Check preview boundaries before choosing it. In Foundry, select the harness only when creating the agent; you can’t switch an existing agent, and bring-your-own-model isn’t supported. In Copilot Studio, you also choose at creation, but the current documentation supports creating a harness-powered agent from a standard-harness agent; transfer back isn’t supported. Don’t assume the two platforms have identical migration options. Microsoft doesn’t recommend the Foundry harness preview for production workloads.

Which should I choose?

Q: My agent lives in Teams or Outlook, and I want Microsoft to run everything.

A: Choose a declarative agent using Microsoft 365 Copilot’s engine.

Q: I want the fastest governed agent in Azure.

A: Start with a Foundry prompt agent.

Q: My prompt agent needs multi-step file, tool, and skill work, and preview is OK.

A: Consider a prompt agent with the Microsoft Copilot harness (preview).

Q: I need my own framework, state, middleware, or multi-agent orchestration.

A: Choose a Foundry hosted agent.

Q: I need my own models and orchestration, but users meet the agent in Microsoft 365 Copilot.

A: Choose a custom engine agent.

Rule of thumb: Want Microsoft to run the brain? Declarative or prompt agent. Need to own the brain? Custom engine or hosted agent. Here, “brain” means orchestration, not just model selection.

Knowledge check

1. Is the Microsoft Copilot harness a new agent type?

Answer No. It's a runtime choice; a Foundry prompt agent stays a prompt agent.

2. Which Foundry agent type deploys Microsoft Agent Framework code?

Answer A hosted agent.

3. Which Microsoft 365 agent type uses Copilot’s own orchestrator?

Answer A declarative agent.

Can I integrate my existing Azure ecosystem tools directly, or do I need standalone solutions?

The answer is yes, you can integrate your existing Azure ecosystem tools directly with Microsoft Foundry Agent Service especially, as it has been built to work seamlessly with other Azure services. You could for example integrate Bing, Azure AI Search, and Azure Functions. There’s also deep integration with Microsoft Foundry.

The Microsoft Agent Framework also integrates with Azure services through FoundryChatClient and Azure identity, letting you call Azure services directly from your agent tools.

Sample Codes

Got More Questions about AI Agent Frameworks?

Join the Microsoft Foundry Discord to meet with other learners, attend office hours and get your AI Agents questions answered.

References

Previous Lesson

Introduction to AI Agents and Agent Use Cases

Next Lesson

Understanding Agentic Design Patterns