agent-framework-github-copilot 2.0.2__tar.gz → 2.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: agent-framework-github-copilot
3
- Version: 2.0.2
3
+ Version: 2.1.1
4
4
  Summary: GitHub Copilot integration for Microsoft Agent Framework.
5
5
  Author-email: Microsoft <af-support@microsoft.com>
6
6
  Requires-Python: >=3.11
@@ -13,14 +13,16 @@ Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: 3.15
16
17
  Classifier: Typing :: Typed
17
18
  License-File: LICENSE
18
- Requires-Dist: agent-framework-core>=1.21.0,<2
19
+ Requires-Dist: agent-framework-core>=1.22.0,<2
19
20
  Requires-Dist: github-copilot-sdk>=1.0.16,<2.0; python_version >= '3.11'
20
21
  Project-URL: homepage, https://aka.ms/agent-framework
21
22
  Project-URL: issues, https://github.com/microsoft/agent-framework/issues
22
23
  Project-URL: release_notes, https://github.com/microsoft/agent-framework/releases?q=tag%3Apython-1&expanded=true
23
24
  Project-URL: source, https://github.com/microsoft/agent-framework/tree/main/python
25
+ Import-Name: agent_framework_github_copilot
24
26
 
25
27
  # Get Started with Microsoft Agent Framework GitHub Copilot
26
28
 
@@ -44,7 +46,8 @@ When you register a `FunctionTool` declared with `approval_mode="always_require"
44
46
  do **not** supply your own `on_pre_tool_use` hook, `GitHubCopilotAgent` installs a default
45
47
  `on_pre_tool_use` hook that returns `"ask"` for that tool and defers (`None`) for all other
46
48
  tools. The `"ask"` decision routes to your `on_permission_request` handler, where you
47
- approve or deny the call:
49
+ approve or deny the call. Other session hooks, such as `on_post_tool_use` or
50
+ `on_session_start`, are preserved alongside this default approval hook:
48
51
 
49
52
  ```python
50
53
  from agent_framework import tool
@@ -20,7 +20,8 @@ When you register a `FunctionTool` declared with `approval_mode="always_require"
20
20
  do **not** supply your own `on_pre_tool_use` hook, `GitHubCopilotAgent` installs a default
21
21
  `on_pre_tool_use` hook that returns `"ask"` for that tool and defers (`None`) for all other
22
22
  tools. The `"ask"` decision routes to your `on_permission_request` handler, where you
23
- approve or deny the call:
23
+ approve or deny the call. Other session hooks, such as `on_post_tool_use` or
24
+ `on_session_start`, are preserved alongside this default approval hook:
24
25
 
25
26
  ```python
26
27
  from agent_framework import tool
@@ -1147,7 +1147,7 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1147
1147
  if data.delta_content:
1148
1148
  update = AgentResponseUpdate(
1149
1149
  role="assistant",
1150
- contents=[Content.from_text(data.delta_content)],
1150
+ contents=[Content.from_text(data.delta_content, merge_mode="append")],
1151
1151
  response_id=data.message_id,
1152
1152
  message_id=data.message_id,
1153
1153
  raw_representation=event,
@@ -1165,7 +1165,13 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1165
1165
  model = event.data.model or None
1166
1166
  if usage_details or finish_reason or model:
1167
1167
  update = AgentResponseUpdate(
1168
- contents=[Content.from_usage(usage_details, raw_representation=event.data)]
1168
+ contents=[
1169
+ Content.from_usage(
1170
+ usage_details,
1171
+ merge_mode="replace",
1172
+ raw_representation=event.data,
1173
+ )
1174
+ ]
1169
1175
  if usage_details
1170
1176
  else None,
1171
1177
  finish_reason=cast(Any, finish_reason),
@@ -1181,6 +1187,8 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1181
1187
  call_id=tool_call_id,
1182
1188
  name=tool_name,
1183
1189
  arguments=arguments,
1190
+ hosted=True,
1191
+ merge_mode="replace",
1184
1192
  raw_representation=event.data,
1185
1193
  )
1186
1194
  update = AgentResponseUpdate(
@@ -1497,17 +1505,16 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1497
1505
  ``approval_mode="always_require"`` is delegated to the Copilot SDK's native
1498
1506
  ``on_pre_tool_use`` hook:
1499
1507
 
1500
- - If the caller supplies their own session hooks -- either the SDK-native
1501
- ``hooks`` dict or the convenience ``on_pre_tool_use`` handler (via per-run
1502
- ``options`` or ``default_options``) -- those take precedence and are used
1503
- as-is. When both are given, the explicit ``hooks`` dict wins for any key it
1504
- defines and the ``on_pre_tool_use`` shortcut fills in that key otherwise. A
1505
- warning is logged naming any approval-required tool that will therefore not
1506
- be automatically gated, since the caller's hooks are responsible for
1507
- enforcing approval.
1508
+ - If the caller supplies their own ``on_pre_tool_use`` handler -- either in
1509
+ the SDK-native ``hooks`` dict or through the convenience option (via per-run
1510
+ ``options`` or ``default_options``) -- it takes precedence. When both are
1511
+ given, the explicit ``hooks`` dict wins for any key it defines and the
1512
+ shortcut fills in that key otherwise. A warning names any approval-required
1513
+ tool that the caller's pre-tool-use handler is responsible for gating.
1508
1514
  - Otherwise, when any approval-required tool is present, a default hook is
1509
1515
  installed that returns ``"ask"`` for those tools (routing the decision to
1510
1516
  ``on_permission_request``) and defers (``None``) for all other tools.
1517
+ Unrelated caller hooks are preserved and do not replace this default.
1511
1518
  - The default hook is **not** installed when the deprecated
1512
1519
  ``on_function_approval`` callback is configured: in that case approval is
1513
1520
  enforced inside the tool handler (see :meth:`_tool_to_copilot_tool`) to
@@ -1524,12 +1531,12 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1524
1531
  The hooks to register for the session, or ``None`` if none are needed.
1525
1532
  """
1526
1533
  user_hook: PreToolUseHandler | None = options.get("on_pre_tool_use") or self._on_pre_tool_use
1527
- caller_hooks: Mapping[str, Any] | None = options.get("hooks")
1534
+ caller_hooks: SessionHooks | None = options.get("hooks")
1528
1535
 
1529
1536
  # Combine caller-provided hooks: the SDK-native ``hooks`` dict plus the
1530
1537
  # convenience ``on_pre_tool_use`` shortcut. The explicit dict wins for the
1531
1538
  # keys it defines; the shortcut only fills in ``on_pre_tool_use`` otherwise.
1532
- combined: dict[str, Any] = {}
1539
+ combined: SessionHooks = {}
1533
1540
  if user_hook is not None:
1534
1541
  combined["on_pre_tool_use"] = user_hook
1535
1542
  if caller_hooks:
@@ -1539,7 +1546,7 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1539
1546
  tool.name for tool in all_tools if isinstance(tool, FunctionTool) and tool.approval_mode == "always_require"
1540
1547
  }
1541
1548
 
1542
- if combined:
1549
+ if combined.get("on_pre_tool_use") is not None:
1543
1550
  if approval_required_names:
1544
1551
  logger.warning(
1545
1552
  "Custom session hooks are configured, so %d approval-required tool(s) (%s) "
@@ -1548,15 +1555,15 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1548
1555
  len(approval_required_names),
1549
1556
  ", ".join(sorted(approval_required_names)),
1550
1557
  )
1551
- return cast("SessionHooks", combined)
1558
+ return combined
1552
1559
 
1553
1560
  if not approval_required_names:
1554
- return None
1561
+ return combined or None
1555
1562
 
1556
1563
  # The deprecated on_function_approval callback enforces approval in the tool
1557
1564
  # handler; don't also install the default ask-hook (which would double-gate).
1558
1565
  if self._function_approval_handler is not None:
1559
- return None
1566
+ return combined or None
1560
1567
 
1561
1568
  def default_pre_tool_use(
1562
1569
  hook_input: Mapping[str, Any],
@@ -1572,7 +1579,8 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1572
1579
  }
1573
1580
  return None
1574
1581
 
1575
- return {"on_pre_tool_use": default_pre_tool_use}
1582
+ combined["on_pre_tool_use"] = default_pre_tool_use
1583
+ return combined
1576
1584
 
1577
1585
  def _session_run_lock(self, service_session_id: str) -> asyncio.Lock:
1578
1586
  """Return the lock that serializes runs on one Copilot service session."""
@@ -4,7 +4,7 @@ description = "GitHub Copilot integration for Microsoft Agent Framework."
4
4
  authors = [{ name = "Microsoft", email = "af-support@microsoft.com"}]
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
7
- version = "2.0.2"
7
+ version = "2.1.1"
8
8
  license-files = ["LICENSE"]
9
9
  urls.homepage = "https://aka.ms/agent-framework"
10
10
  urls.source = "https://github.com/microsoft/agent-framework/tree/main/python"
@@ -19,10 +19,11 @@ classifiers = [
19
19
  "Programming Language :: Python :: 3.12",
20
20
  "Programming Language :: Python :: 3.13",
21
21
  "Programming Language :: Python :: 3.14",
22
+ "Programming Language :: Python :: 3.15",
22
23
  "Typing :: Typed",
23
24
  ]
24
25
  dependencies = [
25
- "agent-framework-core>=1.21.0,<2",
26
+ "agent-framework-core>=1.22.0,<2",
26
27
  "github-copilot-sdk>=1.0.16,<2.0; python_version >= '3.11'",
27
28
  ]
28
29
 
@@ -99,5 +100,5 @@ shell = "python -c \"import sys; exit(0 if sys.version_info < (3,11) else 1)\" |
99
100
  interpreter = "posix"
100
101
 
101
102
  [build-system]
102
- requires = ["flit-core >= 3.11,<4.0"]
103
+ requires = ["flit-core>=3.11,<5.0"]
103
104
  build-backend = "flit_core.buildapi"