Skip to content

[BREAKING] Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types#4551

Merged
eavanvalkenburg merged 9 commits intomicrosoft:mainfrom
moonbox3:agent/fix-4549-1
Mar 9, 2026
Merged

[BREAKING] Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types#4551
eavanvalkenburg merged 9 commits intomicrosoft:mainfrom
moonbox3:agent/fix-4549-1

Conversation

@moonbox3
Copy link
Copy Markdown
Contributor

@moonbox3 moonbox3 commented Mar 9, 2026

Motivation and Context

The upgrade of github-copilot-sdk to >=0.1.32 introduced breaking changes:

  • Handler now receives a ToolInvocation dataclass instead of a plain dict.
  • Handler now returns ToolResult with snake_case fields (result_type, text_result_for_llm) instead of camelCase (resultType, textResultForLlm).
  • The SDK now requires Python >=3.11, dropping Python 3.10 support.

Fixes #4549

Description

Production code changes (_agent.py):

  • Update _tool_to_copilot_tool handler to access invocation.arguments (attribute) instead of invocation.get("arguments") (dict).
  • Update ToolResult construction to use snake_case fields (text_result_for_llm, result_type) instead of camelCase.
  • Fix PermissionRequest import location (moved from copilot.types to copilot.generated.session_events in SDK 0.1.32).

Dependency & Python version changes:

  • Bump github-copilot-sdk dependency from >=0.1.0 to >=0.1.32.
  • Set requires-python = ">=3.11" for the agent-framework-github-copilot package, matching the SDK's requirement.
  • Gate agent-framework-github-copilot in core's [all] extra with python_version >= '3.11' marker so uv sync still works on Python 3.10 for all other packages.

CI/CD changes:

  • Update single-version workflows (python-code-quality, python-test-coverage, python-integration-tests, python-merge-tests) from Python 3.10 to 3.11.
  • Add exclude-packages input to the python-setup action to exclude incompatible workspace members (removes them from workspace resolution via uv.workspace.exclude).
  • On Python 3.10 matrix runs in python-tests and python-lab-tests, exclude agent-framework-github-copilot from install and skip its tests.

Sample fixes (github_copilot samples):

  • Fix PermissionRequest usage: replace dict-style .get() calls with dataclass attribute access.

Test changes (test_github_copilot_agent.py):

  • Update existing tool handler tests to pass ToolInvocation(...) and assert on ToolResult attributes.
  • Add test_tool_handler_rejects_raw_dict_invocation to verify the old dict calling convention raises an error.
  • Add test_tool_handler_with_empty_arguments to cover the empty-arguments edge case.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the https://github.com/microsoft/agent-framework/blob/main/CONTRIBUTING.md
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? Yes — agent-framework-github-copilot now requires Python >=3.11 (matching the upstream github-copilot-sdk >=0.1.32 requirement). All other agent-framework packages continue to support Python 3.10.

moonbox3 and others added 2 commits March 9, 2026 12:59
…ft#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>
…osoft#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>
Copilot AI review requested due to automatic review settings March 9, 2026 04:04
@moonbox3 moonbox3 self-assigned this Mar 9, 2026
Copy link
Copy Markdown
Contributor Author

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 92%

✓ Correctness

The diff updates two test call sites to pass a ToolInvocation object instead of a plain dictionary to copilot_tool.handler(), aligning the tests with a likely signature change in the handler that now expects a typed ToolInvocation rather than a raw dict. The import is correctly added and the construction ToolInvocation(arguments={"arg": "test"}) matches the previous dict shape. No correctness issues found.

✓ Security Reliability

This diff is a minor test-only change that replaces raw dictionary arguments with typed ToolInvocation objects when calling copilot tool handlers. This improves type safety in the tests and aligns them with an updated handler signature. There are no security or reliability concerns.

✓ Test Coverage

The diff updates two existing tests to pass a ToolInvocation object instead of a raw dict to copilot_tool.handler(), aligning tests with a signature change. The existing assertions (checking result_type for success and failure) remain meaningful. However, there are no new tests covering edge cases of the ToolInvocation type — e.g., missing arguments, extra fields, or None arguments — and no test verifies that passing a raw dict now raises an error (if that was the intent of the breaking change).

✓ Design Approach

The diff updates two test call sites to pass a proper ToolInvocation object instead of a raw dictionary to copilot_tool.handler(). This is a correct and straightforward change that aligns tests with a typed interface, replacing duck-typed dictionaries with the actual domain object. No design concerns.

Suggestions

  • Consider adding a test that verifies passing a raw dict (the old calling convention) to copilot_tool.handler() now raises a TypeError or similar error, to lock in the new contract.
  • Consider adding a test with ToolInvocation(arguments={}) (empty arguments) to cover the edge case where no arguments are provided.

Automated review by moonbox3's agents

Copy link
Copy Markdown
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 updates the GitHub Copilot Python integration to align with github-copilot-sdk>=0.1.32’s runtime types, and adds/adjusts tests so future regressions (back to dict-based tool invocation/results) are caught.

Changes:

  • Update GitHubCopilotAgent tool handler to consume ToolInvocation and return ToolResult with snake_case fields.
  • Update regression tests to pass ToolInvocation(...) and assert on ToolResult attributes.
  • Bump agent-framework-github-copilot to Python >=3.11 and upgrade dependency to github-copilot-sdk>=0.1.32.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
python/packages/github_copilot/tests/test_github_copilot_agent.py Updates tool handler tests to use ToolInvocation and validate ToolResult attributes.
python/packages/github_copilot/pyproject.toml Raises minimum Python to 3.11, removes 3.10 classifier, updates mypy target, and bumps github-copilot-sdk dependency.
python/packages/github_copilot/agent_framework_github_copilot/_agent.py Updates tool conversion handler to use invocation.arguments and construct ToolResult using snake_case fields; adjusts imports.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread python/packages/github_copilot/pyproject.toml
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>
@moonbox3 moonbox3 changed the title Python: Add regression tests for github-copilot-sdk ToolInvocation type change [BREAKING] Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types Mar 9, 2026
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>
@moonbox3 moonbox3 changed the title [BREAKING] Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types Mar 9, 2026
moonbox3 added 2 commits March 9, 2026 13:57
github-copilot-sdk>=0.1.32 requires Python>=3.11, which conflicts
with the package's declared >=3.10 minimum, breaking uv sync.
@markwallace-microsoft
Copy link
Copy Markdown
Contributor

markwallace-microsoft commented Mar 9, 2026

Python Test Coverage

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

Python Unit Test Overview

Tests Skipped Failures Errors Time
4932 20 💤 0 ❌ 0 🔥 1m 17s ⏱️

@moonbox3 moonbox3 changed the title Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types [BREAKING] Python: Update github-copilot-sdk integration to use ToolInvocation/ToolResult types Mar 9, 2026
@moonbox3 moonbox3 added the breaking change Introduces changes that are not backward compatible and may require updates to dependent code. label Mar 9, 2026
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Mar 9, 2026
Merged via the queue into microsoft:main with commit d5e240b Mar 9, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible and may require updates to dependent code. python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Update github_copilot package to github-copilot-sdk>=0.1.32 and requires-python>=3.11

4 participants