{"id":6502,"library":"agent-framework","title":"Microsoft Agent Framework","description":"Microsoft Agent Framework is a comprehensive Python library for building, orchestrating, and deploying AI agents and multi-agent workflows. It provides core abstractions, implementations, and integrations with various LLM providers. Version 1.0.1 is the current stable release, offering production-ready APIs with a commitment to long-term support. The project maintains an active development and release cadence.","status":"active","version":"1.0.1","language":"en","source_language":"en","source_url":"https://github.com/microsoft/agent-framework","tags":["AI","Agents","Microsoft","Azure","LLM","Orchestration","Multi-agent","Generative AI"],"install":[{"cmd":"pip install agent-framework","lang":"bash","label":"Full installation (includes all sub-packages)"}],"dependencies":[{"reason":"Required for Azure authentication methods like AzureCliCredential, used by Azure-specific chat clients.","package":"azure-identity","optional":false},{"reason":"Commonly used for loading environment variables from .env files in local development. Not strictly required by the framework itself, but often seen in quickstarts.","package":"python-dotenv","optional":true}],"imports":[{"symbol":"Agent","correct":"from agent_framework import Agent"},{"symbol":"FoundryChatClient","correct":"from agent_framework.foundry import FoundryChatClient"},{"symbol":"AzureOpenAIResponsesClient","correct":"from agent_framework.azure import AzureOpenAIResponsesClient"},{"note":"AzureCliCredential is part of the 'azure-identity' package, not 'agent-framework.azure'.","wrong":"from agent_framework.azure import AzureCliCredential","symbol":"AzureCliCredential","correct":"from azure.identity import AzureCliCredential"},{"symbol":"asyncio","correct":"import asyncio"},{"symbol":"os","correct":"import os"}],"quickstart":{"code":"import asyncio\nimport os\nfrom agent_framework.azure import AzureOpenAIResponsesClient\nfrom azure.identity import AzureCliCredential\n# from dotenv import load_dotenv # Uncomment and install if using .env file locally\n\nasync def main():\n    # Load environment variables from .env file if uncommented above\n    # load_dotenv()\n\n    # Ensure AZURE_AI_PROJECT_ENDPOINT and AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME are set\n    # and you are authenticated via Azure CLI (e.g., `az login`)\n    project_endpoint = os.environ.get(\"AZURE_AI_PROJECT_ENDPOINT\", \"https://your-project.services.ai.azure.com\")\n    deployment_name = os.environ.get(\"AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME\", \"gpt-4o\")\n\n    if not all([project_endpoint, deployment_name]):\n        print(\"Please set AZURE_AI_PROJECT_ENDPOINT and AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME environment variables.\")\n        print(\"Ensure you have authenticated via Azure CLI (`az login`).\")\n        return\n\n    # Create an Azure CLI credential for authentication\n    credential = AzureCliCredential()\n\n    # Initialize the Azure OpenAI Responses client\n    client = AzureOpenAIResponsesClient(\n        project_endpoint=project_endpoint,\n        deployment_name=deployment_name,\n        credential=credential,\n    )\n\n    # Create an agent with instructions\n    agent = client.as_agent(\n        name=\"HelloAgent\",\n        instructions=\"You are a friendly assistant. Keep your answers brief.\",\n    )\n\n    # Run the agent\n    print(\"Agent: Thinking...\")\n    result = await agent.run(\"What is the capital of France?\")\n    print(f\"Agent: {result}\")\n\n    # Example of streaming response (optional)\n    # print(\"\\nAgent (streaming): Thinking...\")\n    # async for token in agent.run(\"Tell me a short story about a brave knight.\", stream=True):\n    #     print(token, end=\"\", flush=True)\n    # print()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to create a simple AI agent using the Microsoft Agent Framework with Azure OpenAI. It requires `azure-identity` for authentication (e.g., via `az login`) and environment variables for Azure project endpoint and deployment name. All agent operations are asynchronous and must be run using `asyncio.run()`."},"warnings":[{"fix":"Wrap agent invocation code in an `async def main():` function and execute it with `asyncio.run(main())`.","message":"All agent operations in the Microsoft Agent Framework are asynchronous. You must use `async/await` syntax and execute your agent logic within an `async` function, typically run via `asyncio.run()`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure `azure-identity` is installed, run `az login` for Azure CLI authentication, and set required environment variables or API keys before running your agent code. Consider using `python-dotenv` for local development with a `.env` file.","message":"Proper authentication and configuration via environment variables are crucial. For Azure services, you'll need to authenticate (e.g., using `az login` for `AzureCliCredential`) and set variables like `AZURE_AI_PROJECT_ENDPOINT` and `AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For smaller deployments or specific use cases, analyze your needs and install only the relevant sub-packages (e.g., `pip install agent-framework-core agent-framework-azure`).","message":"The command `pip install agent-framework` installs the main package along with all its sub-packages and integrations (e.g., Azure, Foundry, Purview, AG-UI). This can lead to a large dependency footprint. If you only need core functionality or specific integrations, consider installing individual sub-packages (e.g., `agent-framework-core`, `agent-framework-azure`) to keep dependencies lighter.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your development and deployment environments are using Python 3.10 or a later version.","message":"The Microsoft Agent Framework requires Python 3.10 or a newer version to run correctly.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[{"fix":"Verify the installed version of 'agent-framework' and ensure it includes 'use_instrumentation'. If not, update the package or consult the documentation for the correct function to use.","cause":"The 'use_instrumentation' function is not present in the 'agent_framework.observability' module, possibly due to an API change or version mismatch.","error":"ImportError: cannot import name 'use_instrumentation' from 'agent_framework.observability'"},{"fix":"Update the import statement to 'from azure.ai.agents.models import MCPTool'.","cause":"The 'MCPTool' has been relocated from 'azure.ai.projects.models' to 'azure.ai.agents.models' in the Azure AI SDK.","error":"ImportError: cannot import name 'MCPTool' from 'azure.ai.projects.models'"},{"fix":"Install the package using 'pip install agent-framework'.","cause":"The 'agent-framework' package is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'agent_framework'"},{"fix":"Ensure that the 'agent-framework' package is up to date and correctly installed. If the issue persists, consult the official documentation for the correct import path.","cause":"The 'AzureAIAgentClient' class is not available in the 'agent_framework.azure' module, possibly due to a version mismatch or incorrect installation.","error":"ImportError: cannot import name 'AzureAIAgentClient' from 'agent_framework.azure'"},{"fix":"Ensure that any necessary Foundry-specific extensions or sub-packages are installed. Consult the 'agent-framework' documentation for specific Foundry integration installation instructions, which might involve a command like `pip install agent-framework-foundry` or `pip install agent-framework --pre` if it's part of a pre-release bundle.","cause":"The 'foundry' submodule, which provides components like 'FoundryChatClient', is either not installed or its package path is incorrect. It often requires additional installation beyond the core 'agent-framework'.","error":"ModuleNotFoundError: No module named 'agent_framework.foundry'"}]}