Microsoft Agent Framework: Python agent tutorial

Learn to build a Python expense agent with Microsoft Agent Framework, GPT-4.1 in Foundry, and a custom tool that the framework invokes.

Player not loading? Watch on YouTube

This AI-103 lesson introduces Microsoft Agent Framework and walks through a Python expense-claim agent. The speaker describes the framework as a successor to Semantic Kernel and AutoGen, with a common interface for model providers, conversation management, and workflow orchestration.

The explanation covers provider flexibility, including the option of a local LLM. The demonstration uses GPT-4.1 deployed in Microsoft Foundry through an Azure OpenAI responses client. Although the application code runs locally, this example relies on an Azure model endpoint; it does not demonstrate offline inference.

The setup uses a project endpoint, model deployment name, and Azure CLI credentials. The speaker warns that this credential choice would need to change for a web app, where he recommends managed identity.

The custom tool accepts expense-claim details and prints them to the screen rather than sending an email. A Python tool decorator registers the function, and the framework handles invocation after the model requests it. The example disables approval for this demonstration tool. Its main lesson is how to supply instructions and tools to an AI agent without writing the dispatch loop yourself. A closing knowledge check identifies the agent thread as the component that manages conversation state and stores messages.