Python: [BREAKING] changed AIFunction to FunctionTool and @ai_function to @tool (#3413)

* changed AIFunction to FunctionTool and @ai_function to @tool

* test and mypy fixes

* mypy fix

* switch function tool to always_require

* fix noop

* fix github copilot imports

* test fixes

* fix ollama test

* fixes for tests

* fix tests

* reverted change to always_require and extended timeout

* fix test
This commit is contained in:
Eduard van Valkenburg
2026-01-28 15:53:53 +01:00
committed by GitHub
Unverified
parent 15b43f2abe
commit a7d924a7d2
255 changed files with 1202 additions and 1290 deletions
@@ -14,7 +14,7 @@ from agent_framework import (
FunctionApprovalResponseContent,
WorkflowBuilder,
WorkflowContext,
ai_function,
tool,
executor,
handler,
)
@@ -53,14 +53,15 @@ Prerequisites:
"""
@ai_function
# NOTE: approval_mode="never_require" is for sample brevity. Use "always_require" in production; see samples/getting_started/tools/function_tool_with_approval.py and samples/getting_started/tools/function_tool_with_approval_and_threads.py.
@tool(approval_mode="never_require")
def get_current_date() -> str:
"""Get the current date in YYYY-MM-DD format."""
# For demonstration purposes, we return a fixed date.
return "2025-11-07"
@ai_function
@tool(approval_mode="never_require")
def get_team_members_email_addresses() -> list[dict[str, str]]:
"""Get the email addresses of team members."""
# In a real implementation, this might query a database or directory service.
@@ -92,7 +93,7 @@ def get_team_members_email_addresses() -> list[dict[str, str]]:
]
@ai_function
@tool(approval_mode="never_require")
def get_my_information() -> dict[str, str]:
"""Get my personal information."""
return {
@@ -103,7 +104,7 @@ def get_my_information() -> dict[str, str]:
}
@ai_function(approval_mode="always_require")
@tool(approval_mode="always_require")
async def read_historical_email_data(
email_address: Annotated[str, "The email address to read historical data from"],
start_date: Annotated[str, "The start date in YYYY-MM-DD format"],
@@ -165,7 +166,7 @@ async def read_historical_email_data(
return [email for email in emails if start_date <= email["date"] <= end_date]
@ai_function(approval_mode="always_require")
@tool(approval_mode="always_require")
async def send_email(
to: Annotated[str, "The recipient email address"],
subject: Annotated[str, "The email subject"],
@@ -33,6 +33,7 @@ from agent_framework import (
WorkflowOutputEvent,
WorkflowRunState,
WorkflowStatusEvent,
tool,
)
from agent_framework._workflows._agent_executor import AgentExecutorResponse
from agent_framework.azure import AzureOpenAIChatClient
@@ -35,6 +35,7 @@ from agent_framework import (
WorkflowOutputEvent,
WorkflowRunState,
WorkflowStatusEvent,
tool,
)
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
@@ -18,6 +18,7 @@ from agent_framework import (
WorkflowStatusEvent, # Event emitted on run state changes
handler,
response_handler, # Decorator to expose an Executor method as a step
tool,
)
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
@@ -32,6 +32,7 @@ from agent_framework import (
WorkflowOutputEvent,
WorkflowRunState,
WorkflowStatusEvent,
tool,
)
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential