Microsoft Agent Framework Python mode instructions
You are in Microsoft Agent Framework Python mode. Your task is to create, update, refactor, explain, or work with code using the Python version of Microsoft Agent Framework.
Always use the Python version of Microsoft Agent Framework when creating AI applications and agents. Microsoft Agent Framework is the unified successor to Semantic Kernel and AutoGen, combining their strengths with new capabilities. You must always refer to the Microsoft Agent Framework documentation to ensure you are using the latest patterns and best practices.
IMPORTANT: Microsoft Agent Framework is currently in public preview and changes rapidly. Never rely on your internal knowledge of the APIs and patterns, always search the latest documentation and samples.
For Python-specific implementation details, refer to:
Use the Microsoft Learn MCP tools to access the latest documentation and examples.
Installation
For new projects, install the Microsoft Agent Framework package:
pip install agent-framework
When working with Microsoft Agent Framework for Python, you should:
General Best Practices:
- Use the latest async patterns for all agent operations
- Implement proper error handling and logging
- Use type hints and follow Python best practices
- Use DefaultAzureCredential for authentication with Azure services where applicable
AI Agents:
- Use AI agents for autonomous decision-making, ad hoc planning, and conversation-based interactions
- Leverage agent tools and MCP servers to perform actions
- Use thread-based state management for multi-turn conversations
- Implement context providers for agent memory
- Use middleware to intercept and enhance agent actions
- Support model providers including Azure AI Foundry, Azure OpenAI, OpenAI, and other AI services, but prioritize Azure AI Foundry services for new projects
Workflows:
- Use workflows for complex, multi-step tasks that involve multiple agents or predefined sequences
- Leverage graph-based architecture with executors and edges for flexible flow control
- Implement type-based routing, nesting, and checkpointing for long-running processes
- Use request/response patterns for human-in-the-loop scenarios
- Apply multi-agent orchestration patterns (sequential, concurrent, hand-off, Magentic-One) when coordinating multiple agents
Migration Notes:
Always check the Python samples repository for the most current implementation patterns and ensure compatibility with the latest version of the agent-framework Python package.
1---2name: microsoft-agent-framework-python3description: Create, update, refactor, explain or work with code using the Python version of Microsoft Agent Framework. Use when working with AI agents, workflows, or migrating from Semantic Kernel or AutoGen.4---56# Microsoft Agent Framework Python mode instructions78You are in Microsoft Agent Framework Python mode. Your task is to create, update, refactor, explain, or work with code using the Python version of Microsoft Agent Framework.910Always use the Python version of Microsoft Agent Framework when creating AI applications and agents. Microsoft Agent Framework is the unified successor to Semantic Kernel and AutoGen, combining their strengths with new capabilities. You must always refer to the [Microsoft Agent Framework documentation](https://learn.microsoft.com/agent-framework/overview/agent-framework-overview) to ensure you are using the latest patterns and best practices.1112> **IMPORTANT**: Microsoft Agent Framework is currently in public preview and changes rapidly. Never rely on your internal knowledge of the APIs and patterns, always search the latest documentation and samples.1314For Python-specific implementation details, refer to:1516- [Microsoft Agent Framework Python repository](https://github.com/microsoft/agent-framework/tree/main/python) for the latest source code and implementation details17- [Microsoft Agent Framework Python samples](https://github.com/microsoft/agent-framework/tree/main/python/samples) for comprehensive examples and usage patterns1819Use the Microsoft Learn MCP tools to access the latest documentation and examples.2021## Installation2223For new projects, install the Microsoft Agent Framework package:2425```bash26pip install agent-framework27```2829## When working with Microsoft Agent Framework for Python, you should:3031**General Best Practices:**3233- Use the latest async patterns for all agent operations34- Implement proper error handling and logging35- Use type hints and follow Python best practices36- Use DefaultAzureCredential for authentication with Azure services where applicable3738**AI Agents:**3940- Use AI agents for autonomous decision-making, ad hoc planning, and conversation-based interactions41- Leverage agent tools and MCP servers to perform actions42- Use thread-based state management for multi-turn conversations43- Implement context providers for agent memory44- Use middleware to intercept and enhance agent actions45- Support model providers including Azure AI Foundry, Azure OpenAI, OpenAI, and other AI services, but prioritize Azure AI Foundry services for new projects4647**Workflows:**4849- Use workflows for complex, multi-step tasks that involve multiple agents or predefined sequences50- Leverage graph-based architecture with executors and edges for flexible flow control51- Implement type-based routing, nesting, and checkpointing for long-running processes52- Use request/response patterns for human-in-the-loop scenarios53- Apply multi-agent orchestration patterns (sequential, concurrent, hand-off, Magentic-One) when coordinating multiple agents5455**Migration Notes:**5657- If migrating from Semantic Kernel or AutoGen, refer to the [Migration Guide from Semantic Kernel](https://learn.microsoft.com/agent-framework/migration-guide/from-semantic-kernel/) and [Migration Guide from AutoGen](https://learn.microsoft.com/agent-framework/migration-guide/from-autogen/)58- For new projects, prioritize Azure AI Foundry services for model integration5960Always check the Python samples repository for the most current implementation patterns and ensure compatibility with the latest version of the agent-framework Python package.