What Tools and Libraries Does ai-agents-for-beginners Depend On?
The microsoft/ai-agents-for-beginners repository depends on 20+ Python packages across five categories: Azure AI services, Microsoft's Agent Framework, Model Context Protocol, OpenAI SDK, and utility libraries for data processing and notebook execution.
This open-source learning kit from Microsoft demonstrates how to build production-ready AI agents using Azure AI Foundry and modern agentic protocols. All dependencies are declaratively managed in requirements.txt, making the environment reproducible for beginners and experienced developers alike. This guide breaks down every dependency group with specific file paths, method signatures, and runnable code examples straight from the source.
Azure AI and Identity Libraries
The Azure AI stack forms the production backbone of the repository. These four packages enable authentication, model inference, project orchestration, and retrieval-augmented generation.
Core Azure Packages
| Package | Purpose | Source File Reference |
|---|---|---|
azure-identity |
Azure AD authentication via DefaultAzureCredential |
Used across all Azure-connected notebooks |
azure-ai-inference |
Chat completions and model inference endpoints | 01-intro-to-ai-agents/code_samples/01-python-agent-framework.ipynb |
azure-ai-projects |
Project-level orchestration and resource management | Foundation for multi-agent workflows |
azure-search-documents |
Vector and keyword search for RAG implementations | 05-agentic-rag lessons |
Authentication Example
The DefaultAzureCredential class from azure-identity provides seamless authentication across local development and Azure deployments:
from azure.identity import DefaultAzureCredential
from azure.ai.inference import ChatCompletionsClient
credential = DefaultAzureCredential()
endpoint = "https://<your-project>.openai.azure.com"
client = ChatCompletionsClient(endpoint=endpoint, credential=credential)
response = client.chat_completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello, AI!"}]
)
print(response.choices[0].message.content)
This pattern appears in 01-intro-to-ai-agents/code_samples/01-python-agent-framework.ipynb as the entry point for Azure-based agent development.
Microsoft Agent Framework
The agent-framework and a2a-sdk packages provide the core abstraction layer for defining agents, registering tools, and orchestrating multi-step workflows.
Framework Components
| Package | Role | Key Classes/Decorators |
|---|---|---|
agent-framework |
Core agent definition and execution | Agent, Tool, @Tool |
a2a-sdk |
Agent-to-Agent protocol implementation | A2A communication primitives |
Agent Definition Example
The 14-microsoft-agent-framework/code-samples/14-sequential.ipynb notebook demonstrates the declarative agent pattern:
from agent_framework import Agent, Tool
@Tool
def echo(text: str) -> str:
"""Simply returns the provided text."""
return text
my_agent = Agent(
name="EchoAgent",
description="Echoes back whatever the user says",
tools=[echo],
model="gpt-4o" # works with Azure or OpenAI
)
print(my_agent.run("Say hello!"))
The framework abstracts the underlying LLM provider, enabling identical agent code to run against Azure OpenAI or OpenAI's native API.
Model Context Protocol (MCP)
The mcp[cli] package implements the Model Context Protocol, a standardized mechanism for serializing, exchanging, and tracing agent context across distributed components.
MCP Usage Pattern
As shown in 11-agentic-protocols/code_samples/11-mcp-agent-framework.ipynb:
from mcp import Context, serialize_context, deserialize_context
ctx = Context(user_id="alice", session_id="1234")
payload = serialize_context(ctx)
# Later, possibly in another agent
restored = deserialize_context(payload)
print(restored.session_id) # → "1234"
MCP enables traceability and context preservation when agents hand off work to other agents or resume sessions from persisted state.
OpenAI SDK
The openai package provides a direct alternative to Azure AI for students without Azure subscriptions or those wanting to compare model behavior.
Direct OpenAI Usage
import openai
openai.api_key = "sk-…" # loaded from .env in real notebooks
response = openai.ChatCompletion.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What is the capital of France?"}]
)
print(response.choices[0].message.content)
This pattern appears in introductory notebooks when Azure credentials are unavailable, ensuring the learning materials remain accessible.
Data and Utility Libraries
The remaining packages support notebook execution, data processing, HTTP communication, and environment management.
| Category | Libraries | Purpose |
|---|---|---|
| HTTP & Async | httpx, nest-asyncio, uvicorn |
Modern HTTP client, Jupyter async loop patching, ASGI server for tool endpoints |
| Jupyter | ipykernel |
Notebook kernel execution |
| Data Processing | numpy, pandas, pillow |
Numerical arrays, tabular data, image manipulation |
| Environment | python-dotenv |
Load .env files for secrets and configuration |
FastAPI Tool Server Example
The uvicorn + fastapi combination enables agents to expose custom tools as HTTP endpoints, as demonstrated in multi-agent workflow examples:
from fastapi import FastAPI
import uvicorn
app = FastAPI()
@app.get("/weather")
def get_weather(city: str):
return {"city": city, "temp_c": 22}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
Agents invoke this endpoint as an external tool, enabling integration with existing APIs and services.
Summary
- Azure AI stack (
azure-identity,azure-ai-inference,azure-ai-projects,azure-search-documents) provides production-grade authentication, inference, and retrieval capabilities. - Microsoft Agent Framework (
agent-framework,a2a-sdk) offers the core abstraction for defining agents and enabling agent-to-agent communication. - Model Context Protocol (
mcp[cli]) standardizes context serialization and tracing across distributed agent components. - OpenAI SDK (
openai) serves as an accessible alternative for learners without Azure subscriptions. - Utility libraries (
httpx,uvicorn,pandas,pillow,python-dotenv, etc.) support notebook execution, data processing, HTTP communication, and environment management.
All dependencies are declared in requirements.txt and loaded via python-dotenv from .env files, ensuring reproducible, secure environments for learning AI agent development.
Frequently Asked Questions
What is the main dependency file in ai-agents-for-beginners?
The requirements.txt file at the repository root contains all 20+ Python dependencies. It is referenced in setup instructions and used by pip install -r requirements.txt to create a reproducible environment.
Can I run the notebooks without an Azure subscription?
Yes. The openai package allows direct API calls to OpenAI's models, and several introductory notebooks include fallback paths that use python-dotenv to load OpenAI keys instead of Azure credentials.
What is the purpose of the mcp[cli] package?
The mcp[cli] package implements the Model Context Protocol, which standardizes how agents serialize, exchange, and trace context across sessions and between different agent instances. It is demonstrated in the "11-agentic-protocols" lesson.
How does the Microsoft Agent Framework differ from using Azure AI directly?
The agent-framework provides higher-level abstractions like the Agent class and @Tool decorator that handle tool registration, conversation state, and orchestration patterns (sequential, concurrent, conditional). It can target either Azure AI or OpenAI through the same API, whereas direct Azure AI usage requires manual management of endpoints and credentials.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →