Skip to content

Python: Add InvokeFunctionTool action for declarative workflows#3716

Open
moonbox3 wants to merge 4 commits intomicrosoft:mainfrom
moonbox3:declarative-workflow-invoke-function-tool
Open

Python: Add InvokeFunctionTool action for declarative workflows#3716
moonbox3 wants to merge 4 commits intomicrosoft:mainfrom
moonbox3:declarative-workflow-invoke-function-tool

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Feb 6, 2026

Motivation and Context

  • Add InvokeFunctionTool action kind that invokes registered Python functions from declarative YAML workflows
  • Add WorkflowFactory.register_tool() API for registering sync/async functions by name
  • Support expression-based arguments, optional approval flow (requireApproval), and structured output (result + ChatMessage history)
  • Add BaseToolExecutor abstract class for future tool types (MCP, API, etc.)
  • Add two samples: invoke_function_tool and agent_to_function_tool

Description

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.

@moonbox3 moonbox3 self-assigned this Feb 6, 2026
Copilot AI review requested due to automatic review settings February 6, 2026 02:31
@moonbox3 moonbox3 added python workflows Related to Workflows in agent-framework declarative-workflow labels Feb 6, 2026
@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Feb 6, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 6, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL16515199787% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
4216 225 💤 0 ❌ 0 🔥 1m 10s ⏱️

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 adds comprehensive support for invoking Python functions as tools in declarative YAML workflows through a new InvokeFunctionTool action. The implementation introduces a well-designed BaseToolExecutor abstract class that provides extensibility for future tool types (MCP, API, etc.) while maintaining consistency with existing workflow patterns.

Changes:

  • Added InvokeFunctionTool action executor with support for sync/async functions, expression-based arguments, optional approval flow, and structured output formatting
  • Added WorkflowFactory.register_tool() fluent API for registering Python functions by name
  • Introduced BaseToolExecutor abstract base class that encapsulates common tool invocation patterns (registry lookup, approval flow, output formatting, error handling)
  • Added comprehensive test coverage (88% for declarative package) including tests for function invocation, error handling, approval flow, and factory registration
  • Added two sample workflows demonstrating basic function invocation and agent-to-function chaining patterns

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
_executors_tools.py New module with BaseToolExecutor and InvokeFunctionToolExecutor implementations
_factory.py Added register_tool() method and _tools registry to WorkflowFactory
_declarative_builder.py Integrated InvokeFunctionToolExecutor into builder with tool registry support
__init__.py Exported new tool-related classes and constants
test_function_tool_executor.py Comprehensive test suite for function tool executor (716 lines)
test_workflow_factory.py Added tests for tool registration and fluent API
test_workflow_handlers.py Extended tests for various action handlers (695 new lines)
test_workflow_state.py Added 338 lines of state evaluation tests
test_powerfx_functions.py Added 443 lines of PowerFx function tests
test_declarative_loader.py Added 423 lines of loader and factory tests
test_actions_agents.py New test file (885 lines) for agent action handlers
invoke_function_tool/ Sample workflow demonstrating basic function tool invocation
agent_to_function_tool/ Sample workflow demonstrating agent-to-function tool chaining
README.md Updated documentation with InvokeFunctionTool action description

@moonbox3 moonbox3 moved this to In Review in Agent Framework Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

declarative-workflow documentation Improvements or additions to documentation python workflows Related to Workflows in agent-framework

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants