* Add AgentWorkflowBuilder group chat
And fix a variety of issues along the way:
- Use DateTime{Offset}.UtcNow rather than Now
- AIAgentHostExecutor shouldn't be publishing empty messages
- Sequential workflows should be flowing all history and not just the output from the previous agent as the input into the next agent
- Renamed some of the new agent workflow methods... still not super happy with the shape, though
- Simplified handoffs builder, e.g. using a hashset with a custom comparer instead of a dictionary
- Improved multi-service use by trying to change assistant->user role for messages created by other agents
- Changed MessageMerger to rely on M.E.AI's coalescing more and to avoid empty contents / text
- Ensured that messages from ChatClientAgent include MessageId and CreatedAt timestamps
- Avoided including instructions for agents in a handoff workflow that don't have any handoffs
- Removed the unnecessary end function in handoffs
- Improved naming of executors to include agent name for debuggability
- Use "N" formatting with Guid.ToString everywhere, to avoid the unnecessary extra dash character which is also not valid in various places (like function tool names)
- Replace `params T[]` with `params IEnumerable<T>` to make public APIs more flexible in what they consume
* Address feedback
- Fix unintentional provider change in sample
Getting started with agents
The getting started with agents samples demonstrate the fundamental concepts and functionalities of single agents and can be used with any agent type.
While the functionality can be used with any agent type, these samples use Azure OpenAI as the AI provider and use ChatCompletion as the type of service.
For other samples that demonstrate how to create and configure each type of agent that come with the agent framework, see the How to create an agent for each provider samples.
Getting started with agents prerequisites
Before you begin, ensure you have the following prerequisites:
- .NET 8.0 SDK or later
- Azure OpenAI service endpoint and deployment configured
- Azure CLI installed and authenticated (for Azure credential authentication)
- User has the
Cognitive Services OpenAI Contributorrole for the Azure OpenAI resource.
Note: These samples use Azure OpenAI models. For more information, see how to deploy Azure OpenAI models with Azure AI Foundry.
Note: These samples use Azure CLI credentials for authentication. Make sure you're logged in with az login and have access to the Azure OpenAI resource and have the Cognitive Services OpenAI Contributor role. For more information, see the Azure CLI documentation.
Samples
| Sample | Description |
|---|---|
| Running a simple agent | This sample demonstrates how to create and run a basic agent with instructions |
| Multi-turn conversation with a simple agent | This sample demonstrates how to implement a multi-turn conversation with a simple agent |
| Using function tools with a simple agent | This sample demonstrates how to use function tools with a simple agent |
| Using function tools with approvals | This sample demonstrates how to use function tools where approvals require human in the loop approvals before execution |
| Structured output with a simple agent | This sample demonstrates how to use structured output with a simple agent |
| Persisted conversations with a simple agent | This sample demonstrates how to persist conversations and reload them later. This is useful for cases where an agent is hosted in a stateless service |
| 3rd party thread storage with a simple agent | This sample demonstrates how to store conversation history in a 3rd party storage solution |
| Telemetry with a simple agent | This sample demonstrates how to add telemetry to a simple agent |
| Dependency injection with a simple agent | This sample demonstrates how to add and resolve an agent with a dependency injection container |
| Exposing a simple agent as MCP tool | This sample demonstrates how to expose an agent as an MCP tool |
| Using images with a simple agent | This sample demonstrates how to use image multi-modality with an AI agent |
| Exposing a simple agent as a function tool | This sample demonstrates how to expose an agent as a function tool |
| Using memory with an agent | This sample demonstrates how to create a simple memory component and use it with an agent |
Running the samples from the console
To run the samples, navigate to the desired sample directory, e.g.
cd Agents_Step01_Running
Set the following environment variables:
$env:AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/" # Replace with your Azure OpenAI resource endpoint
$env:AZURE_OPENAI_DEPLOYMENT_NAME="gpt-4o-mini" # Optional, defaults to gpt-4o-mini
If the variables are not set, you will be prompted for the values when running the samples.
Execute the following command to build the sample:
dotnet build
Execute the following command to run the sample:
dotnet run --no-build
Or just build and run in one step:
dotnet run
Running the samples from Visual Studio
Open the solution in Visual Studio and set the desired sample project as the startup project. Then, run the project using the built-in debugger or by pressing F5.
You will be prompted for any required environment variables if they are not already set.