Skip to content

.NET: Support InvokeFunctionTool for declarative workflows#4014

Open
peibekwe wants to merge 15 commits intomainfrom
peibekwe/declarative-invoke-function-tool
Open

.NET: Support InvokeFunctionTool for declarative workflows#4014
peibekwe wants to merge 15 commits intomainfrom
peibekwe/declarative-invoke-function-tool

Conversation

@peibekwe
Copy link
Contributor

@peibekwe peibekwe commented Feb 17, 2026

Motivation and Context

This implementation supports the InvokeFunctionTool action in a declarative workflow to call functions directly from the workflow without going through an AI agent first. This is different from the standard InvokeAzureAgent pattern where the AI decides which functions to call based on the conversation.

This PR includes tests and samples for the new action type and sample yaml implementations.

Fixes #3377
Fixes #3414

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@peibekwe peibekwe self-assigned this Feb 17, 2026
@markwallace-microsoft markwallace-microsoft added .NET workflows Related to Workflows in agent-framework labels Feb 17, 2026
@github-actions github-actions bot changed the title Support InvokeFunctionTool for declarative workflows .NET: Support InvokeFunctionTool for declarative workflows Feb 17, 2026
@peibekwe peibekwe requested a review from crickman February 17, 2026 22:45
@peibekwe peibekwe marked this pull request as ready for review February 17, 2026 22:46
Copilot AI review requested due to automatic review settings February 17, 2026 22:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements support for the InvokeFunctionTool action in declarative workflows, enabling workflows to call functions directly without going through an AI agent first. This is a new capability that allows pre-fetching data or executing operations before AI involvement.

Changes:

  • Adds InvokeFunctionToolExecutor to execute function tool invocations in workflows
  • Implements workflow visitor pattern to integrate InvokeFunctionTool into the workflow execution model
  • Includes comprehensive unit and integration tests
  • Provides sample implementation demonstrating function tool invocation with and without approval requirements
  • Updates package dependencies (Microsoft.Agents.ObjectModel from 2026.2.2.1 to 2026.2.3.1, PowerFx from 1.5.0 to 1.8.1)

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/InvokeFunctionToolExecutor.cs Core executor implementation handling function tool invocation, approval requests, result capture, and conversation integration
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowActionVisitor.cs Visitor pattern integration to wire up InvokeFunctionTool in workflow execution graph
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowTemplateVisitor.cs Marks InvokeFunctionTool as not supported in template workflows
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/InvokeFunctionToolExecutorTest.cs Unit tests covering executor functionality including approval, arguments, conversation ID handling
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/InvokeFunctionToolWorkflowTest.cs Integration tests validating end-to-end workflow execution with function tools
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Workflows/InvokeFunctionTool.yaml Test workflow demonstrating function tool invocation
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Workflows/InvokeFunctionToolWithApproval.yaml Test workflow demonstrating function tool invocation with approval requirement
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Framework/WorkflowHarness.cs Fixes checkpoint tracking and request counting for workflow resume operations
dotnet/samples/GettingStarted/Workflows/Declarative/InvokeFunctionTool/Program.cs Sample program demonstrating InvokeFunctionTool usage
dotnet/samples/GettingStarted/Workflows/Declarative/InvokeFunctionTool/MenuPlugin.cs Sample plugin with menu functions for demonstration
dotnet/samples/GettingStarted/Workflows/Declarative/InvokeFunctionTool/InvokeFunctionTool.yaml Sample workflow YAML file
dotnet/samples/GettingStarted/Workflows/Declarative/InvokeFunctionTool/InvokeFunctionTool.csproj Project configuration for sample
dotnet/agent-framework-dotnet.slnx Adds new sample project to solution
dotnet/Directory.Packages.props Updates package versions for ObjectModel and PowerFx dependencies

ChatMessage requestMessage = new(ChatRole.Tool, [functionCall]);

// If approval is required, add user input request content
if (requireApproval)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if approval and execution need to be separate turns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but I think it makes sense for the client to handle both however they see fit. We can get this in and get feedback from the service team and other users and change if needed.

{
try
{
JsonDocument jsonDocument = JsonDocument.Parse(jsonString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be disposed?

Suggested change
JsonDocument jsonDocument = JsonDocument.Parse(jsonString);
using JsonDocument jsonDocument = JsonDocument.Parse(jsonString);

await this.AssignAsync(this.Model.Output.Result?.Path, objectProperties.ToFormula(), context).ConfigureAwait(false);
return;
}
catch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we narrow the catch to JsonException?

Suggested change
catch
catch (JsonException)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

declarative-workflow .NET workflows Related to Workflows in agent-framework

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

.NET Workflows - Create InvokeFunctionTool sample .NET Workflows - Implement InvokeFunctionTools support in Declarative workflow

4 participants

Comments