Skip to content

Commit d5e240b

Browse files
moonbox3Copilot
andauthored
[BREAKING] Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types (#4551)
* Update github_copilot package for github-copilot-sdk>=0.1.32 (#4549) - Update requires-python from >=3.10 to >=3.11 - Remove Python 3.10 classifier - Update mypy python_version to 3.11 - Update dependency to github-copilot-sdk>=0.1.32 - Fix ToolResult API: use snake_case kwargs (text_result_for_llm, result_type) instead of camelCase (textResultForLlm, resultType) - Update test assertions to use attribute access on ToolResult - Add ToolResult type assertions to tool handler tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix tests to use ToolInvocation dataclass instead of plain dict (#4549) Update test_github_copilot_agent.py to pass ToolInvocation objects to tool handlers instead of plain dicts, matching the github-copilot-sdk>=0.1.32 API where ToolInvocation is a dataclass with an .arguments attribute. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add regression tests for ToolInvocation contract (#4549) Add tests to lock in the new ToolInvocation-based calling convention: - test_tool_handler_rejects_raw_dict_invocation: verifies passing a raw dict (old calling convention) raises TypeError/AttributeError - test_tool_handler_with_empty_arguments: verifies ToolInvocation with empty arguments works correctly for no-arg tools Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Revert requires-python to >=3.10 to avoid breaking CI (#4549) The repo CI runs with Python 3.10 (uv sync --all-packages) and all other packages require >=3.10. Raising this package to >=3.11 would break the shared install flow. The SDK dependency version constraint (>=0.1.32) will enforce any Python version requirement from the SDK itself. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix min Python version for github_copilot package to >=3.11 github-copilot-sdk>=0.1.32 requires Python>=3.11, which conflicts with the package's declared >=3.10 minimum, breaking uv sync. * Bump py version for GH workflows to 3.11, exclude GHCP sdk from 3.10 items * Fix uv command * Fixes * Update samples --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1ca43f9 commit d5e240b

17 files changed

Lines changed: 169 additions & 984 deletions

.github/actions/python-setup/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
os:
99
description: The operating system to set up
1010
required: true
11+
exclude-packages:
12+
description: Space-separated list of packages to exclude from uv sync
13+
required: false
14+
default: ''
1115

1216
runs:
1317
using: "composite"
@@ -19,6 +23,20 @@ runs:
1923
enable-cache: true
2024
cache-suffix: ${{ inputs.os }}-${{ inputs.python-version }}
2125
cache-dependency-glob: "**/uv.lock"
26+
- name: Exclude incompatible workspace packages
27+
if: ${{ inputs.exclude-packages != '' }}
28+
shell: bash
29+
run: |
30+
for pkg in ${{ inputs.exclude-packages }}; do
31+
for f in python/packages/*/pyproject.toml; do
32+
if grep -q "name = \"$pkg\"" "$f"; then
33+
pkg_dir=$(dirname "$f" | sed 's|python/||')
34+
echo "Excluding workspace package: $pkg ($pkg_dir)"
35+
sed -i.bak '/\[tool\.uv\.workspace\]/a\exclude = ["'"$pkg_dir"'"]' python/pyproject.toml
36+
sed -i.bak '/'"$pkg"' = { workspace = true }/d' python/pyproject.toml
37+
fi
38+
done
39+
done
2240
- name: Install the project
2341
shell: bash
2442
run: |

.github/workflows/python-code-quality.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: ["3.10"]
21+
python-version: ["3.11"]
2222
runs-on: ubuntu-latest
2323
continue-on-error: true
2424
defaults:
@@ -55,7 +55,7 @@ jobs:
5555
strategy:
5656
fail-fast: false
5757
matrix:
58-
python-version: ["3.10"]
58+
python-version: ["3.11"]
5959
runs-on: ubuntu-latest
6060
continue-on-error: true
6161
defaults:
@@ -84,7 +84,7 @@ jobs:
8484
strategy:
8585
fail-fast: false
8686
matrix:
87-
python-version: ["3.10"]
87+
python-version: ["3.11"]
8888
runs-on: ubuntu-latest
8989
continue-on-error: true
9090
defaults:
@@ -117,7 +117,7 @@ jobs:
117117
strategy:
118118
fail-fast: false
119119
matrix:
120-
python-version: ["3.10"]
120+
python-version: ["3.11"]
121121
runs-on: ubuntu-latest
122122
continue-on-error: true
123123
defaults:

.github/workflows/python-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ jobs:
170170
environment: integration
171171
timeout-minutes: 60
172172
env:
173-
UV_PYTHON: "3.10"
173+
UV_PYTHON: "3.11"
174174
OPENAI_CHAT_MODEL_ID: ${{ vars.OPENAI__CHATMODELID }}
175175
OPENAI_RESPONSES_MODEL_ID: ${{ vars.OPENAI__RESPONSESMODELID }}
176176
OPENAI_API_KEY: ${{ secrets.OPENAI__APIKEY }}

.github/workflows/python-lab-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
with:
6868
python-version: ${{ matrix.python-version }}
6969
os: ${{ runner.os }}
70+
exclude-packages: ${{ matrix.python-version == '3.10' && 'agent-framework-github-copilot' || '' }}
7071
env:
7172
# Configure a constant location for the uv cache
7273
UV_CACHE_DIR: /tmp/.uv-cache

.github/workflows/python-merge-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ jobs:
288288
runs-on: ubuntu-latest
289289
environment: integration
290290
env:
291-
UV_PYTHON: "3.10"
291+
UV_PYTHON: "3.11"
292292
OPENAI_CHAT_MODEL_ID: ${{ vars.OPENAI__CHATMODELID }}
293293
OPENAI_RESPONSES_MODEL_ID: ${{ vars.OPENAI__RESPONSESMODELID }}
294294
OPENAI_API_KEY: ${{ secrets.OPENAI__APIKEY }}

.github/workflows/python-test-coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run:
2121
working-directory: python
2222
env:
23-
UV_PYTHON: "3.10"
23+
UV_PYTHON: "3.11"
2424
steps:
2525
- uses: actions/checkout@v6
2626
# Save the PR number to a file since the workflow_run event

.github/workflows/python-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ jobs:
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636
os: ${{ runner.os }}
37+
exclude-packages: ${{ matrix.python-version == '3.10' && 'agent-framework-github-copilot' || '' }}
3738
env:
3839
# Configure a constant location for the uv cache
3940
UV_CACHE_DIR: /tmp/.uv-cache
4041
# Unit tests
4142
- name: Run all tests
42-
run: uv run poe all-tests
43+
run: uv run poe all-tests ${{ matrix.python-version == '3.10' && '--ignore-glob=packages/github_copilot/**' || '' }}
4344
working-directory: ./python
4445

4546
# Surface failing tests

python/packages/core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ all = [
5555
"agent-framework-devui",
5656
"agent-framework-durabletask",
5757
"agent-framework-foundry-local",
58-
"agent-framework-github-copilot",
58+
"agent-framework-github-copilot; python_version >= '3.11'",
5959
"agent-framework-lab",
6060
"agent-framework-mem0",
6161
"agent-framework-ollama",

python/packages/github_copilot/agent_framework_github_copilot/_agent.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
from agent_framework._types import AgentRunInputs, normalize_tools
2727
from agent_framework.exceptions import AgentException
2828
from copilot import CopilotClient, CopilotSession
29-
from copilot.generated.session_events import SessionEvent, SessionEventType
29+
from copilot.generated.session_events import PermissionRequest, SessionEvent, SessionEventType
3030
from copilot.types import (
3131
CopilotClientOptions,
3232
MCPServerConfig,
3333
MessageOptions,
34-
PermissionRequest,
3534
PermissionRequestResult,
3635
ResumeSessionConfig,
3736
SessionConfig,
@@ -529,21 +528,21 @@ def _tool_to_copilot_tool(self, ai_func: FunctionTool) -> CopilotTool:
529528
"""Convert an FunctionTool to a Copilot SDK tool."""
530529

531530
async def handler(invocation: ToolInvocation) -> ToolResult:
532-
args = invocation.get("arguments", {})
531+
args: dict[str, Any] = invocation.arguments or {}
533532
try:
534533
if ai_func.input_model:
535534
args_instance = ai_func.input_model(**args)
536535
result = await ai_func.invoke(arguments=args_instance)
537536
else:
538537
result = await ai_func.invoke(arguments=args)
539538
return ToolResult(
540-
textResultForLlm=str(result),
541-
resultType="success",
539+
text_result_for_llm=str(result),
540+
result_type="success",
542541
)
543542
except Exception as e:
544543
return ToolResult(
545-
textResultForLlm=f"Error: {e}",
546-
resultType="failure",
544+
text_result_for_llm=f"Error: {e}",
545+
result_type="failure",
547546
error=str(e),
548547
)
549548

python/packages/github_copilot/pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "agent-framework-github-copilot"
33
description = "GitHub Copilot integration for Microsoft Agent Framework."
44
authors = [{ name = "Microsoft", email = "af-support@microsoft.com"}]
55
readme = "README.md"
6-
requires-python = ">=3.10"
6+
requires-python = ">=3.11"
77
version = "1.0.0b260304"
88
license-files = ["LICENSE"]
99
urls.homepage = "https://aka.ms/agent-framework"
@@ -15,7 +15,6 @@ classifiers = [
1515
"Development Status :: 4 - Beta",
1616
"Intended Audience :: Developers",
1717
"Programming Language :: Python :: 3",
18-
"Programming Language :: Python :: 3.10",
1918
"Programming Language :: Python :: 3.11",
2019
"Programming Language :: Python :: 3.12",
2120
"Programming Language :: Python :: 3.13",
@@ -24,7 +23,7 @@ classifiers = [
2423
]
2524
dependencies = [
2625
"agent-framework-core>=1.0.0rc3",
27-
"github-copilot-sdk>=0.1.0",
26+
"github-copilot-sdk>=0.1.32",
2827
]
2928

3029
[tool.uv]
@@ -66,7 +65,7 @@ include = ["agent_framework_github_copilot"]
6665
[tool.mypy]
6766
plugins = ['pydantic.mypy']
6867
strict = true
69-
python_version = "3.10"
68+
python_version = "3.11"
7069
ignore_missing_imports = true
7170
disallow_untyped_defs = true
7271
no_implicit_optional = true

0 commit comments

Comments
 (0)