ai-agents-for-beginners

Explorin AI Agent Frameworks

(Click di picture wey dey up to watch dis lesson video)

Make We 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 dey help make the development of complex AI systems faster.

Dem frameworks dey help developers concentrate on wetin dey unique for their apps by giving standard ways to handle common wahala for AI agent development. Dem dey boost scalability, accessibility, and efficiency for building AI systems.

Introduction

This lesson go cover:

Learning goals

Di goals for dis lesson na to help you sabi:

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

Traditional AI Frameworks fit help you integrate AI inside your apps and make these apps beta for di following ways:

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

AI Agent frameworks mean something pass normal AI frameworks. Dem design dem to enable the creation of intelligent agents wey fit interact with users, other agents, and the environment to achieve specific goals. These agents fit show autonomous behaviour, make decisions, and adapt to changing conditions. Make we look some key capabilities wey AI Agent Frameworks dey enable:

So in short, agents dey allow you do more, make automation reach next level, and create more intelligent systems wey fit adapt and learn from their environment.

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

This landscape dey move quick, but some things common for most AI Agent Frameworks fit help you quickly prototype and iterate — like modular components, collaborative tools, and real-time learning. Make we dive into these:

Use Modular Components

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

How teams fit use these: Teams fit quickly assemble these components to create a working prototype without starting from scratch, so dem fit experiment and iterate fast.

How e dey work for practice: You fit use 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 building these components from scratch.

Example code. Make we look one example of how you fit use the Microsoft Agent Framework with AzureAIProjectAgentProvider to make the model respond to user input with tool calling:

# Microsoft Agent Framework Python Example

import asyncio
import os
from typing import Annotated

from agent_framework.azure import AzureAIProjectAgentProvider
from azure.identity import AzureCliCredential


# Define wan sample tool function to book travel
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 = AzureAIProjectAgentProvider(credential=AzureCliCredential())
    agent = await provider.create_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 successfully book. Safe travels! ✈️🗽


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

Wetin you fit see from this example na how you fit use pre-built parser to extract key information from user input, like origin, destination, and date for flight booking request. Dis modular approach allow you focus on the high-level logic.

Leverage Collaborative Tools

Frameworks like the Microsoft Agent Framework dey make am easy to create multiple agents wey fit work together.

How teams fit use these: Teams fit design agents with specific roles and tasks, make dem test and refine collaborative workflows and improve overall system efficiency.

How e dey work for practice: You fit create team of agents where each agent get specialized function, like data retrieval, analysis, or decision-making. These agents fit communicate and share info to achieve common goal, like answer user question or complete task.

Example code (Microsoft Agent Framework):

# Di mek plenty agents wey dey work togeder wit di Microsoft Agent Framework

import os
from agent_framework.azure import AzureAIProjectAgentProvider
from azure.identity import AzureCliCredential

provider = AzureAIProjectAgentProvider(credential=AzureCliCredential())

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

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

# Make agents run one after di oda for one work
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 the code wey pass na how you fit create task wey involve multiple agents wey dey work together to analyze data. Each agent dey do specific function, and the task dey executed by coordinating the agents to reach the desired outcome. By creating dedicated agents with specialized roles, you fit improve task efficiency and performance.

Learn in Real-Time

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

How teams fit use these: Teams fit implement feedback loops wey make agents learn from interactions and change their behaviour dynamically, so dem go continue to improve and refine capabilities.

How e dey work for practice: Agents fit analyze user feedback, environmental data, and task outcomes to update their knowledge base, adjust decision-making algorithms, and improve performance over time. Dis iterative learning process make agents fit adapt to changing conditions and user preferences, and e dey boost overall system effectiveness.

What are the differences between the Microsoft Agent Framework and Azure AI Agent Service?

Plenty ways dey compare these approaches, but make we look some key differences for their design, capabilities, and target use cases:

Microsoft Agent Framework (MAF)

The Microsoft Agent Framework na streamlined SDK for building AI agents using AzureAIProjectAgentProvider. E enable developers to create agents wey use Azure OpenAI models with built-in tool calling, conversation management, and enterprise-grade security through Azure identity.

Use Cases: Build production-ready AI agents wey fit use tools, run multi-step workflows, and integrate with enterprise scenarios.

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

Azure AI Agent Service

Azure AI Agent Service na newer option wey dem present for Microsoft Ignite 2024. E allow development and deployment of AI agents with more flexible models, for example direct call open-source LLMs like Llama 3, Mistral, and Cohere.

Azure AI Agent Service dey provide stronger enterprise security mechanisms and data storage ways, so e good for enterprise apps.

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

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

Using the Azure AI 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 functions na wetin deh for do small small samting dem
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-4o-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

Azure AI Agent Service get these core concepts:

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

What’s the difference between these approaches?

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

Still no sure which one to choose?

Use Cases

Make we try help you by going through common use cases:

Q: I dey build production AI agent applications and I want to start quick

A: The Microsoft Agent Framework na good choice. E provide simple, Pythonic API via AzureAIProjectAgentProvider wey let you define agents with tools and instructions in just few lines of code.

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

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

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

A: Start with the Microsoft Agent Framework to build your agents, then use Azure AI Agent Service when you need deploy and scale them for production. This way you fit iterate quick on your agent logic and still get clear path to enterprise deployment.

Make we summarize key differences for 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
Azure AI Agent Service Flexible models, enterprise security, Code generation, Tool calling Modularity, Collaboration, Process Orchestration Secure, scalable, and flexible AI agent deployment

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

Di ansa na yes — you fit integrate your existing Azure ecosystem tools directly wit Azure AI Agent Service, especially as e don build make e work seamlessly wit oda Azure services. You fit, for example, integrate Bing, Azure AI Search, and Azure Functions. E still get deep integration wit Microsoft Foundry.

The Microsoft Agent Framework sef dey integrate wit Azure services through AzureAIProjectAgentProvider and Azure identity, letting you call Azure services directly from your agent tools.

Sample Codes

You get more questions about AI Agent Frameworks?

Join the Microsoft Foundry Discord to meet wit oda learners, attend office hours, and make dem answer your AI Agents questions.

References

Previous Lesson

Intro to AI Agents and Agent Use Cases

Next Lesson

Understanding Agentic Design Patterns


Disclaimer: Dis document dem translate wit AI translation service wey dem dey call Co-op Translator (https://github.com/Azure/co-op-translator). Even though we dey try make am correct, abeg sabi say automatic translations fit get mistakes or things wey no too correct. The original document for im original language na the main/official source. If na important information, better make professional human translator do am. We no go liable for any misunderstanding or wrong interpretation wey fit come from this translation.