Microsoft Agent Framework Core

1.0.1 · active · verified Sun Apr 12

Microsoft Agent Framework Core (version 1.0.1) is the foundational Python package for building, orchestrating, and deploying AI agents and multi-agent workflows. It provides core abstractions and implementations, serving as the stable and production-ready base for the broader Microsoft Agent Framework which also supports .NET. The framework offers enterprise-grade multi-agent orchestration, multi-provider model support, and cross-runtime interoperability. It maintains an active development and release cadence, with version 1.0.0 released in early April 2026 and subsequent patches.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create and run a simple agent using the `agent-framework` with an OpenAI chat client. It requires setting the `OPENAI_API_KEY` environment variable. For Azure OpenAI, `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_DEPLOYMENT_NAME` would be needed along with Azure credentials.

import asyncio
import os
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient

async def main():
    # Ensure OPENAI_API_KEY environment variable is set
    # For Azure OpenAI, set AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_DEPLOYMENT_NAME
    openai_api_key = os.environ.get("OPENAI_API_KEY", "YOUR_OPENAI_API_KEY_HERE")

    if not openai_api_key or openai_api_key == "YOUR_OPENAI_API_KEY_HERE":
        print("Please set the OPENAI_API_KEY environment variable or replace the placeholder.")
        return

    try:
        client = OpenAIChatClient(api_key=openai_api_key)
        agent = Agent(
            client=client,
            name="HelloAgent",
            instructions="You are a friendly assistant that writes haikus about nature."
        )
        print("\n--- Running Agent ---")
        result = await agent.run("Write a haiku about a blooming spring flower.")
        print(f"Agent Response: {result}")

    except Exception as e:
        print(f"An error occurred: {e}")
        print("Ensure your API key is valid and required environment variables are set for the chosen client.")

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

view raw JSON →