Microsoft Agent Framework Lab

1.0.0b251024 · active · verified Thu Apr 16

agent-framework-lab provides experimental modules as part of the Microsoft Agent Framework, focusing on cutting-edge features, benchmarking, reinforcement learning, and research initiatives. It is currently in a beta development stage (1.0.0b251024) and is designed for developers building, learning to build, or exploring AI agents using modern frameworks and tooling.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates creating a basic agent using the core Microsoft Agent Framework and an OpenAI chat client. Modules from `agent-framework-lab` would typically extend or be integrated into such agents and workflows, for example, by providing specialized tools, evaluation components, or experimental agent behaviors.

import os
from agent_framework import Message
from agent_framework.openai import OpenAIChatClient
from agent_framework.core import Agent

# Ensure your OpenAI API key is set as an environment variable
# Or, if using Azure OpenAI, set AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, etc.
# Agent Framework does not automatically load .env files; use `load_dotenv()` if needed.
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY', '')

if not OPENAI_API_KEY:
    print("Warning: OPENAI_API_KEY environment variable not set. This example may fail.")

async def main():
    client = OpenAIChatClient(api_key=OPENAI_API_KEY)
    
    # Create a simple agent
    agent = Agent(
        name="MyFirstAgent",
        instructions="You are a helpful assistant.",
        client=client
    )
    
    # Send a message to the agent
    response = await agent.run(
        messages=[Message("user", "Hello, how are you?")]
    )
    
    print(f"Agent: {response.content[0].text}")

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

view raw JSON →