Skip to content

Commit 8c80dd2

Browse files
fix github copilot imports
1 parent 58d2b71 commit 8c80dd2

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

python/packages/github_copilot/agent_framework_github_copilot/_agent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Role,
2020
normalize_messages,
2121
)
22-
from agent_framework._tools import AIFunction, ToolProtocol
22+
from agent_framework._tools import FunctionTool, ToolProtocol
2323
from agent_framework._types import normalize_tools
2424
from agent_framework.exceptions import ServiceException, ServiceInitializationError
2525
from copilot import CopilotClient, CopilotSession
@@ -417,17 +417,17 @@ def _prepare_tools(
417417
for tool in tools:
418418
if isinstance(tool, ToolProtocol):
419419
match tool:
420-
case AIFunction():
421-
copilot_tools.append(self._ai_function_to_copilot_tool(tool)) # type: ignore
420+
case FunctionTool():
421+
copilot_tools.append(self._tool_to_copilot_tool(tool)) # type: ignore
422422
case _:
423423
logger.debug(f"Unsupported tool type: {type(tool)}")
424424
elif isinstance(tool, CopilotTool):
425425
copilot_tools.append(tool)
426426

427427
return copilot_tools
428428

429-
def _ai_function_to_copilot_tool(self, ai_func: AIFunction[Any, Any]) -> CopilotTool:
430-
"""Convert an AIFunction to a Copilot SDK tool."""
429+
def _tool_to_copilot_tool(self, ai_func: FunctionTool[Any, Any]) -> CopilotTool:
430+
"""Convert an FunctionTool to a Copilot SDK tool."""
431431

432432
async def handler(invocation: ToolInvocation) -> ToolResult:
433433
args = invocation.get("arguments", {})

python/packages/github_copilot/tests/test_github_copilot_agent.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
from uuid import uuid4
88

99
import pytest
10-
from agent_framework import AgentResponse, AgentResponseUpdate, AgentThread, ChatMessage, Content, Role
10+
from agent_framework import (
11+
AgentResponse,
12+
AgentResponseUpdate,
13+
AgentThread,
14+
ChatMessage,
15+
Content,
16+
Role,
17+
)
1118
from agent_framework.exceptions import ServiceException
1219
from copilot.generated.session_events import Data, SessionEvent, SessionEventType
1320

@@ -733,10 +740,10 @@ def test_mixed_tools_conversion(
733740
mock_client: MagicMock,
734741
) -> None:
735742
"""Test that mixed tool types are handled correctly."""
736-
from agent_framework._tools import ai_function
743+
from agent_framework import tool
737744
from copilot.types import Tool as CopilotTool
738745

739-
@ai_function
746+
@tool(approval_mode="never_require")
740747
def my_function(arg: str) -> str:
741748
"""A function tool."""
742749
return arg
@@ -754,7 +761,7 @@ async def tool_handler(invocation: Any) -> Any:
754761
result = agent._prepare_tools([my_function, copilot_tool]) # type: ignore
755762

756763
assert len(result) == 2
757-
# First tool is converted AIFunction
764+
# First tool is converted FunctionTool
758765
assert result[0].name == "my_function"
759766
# Second tool is CopilotTool passthrough
760767
assert result[1] == copilot_tool

0 commit comments

Comments
 (0)