Skip to content

Commit 19a9e13

Browse files
authored
.NET: Use GrpcEntityRunner instead of TaskEntityDispatcher (#2759)
* Use GrpcEntityRunner instead of TaskEntityDispatcher * Pin to Durable worker 1.11.0 * Set the invocation result * Update all Durable packages * Update changelog, rename dispatcher to encondedEntityRequest
1 parent b0a7a1f commit 19a9e13

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

dotnet/Directory.Packages.props

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@
112112
<PackageVersion Include="Microsoft.Bot.ObjectModel.PowerFx" Version="1.2025.1106.1" />
113113
<PackageVersion Include="Microsoft.PowerFx.Interpreter" Version="1.5.0-build.20251008-1002" />
114114
<!-- Durable Task -->
115-
<PackageVersion Include="Microsoft.DurableTask.Client" Version="1.16.2" />
116-
<PackageVersion Include="Microsoft.DurableTask.Client.AzureManaged" Version="1.16.2-preview.1" />
117-
<PackageVersion Include="Microsoft.DurableTask.Worker" Version="1.16.2" />
118-
<PackageVersion Include="Microsoft.DurableTask.Worker.AzureManaged" Version="1.16.2-preview.1" />
115+
<PackageVersion Include="Microsoft.DurableTask.Client" Version="1.18.0" />
116+
<PackageVersion Include="Microsoft.DurableTask.Client.AzureManaged" Version="1.18.0" />
117+
<PackageVersion Include="Microsoft.DurableTask.Worker" Version="1.18.0" />
118+
<PackageVersion Include="Microsoft.DurableTask.Worker.AzureManaged" Version="1.18.0" />
119119
<!-- Azure Functions -->
120120
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="2.50.0" />
121121
<PackageVersion Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.50.0" />
122-
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.9.0" />
123-
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged" Version="1.0.0" />
122+
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.11.0" />
123+
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged" Version="1.0.1" />
124124
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
125125
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.1.0" />
126126
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Mcp" Version="1.0.0" />

dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async ValueTask ExecuteAsync(FunctionContext context)
3232
}
3333

3434
HttpRequestData? httpRequestData = null;
35-
TaskEntityDispatcher? dispatcher = null;
35+
string? encodedEntityRequest = null;
3636
DurableTaskClient? durableTaskClient = null;
3737
ToolInvocationContext? mcpToolInvocationContext = null;
3838

@@ -43,8 +43,8 @@ public async ValueTask ExecuteAsync(FunctionContext context)
4343
case HttpRequestData request:
4444
httpRequestData = request;
4545
break;
46-
case TaskEntityDispatcher entityDispatcher:
47-
dispatcher = entityDispatcher;
46+
case string entityRequest:
47+
encodedEntityRequest = entityRequest;
4848
break;
4949
case DurableTaskClient client:
5050
durableTaskClient = client;
@@ -78,14 +78,14 @@ public async ValueTask ExecuteAsync(FunctionContext context)
7878

7979
if (context.FunctionDefinition.EntryPoint == BuiltInFunctions.RunAgentEntityFunctionEntryPoint)
8080
{
81-
if (dispatcher is null)
81+
if (encodedEntityRequest is null)
8282
{
8383
throw new InvalidOperationException($"Task entity dispatcher binding is missing for the invocation {context.InvocationId}.");
8484
}
8585

86-
await BuiltInFunctions.InvokeAgentAsync(
87-
dispatcher,
86+
context.GetInvocationResult().Value = await BuiltInFunctions.InvokeAgentAsync(
8887
durableTaskClient,
88+
encodedEntityRequest,
8989
context);
9090
return;
9191
}

dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctions.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Azure.Functions.Worker.Extensions.Mcp;
88
using Microsoft.Azure.Functions.Worker.Http;
99
using Microsoft.DurableTask.Client;
10+
using Microsoft.DurableTask.Worker.Grpc;
1011
using Microsoft.Extensions.AI;
1112
using Microsoft.Extensions.DependencyInjection;
1213

@@ -22,14 +23,14 @@ internal static class BuiltInFunctions
2223
internal static readonly string RunAgentMcpToolFunctionEntryPoint = $"{typeof(BuiltInFunctions).FullName!}.{nameof(RunMcpToolAsync)}";
2324

2425
// Exposed as an entity trigger via AgentFunctionsProvider
25-
public static async Task InvokeAgentAsync(
26-
[EntityTrigger] TaskEntityDispatcher dispatcher,
26+
public static Task<string> InvokeAgentAsync(
2727
[DurableClient] DurableTaskClient client,
28+
string encodedEntityRequest,
2829
FunctionContext functionContext)
2930
{
3031
// This should never be null except if the function trigger is misconfigured.
31-
ArgumentNullException.ThrowIfNull(dispatcher);
3232
ArgumentNullException.ThrowIfNull(client);
33+
ArgumentNullException.ThrowIfNull(encodedEntityRequest);
3334
ArgumentNullException.ThrowIfNull(functionContext);
3435

3536
// Create a combined service provider that includes both the existing services
@@ -38,7 +39,8 @@ public static async Task InvokeAgentAsync(
3839

3940
// This method is the entry point for the agent entity.
4041
// It will be invoked by the Azure Functions runtime when the entity is called.
41-
await dispatcher.DispatchAsync(new AgentEntity(combinedServiceProvider, functionContext.CancellationToken));
42+
AgentEntity entity = new(combinedServiceProvider, functionContext.CancellationToken);
43+
return GrpcEntityRunner.LoadAndRunAsync(encodedEntityRequest, entity, combinedServiceProvider);
4244
}
4345

4446
public static async Task<HttpResponseData> RunAgentHttpAsync(

dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release History
22

3+
## <version>
4+
5+
- Addressed incompatibility issue with `Microsoft.Azure.Functions.Worker.Extensions.DurableTask` >= 1.11.0 ([#2759](https://github.com/microsoft/agent-framework/pull/2759))
6+
37
## v1.0.0-preview.251125.1
48

59
- Added support for .NET 10 ([#2128](https://github.com/microsoft/agent-framework/pull/2128))

dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/DurableAgentFunctionMetadataTransformer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static DefaultFunctionMetadata CreateAgentTrigger(string name)
7373
Language = "dotnet-isolated",
7474
RawBindings =
7575
[
76-
"""{"name":"dispatcher","type":"entityTrigger","direction":"In"}""",
76+
"""{"name":"encodedEntityRequest","type":"entityTrigger","direction":"In"}""",
7777
"""{"name":"client","type":"durableClient","direction":"In"}"""
7878
],
7979
EntryPoint = BuiltInFunctions.RunAgentEntityFunctionEntryPoint,

0 commit comments

Comments
 (0)