Microsoft Agent Framework Samples

repository·main·Indexed 43 days ago

https://github.com/microsoft/agent-framework-samples

A comprehensive guide and sample repository for building intelligent agents using the Microsoft Agent Framework. It provides practical Python and .NET implementations covering agent foundations, tool integration, Agentic RAG via Azure AI Foundry, and multi-agent orchestration. The framework consolidates capabilities from Semantic Kernel and AutoGen to enable natural language-driven agents and collaborative workflows.

Tokens
87.9K
Snippets
233
Records
310
Agent score
56%

What's inside Microsoft Agent Framework

  1. Key features of the Microsoft Agent Framework samples

    main

    The samples demonstrate the following capabilities of the Microsoft Agent Framework:

    • Multiple Provider Support: Integration with Azure OpenAI, GitHub Models, and Microsoft Foundry.
    • Tool Integration: Vision analysis, code interpretation, and custom functions.
    • RAG Capabilities: File search and knowledge base integration.
    • Multi-Agent Orchestration: Sequential and collaborative agent patterns.
    • MCP Integration: Model Context Protocol for enhanced capabilities.
    • Streaming Responses: Real-time agent interactions.
    • Persistent Agents: Stateful agent conversations.
    • Evaluation & Debugging: DevUI for visual debugging and observability tools for tracing.
  2. Explore Microsoft Agent Framework sample categories

    main

    The repository is organized into several learning paths and functional modules. Use the following directory structure to find relevant code samples for your needs:

    • 00.ForBeginners: Introductory examples (Travel Agent, Basic Agent, RAG, Multi-Agent) for both .NET and Python.
    • 01.AgentFoundation: Core concepts and architecture (Documentation only).
    • 02.CreateYourFirstAgent: Step-by-step guide to building a travel planning agent.
    • 03.ExploreAgentFramework: Deep dives into providers like Azure OpenAI, GitHub Models, and MS Foundry.
    • 04.Tools: Integration of Vision, Code Interpreter, Bing Grounding, and File Search.
    • 05.Providers: Implementation of MCP (Model Context Protocol) and Agent-to-Agent communication.
    • 06.RAGs: Knowledge-enhanced agents using File Search RAG.
    • 07.Workflow: Orchestration patterns including Basic, Sequential, Concurrent, and Conditional workflows.
    • 08.EvaluationAndTracing: Tools for debugging, observability, and DevUI for various agent types.
    • 09.Cases: Real-world production-ready multi-agent applications and case studies.
  3. Build multi-agent systems with Microsoft Foundry

    main

    Microsoft Foundry enables the transition from AI research to production-ready enterprise applications using a three-phase development lifecycle: Design, Develop, and Deploy.

    1. Design (Low-Code) via Foundry Workflows

    Use the visual, drag-and-drop interface in Microsoft Foundry to orchestrate agents and deterministic business logic (e.g., IF/ELSE conditions). This phase allows for rapid prototyping and visualization of data flows. Once designed, workflows can be tested in the cloud and exported as YAML configuration.

    2. Develop (Local SDLC) via VSCode Extension

    Use the Microsoft Foundry VSCode Extension to move from cloud prototypes to a local Software Development Lifecycle (SDLC). Key capabilities include:

    • Sync: Pull workflow definitions from the cloud to your local machine.
    • Inspect: Review the logic of your orchestrated agents.
    • Scaffold: Generate the necessary local code structures.

    3. Deploy (Native Runtime) via Microsoft Agent Framework

    The Microsoft Agent Framework acts as the runtime engine. It natively ingests the declarative YAML files exported from the Foundry design phase. This implements a "Configuration as Code" pattern, allowing you to promote artifacts from prototyping to production without rewriting logic, requiring minimal boilerplate code to initialize the system.

  4. Overview of Azure AI Foundry Agent Service

    main

    The Azure AI Foundry Agent Service (integrated within Azure AI Studio) is a managed platform for the lifecycle of building, testing, and deploying enterprise-grade AI agents.

    Key features include:

    • Enterprise-Grade Orchestration: Manages the logic for reasoning, tool selection, and multi-step plan execution.
    • Seamless Tool Integration: Provides pre-built connectors and support for custom functions and APIs.
    • Managed Infrastructure: Handles compute, scalability, and deployment so developers can focus on agent intelligence.
    • Robust Evaluation & Monitoring: Provides tools to evaluate performance, ensure safety, and monitor real-world behavior.
  5. What is GraphRAG and its intended use cases?

    main

    GraphRAG is an AI-based content interpretation and search capability that uses LLMs to parse data into a knowledge graph. It is designed to answer user questions about private datasets by connecting information across large volumes of data.

    Key Capabilities:

    • Answers questions that are difficult for keyword or vector-based search.
    • Handles thematic questions (e.g., "What are the top themes in this dataset?").
    • Connects information spanning many documents.

    Intended Use Cases:

    • Critical information discovery and analysis where insights span multiple documents.
    • Analyzing noisy datasets or datasets containing misinformation.
    • Answering abstract or thematic questions.
    • Working with domain-specific corpora of text data.
  6. Overview of the Agentic Marketing Content Workflow

    main

    The Agentic Marketing Content Workflow is an automated system designed to transform a single topic into a complete marketing asset package. The workflow operates in three distinct phases:

    1. Strategy Phase: Uses either a Strategy Agent or a DeepResearch Executor to generate a MarketingStrategy.
    2. Content Generation Phase: Uses specialized agents to produce CopywritingContent, ImageContent, and VideoScript based on the strategy.
    3. Packaging Phase: Uses a Packaging Executor to collect all outputs into a final CampaignPackage.

    Key services integrated into the workflow include Tavily (web search), FLUX (image generation), Sora-2 (video generation), and the local FileSystem.

  7. Overview of the Microsoft Agent Framework

    main

    The Microsoft Agent Framework is a unified platform for creating natural language-driven agents and orchestrating multi-agent collaboration. It serves as a consolidation of capabilities from previous projects like Semantic Kernel and AutoGen.

    Core capabilities include:

    • Unified Development Experience: A consistent way to build agents of varying complexity.
    • Advanced Orchestration: Tools to design workflows where multiple agents interact and delegate tasks to one another.
    • Natural Language Interaction: A focus on enabling agents to communicate effectively with users via natural language.
  8. What is Agent-to-Agent (A2A) communication?

    main

    Agent-to-Agent (A2A) is a pattern where one AI agent can call upon another specialized AI agent to perform a task or answer a question. This allows for the composition of complex multi-agent systems where a 'manager' agent orchestrates specialized 'worker' agents.

    Common scenarios:

    • Task Delegation and Orchestration: A manager agent breaks a complex request into sub-tasks for specialized agents.
    • Specialized Expertise: A generalist agent consults a specialist (e.g., a Billing Expert) for domain-specific knowledge.
    • Collaborative Problem-Solving: Multiple agents share information and intermediate results to solve complex problems.
  9. What is the Model Context Protocol (MCP)?

    main

    The Model Context Protocol (MCP) is a standard that allows an AI agent to discover and interact with external tools and services via a universal API. Instead of building custom connections for every tool, an agent connects to an MCP endpoint which exposes a list of available tools.

    Common use cases include:

    • Retrieval-Augmented Generation (RAG): Fetching information from external knowledge bases (e.g., documentation) to ground agent responses.
    • Task Automation: Using tools to perform actions like checking inventory or filing tickets.
    • Dynamic Tool Usage: Automatically discovering new tools as they are added to the MCP server without reprogramming the agent.
  10. What is an AI Agent and its core components?

    main

    An AI Agent is an autonomous system driven by a Large Language Model (LLM) that can understand high-level goals, plan actionable steps, and execute them using tools.

    An agent consists of three primary components:

    1. The LLM (Reasoning Engine): Acts as the 'brain' to interpret requests, generate plans, make decisions, and learn.
    2. Tools (Action Executors): External capabilities that allow the agent to interact with the world (e.g., internet search, API calls, email, database queries, or software control).
    3. Memory (Experience & Context): Enables intelligence over time through short-term memory (conversation context) and long-term memory (storing past observations and learnings).
  11. How RAG (Retrieval-Augmented Generation) works

    main

    Retrieval-Augmented Generation (RAG) is a technique used to ground Large Language Models (LLMs) in external, private, or up-to-date knowledge sources to reduce hallucinations. It consists of two primary components:

    1. Retriever: Searches and retrieves relevant information from a knowledge base (e.g., documents).
    2. Generator: An LLM that uses the retrieved context to generate an accurate answer.
    1. Upload Knowledge: Upload documents to the service.
    2. Create a Vector Store: Index uploaded files into a vector store for semantic searching.
    3. Define the Agent: Create an agent and equip it with a File Search tool.
    4. Link Resources: Connect the File Search tool to the specific vector store.
    5. Instruct the Agent: Use a system prompt to define behavior (e.g., "only use provided files").
    6. Query the Agent: Ask questions; the agent automatically retrieves context before responding.
  12. Build conditional workflows with WorkflowBuilder

    main

    Conditional workflows allow you to route processing based on AI analysis or business rules. You use WorkflowBuilder to define the sequence of agents and the logic for branching.

    Key patterns:

    • Edges: Connect an agent to another agent or an executor function.
    • Multi-selection edges: Use add_multi_selection_edge_group to implement decision logic. This requires a selection_func that takes the current result and a list of target IDs, returning the ID(s) of the next step(s).
    • Executors: Use the @executor decorator to define custom logic that processes agent responses and decides the next path in the workflow.

    Example Workflow Structure:

    1. Start with an initial agent.
    2. Add edges to specialized agents.
    3. Use an executor to parse results and a selection function to route to specific paths (e.g., handle_review vs save_draft).
    workflow = (
        WorkflowBuilder(start_executor=evangelist_agent)
            .add_edge(evangelist_agent, reviewer_agent)
            .add_edge(reviewer_agent, to_reviewer_result)
            .add_multi_selection_edge_group(
                to_reviewer_result,
                [handle_review, save_draft],
                selection_func=select_targets,
            )
            .add_edge(save_draft, publisher_agent)
            .build()
    )