diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index 427ea6c3d3..95d35508e1 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -112,15 +112,15 @@ - - - - + + + + - - + + diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs index 10b1bc54ff..fa0b9ef287 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctionExecutor.cs @@ -32,7 +32,7 @@ public async ValueTask ExecuteAsync(FunctionContext context) } HttpRequestData? httpRequestData = null; - TaskEntityDispatcher? dispatcher = null; + string? encodedEntityRequest = null; DurableTaskClient? durableTaskClient = null; ToolInvocationContext? mcpToolInvocationContext = null; @@ -43,8 +43,8 @@ public async ValueTask ExecuteAsync(FunctionContext context) case HttpRequestData request: httpRequestData = request; break; - case TaskEntityDispatcher entityDispatcher: - dispatcher = entityDispatcher; + case string entityRequest: + encodedEntityRequest = entityRequest; break; case DurableTaskClient client: durableTaskClient = client; @@ -78,14 +78,14 @@ public async ValueTask ExecuteAsync(FunctionContext context) if (context.FunctionDefinition.EntryPoint == BuiltInFunctions.RunAgentEntityFunctionEntryPoint) { - if (dispatcher is null) + if (encodedEntityRequest is null) { throw new InvalidOperationException($"Task entity dispatcher binding is missing for the invocation {context.InvocationId}."); } - await BuiltInFunctions.InvokeAgentAsync( - dispatcher, + context.GetInvocationResult().Value = await BuiltInFunctions.InvokeAgentAsync( durableTaskClient, + encodedEntityRequest, context); return; } diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctions.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctions.cs index ebd378ac3b..3d824994e9 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/BuiltInFunctions.cs @@ -7,6 +7,7 @@ using Microsoft.Azure.Functions.Worker.Extensions.Mcp; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.DurableTask.Client; +using Microsoft.DurableTask.Worker.Grpc; using Microsoft.Extensions.AI; using Microsoft.Extensions.DependencyInjection; @@ -22,14 +23,14 @@ internal static class BuiltInFunctions internal static readonly string RunAgentMcpToolFunctionEntryPoint = $"{typeof(BuiltInFunctions).FullName!}.{nameof(RunMcpToolAsync)}"; // Exposed as an entity trigger via AgentFunctionsProvider - public static async Task InvokeAgentAsync( - [EntityTrigger] TaskEntityDispatcher dispatcher, + public static Task InvokeAgentAsync( [DurableClient] DurableTaskClient client, + string encodedEntityRequest, FunctionContext functionContext) { // This should never be null except if the function trigger is misconfigured. - ArgumentNullException.ThrowIfNull(dispatcher); ArgumentNullException.ThrowIfNull(client); + ArgumentNullException.ThrowIfNull(encodedEntityRequest); ArgumentNullException.ThrowIfNull(functionContext); // Create a combined service provider that includes both the existing services @@ -38,7 +39,8 @@ public static async Task InvokeAgentAsync( // This method is the entry point for the agent entity. // It will be invoked by the Azure Functions runtime when the entity is called. - await dispatcher.DispatchAsync(new AgentEntity(combinedServiceProvider, functionContext.CancellationToken)); + AgentEntity entity = new(combinedServiceProvider, functionContext.CancellationToken); + return GrpcEntityRunner.LoadAndRunAsync(encodedEntityRequest, entity, combinedServiceProvider); } public static async Task RunAgentHttpAsync( diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md index d32f4bb0e2..a606629dc2 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## + +- Addressed incompatibility issue with `Microsoft.Azure.Functions.Worker.Extensions.DurableTask` >= 1.11.0 ([#2759](https://github.com/microsoft/agent-framework/pull/2759)) + ## v1.0.0-preview.251125.1 - Added support for .NET 10 ([#2128](https://github.com/microsoft/agent-framework/pull/2128)) diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/DurableAgentFunctionMetadataTransformer.cs b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/DurableAgentFunctionMetadataTransformer.cs index cce8fbd1b0..f626db2a90 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/DurableAgentFunctionMetadataTransformer.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting.AzureFunctions/DurableAgentFunctionMetadataTransformer.cs @@ -73,7 +73,7 @@ private static DefaultFunctionMetadata CreateAgentTrigger(string name) Language = "dotnet-isolated", RawBindings = [ - """{"name":"dispatcher","type":"entityTrigger","direction":"In"}""", + """{"name":"encodedEntityRequest","type":"entityTrigger","direction":"In"}""", """{"name":"client","type":"durableClient","direction":"In"}""" ], EntryPoint = BuiltInFunctions.RunAgentEntityFunctionEntryPoint,