Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Dapr Conversation building block routes model inference through a Dapr sidecar and exposes an IChatClient that can back an Agent Framework .NET agent. The model provider and credentials are configured in the Dapr Conversation component rather than directly in the agent process.
Prerequisites
- .NET 10 or later.
- Docker and the Dapr CLI.
- A configured Dapr Conversation component, such as an Ollama-backed component.
Install the packages
dotnet add package Dapr.AI.Microsoft.Extensions
dotnet add package Microsoft.Agents.AI --prerelease
Configuration
DAPR_GRPC_ENDPOINT="http://localhost:3501"
DAPR_GRPC_ENDPOINT is optional and defaults to http://localhost:3501. Set ConversationComponentName in application code to the name of the Dapr Conversation component, such as ollama.
Create a Dapr-backed agent
Configure the Dapr sidecar endpoint and Conversation component through dependency injection, resolve the IChatClient, and convert it to an agent.
// the sidecar (see this sample's README). Override it with the DAPR_GRPC_ENDPOINT environment
// variable if you run the sidecar on a different port.
var daprGrpcEndpoint = Environment.GetEnvironmentVariable("DAPR_GRPC_ENDPOINT") ?? "http://localhost:3501";
// Register the Dapr Conversation client with dependency injection.
var app = Host.CreateDefaultBuilder()
.ConfigureServices(services =>
{
// Configure the gRPC endpoint for the Dapr sidecar.
services.AddDaprConversationClient((_, builder) => builder.UseGrpcEndpoint(daprGrpcEndpoint));
// Provide the name of the Conversation component loaded in the sidecar to use.
services.AddDaprChatClient(opt => opt.ConversationComponentName = "ollama");
}).Build();
// Get an instance of the Dapr chat client from the dependency injection container.
using var scope = app.Services.CreateScope();
var daprChatClient = scope.ServiceProvider.GetRequiredService<IChatClient>();
// Use this chat client to construct an AIAgent.
AIAgent agent = daprChatClient.AsAIAgent(instructions: "You are good at telling jokes.", name: "Joker");
// Invoke the agent and output the text result.
Console.WriteLine(await agent.RunAsync("Tell me a joke about a pirate."));
Provider capabilities depend on the Dapr Conversation component and the model behind it.
Tools
Tool support is inherited from the configured Dapr Conversation component and model.
| Tool | Status | Notes |
|---|---|---|
| Function Tools | Varies | Requires function-calling support from the configured component and model. |
| Tool Approval | Varies | Available when the model produces function-tool calls. |
| Provider-hosted tools | ❌ | Dapr doesn't add a separate Agent Framework hosted-tool surface. |
| Local MCP Tools | ✅ | Runs in the application process. |