ai-agents-for-beginners

Exploring AI Agent Frameworks

(Click di image we dey top to watch video of dis lesson)

Explore AI Agent Frameworks

AI agent frameworks na software platforms wey dem design to make e easy to create, deploy, and manage AI agents. Dem frameworks dey give developers pre-built components, abstractions, and tools wey quicken di development of complex AI systems.

Dem frameworks dey help developers focus for di unique parts of dia applications by providing standard ways to solve common wahala for AI agent development. Dem dey improve scalability, accessibility, and efficiency for building AI systems.

Introduction

This lesson go cover:

Learning goals

Di goals of dis lesson na to help you understand:

Wetin be AI Agent Frameworks and wetin dem enable developers to do?

Traditional AI Frameworks fit help you add AI give your apps and make di apps beta in dis kain ways:

All dis sounds beta abi, why we still need AI Agent Framework?

AI Agent frameworks no be just AI frameworks. Dem design to enable creation of smart agents wey fit interact with users, other agents, and environment to achieve special goals. These agents fit behave on dia own, make decisions, and adjust to changes. Make we see some key abilities wey AI Agent Frameworks enable:

So, to summarize, agents dey allow you to do more, take automation go next level, and create smarter systems wey fit adapt and learn from their environment.

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

Dis matter dey move quick, but some things dey common for most AI Agent Frameworks wey fit help you prototype and iterate fast, like module components, collaborative tools, and real-time learning. Make we explore dem:

Use Modular Components

SDKs like Microsoft Agent Framework dey provide pre-built components like AI connectors, tool definitions, and agent management.

How teams fit use dem: Teams fit quickly put together these components to create functional prototype without to start from scratch, e dey allow rapid experiments and iterations.

How e dey work for practice: You fit use pre-built parser to extract info from user input, memory module to store and get data, and prompt generator to interact with users, all without to build these parts from beginning.

Example code. Make we check example how you fit use Microsoft Agent Framework with FoundryChatClient to make model respond to user input with tool call:

# 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 one sample tool function wey go 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 go New York on January 1, 2025, don book gidigba. Safe travels! ✈️🗽


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

Wetin you go see for dis example na how you fit use pre-built parser to take important info from user input, like origin, destination, and travel date for flight booking. Dis modular approach make you fit focus on high-level logic.

Leverage Collaborative Tools

Frameworks like Microsoft Agent Framework dey help create many agents wey fit work together.

How teams fit use dem: Teams fit design agents with special roles and tasks, so dem fit test and improve collaborative workflows and make system efficiency beta.

How e dey work for practice: You fit create team of agents wey each get special function, like data retrieval, analysis, or decision-making. These agents fit communicate and share info to achieve one goal, e.g., answer user question or finish task.

Example code (Microsoft Agent Framework):

# Dey create plenti agents wey go work together wit di 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],
)

# Make agents run one by one for di 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)

Wetin you see for di code above na how you fit create task wey many agents dey work together to analyze data. Each agent dey do special work, and dem coordinate to finish di task as e suppost be. By creating agents with clear roles, you fit improve task efficiency and performance.

Learn in Real-Time

Advanced frameworks get abilities for real-time context understanding and adjustment.

How teams fit use dem: Teams fit put feedback loops wey make agents learn from interactions and adjust behaviour as e dey go, so performance go continuously improve.

How e dey work for practice: Agents fit analyze user feedback, environment data, and task results to update knowledge base, adjust decision algorithms, and improve performance over time. This iterative learning make agents fit adapt to change and user preferences, improve system effectiveness.

Wetin be di difference between Microsoft Agent Framework and Microsoft Foundry Agent Service?

Plenty ways dey to compare these, but make we look some key difference for their design, abilities, and intended use:

Microsoft Agent Framework (MAF)

Microsoft Agent Framework dey provide streamlined SDK to build AI agents using FoundryChatClient. E enable devs create agents wey fit use Azure OpenAI models with built-in tool call, conversation management, and enterprise-grade security through Azure identity.

Use Cases: Build production-ready AI agents with tools, multi-step workflows, and enterprise integration scenarios.

Here be some important core concepts for Microsoft Agent Framework:

Microsoft Foundry Agent Service

Microsoft Foundry Agent Service na newer addition, wey dem show for Microsoft Ignite 2024. E allow make people develop and deploy AI agents with more flexible models, like direct call open-source LLMs like Llama 3, Mistral, and Cohere.

Microsoft Foundry Agent Service get stronger enterprise security and data storage methods, so e good for enterprise applications.

E work out-of-the-box with Microsoft Agent Framework for building and deploying agents.

Dis service dey Public Preview now and e support Python and C# for building agents.

Using Microsoft Foundry Agent Service Python SDK, we fit create agent with user-defined tool:

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

# Define tool tins wey dem dey use do work
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-4.1-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 get dis core concepts:

Use Cases: Microsoft Foundry Agent Service design for enterprise applications wey need secure, scalable, flexible AI agent deployment.

Wetin be di difference between dese approaches?

E be like overlap dey, but some key differences dey for design, powers, and target use cases:

Still dey wonder which one to pick?

Use Cases

Make we help you by showing some common use cases:

Q: I dey build production AI agent apps and I want start fast

A: Microsoft Agent Framework na beta choice. E get simple, Python style API via FoundryChatClient wey let you define agents with tools and instructions in just small code.

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

A: Microsoft Foundry Agent Service na best fit. Na platform service wey get built-in support for many models, Azure AI Search, Bing Search and Azure Functions. E make am easy to build agents for Foundry Portal and deploy dem at scale.

Q: I still dey confused, just give me one option

A: Start with Microsoft Agent Framework to build your agents, then use Microsoft Foundry Agent Service when you ready to deploy and scale for production. This way, you fit quickly test your agent logic and still get enterprise deployment path clear.

Make we summarize key differences for table:

Framework Focus Core Concepts Use Cases
Microsoft Agent Framework Streamlined agent SDK with tool call Agents, Tools, Azure Identity Build 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, flexible AI agent deployment

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

Di answer na yes, you fit connect your existing Azure ecosystem tools straight to Microsoft Foundry Agent Service specially, as e dey built to work well witoda oda Azure services. You fit for example connect Bing, Azure AI Search, and Azure Functions. E still get deep connection wit Microsoft Foundry.

Di Microsoft Agent Framework still dey connect wit Azure services through FoundryChatClient and Azure identity, wey fit make you yan Azure services direct from your agent tools.

Sample Codes

You Get More Questions about AI Agent Frameworks?

Join di Microsoft Foundry Discord to meet oda learners, join office hours and make you fit get answer for your AI Agents questions.

References

Previous Lesson

Introduction to AI Agents and Agent Use Cases

Next Lesson

Understanding Agentic Design Patterns


Disclaimer: Dis document don translate wit AI translation service Co-op Translator. Even tho we dey try make am correct, abeg make you know say automated translation fit get errors or mistakes. Di original document for dia own language na im be di correct source. For important info, make person wey sabi human translation do am. We no go responsible for any misunderstanding or wrong understanding wey fit happen because of dis translation.