-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[BREAKING] Python: Add InvokeFunctionTool action for declarative workflows #3716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[BREAKING] Python: Add InvokeFunctionTool action for declarative workflows #3716
Conversation
There was a problem hiding this 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
InvokeFunctionToolaction 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
BaseToolExecutorabstract 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 |
Motivation and Context
InvokeFunctionToolaction kind that invokes registered Python functions from declarative YAML workflowsWorkflowFactory.register_tool()API for registering sync/async functions by namerequireApproval), and structured output (result + ChatMessage history)BaseToolExecutorabstract class for future tool types (MCP, API, etc.)invoke_function_toolandagent_to_function_toolDescription
Contribution Checklist