agent-framework-github-copilot 2.1.0__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
1
  Metadata-Version: 2.5
2
2
  Name: agent-framework-github-copilot
3
- Version: 2.1.0
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
@@ -46,7 +46,8 @@ When you register a `FunctionTool` declared with `approval_mode="always_require"
46
46
  do **not** supply your own `on_pre_tool_use` hook, `GitHubCopilotAgent` installs a default
47
47
  `on_pre_tool_use` hook that returns `"ask"` for that tool and defers (`None`) for all other
48
48
  tools. The `"ask"` decision routes to your `on_permission_request` handler, where you
49
- 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:
50
51
 
51
52
  ```python
52
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
@@ -1505,17 +1505,16 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1505
1505
  ``approval_mode="always_require"`` is delegated to the Copilot SDK's native
1506
1506
  ``on_pre_tool_use`` hook:
1507
1507
 
1508
- - If the caller supplies their own session hooks -- either the SDK-native
1509
- ``hooks`` dict or the convenience ``on_pre_tool_use`` handler (via per-run
1510
- ``options`` or ``default_options``) -- those take precedence and are used
1511
- as-is. When both are given, the explicit ``hooks`` dict wins for any key it
1512
- defines and the ``on_pre_tool_use`` shortcut fills in that key otherwise. A
1513
- warning is logged naming any approval-required tool that will therefore not
1514
- be automatically gated, since the caller's hooks are responsible for
1515
- 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.
1516
1514
  - Otherwise, when any approval-required tool is present, a default hook is
1517
1515
  installed that returns ``"ask"`` for those tools (routing the decision to
1518
1516
  ``on_permission_request``) and defers (``None``) for all other tools.
1517
+ Unrelated caller hooks are preserved and do not replace this default.
1519
1518
  - The default hook is **not** installed when the deprecated
1520
1519
  ``on_function_approval`` callback is configured: in that case approval is
1521
1520
  enforced inside the tool handler (see :meth:`_tool_to_copilot_tool`) to
@@ -1532,12 +1531,12 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1532
1531
  The hooks to register for the session, or ``None`` if none are needed.
1533
1532
  """
1534
1533
  user_hook: PreToolUseHandler | None = options.get("on_pre_tool_use") or self._on_pre_tool_use
1535
- caller_hooks: Mapping[str, Any] | None = options.get("hooks")
1534
+ caller_hooks: SessionHooks | None = options.get("hooks")
1536
1535
 
1537
1536
  # Combine caller-provided hooks: the SDK-native ``hooks`` dict plus the
1538
1537
  # convenience ``on_pre_tool_use`` shortcut. The explicit dict wins for the
1539
1538
  # keys it defines; the shortcut only fills in ``on_pre_tool_use`` otherwise.
1540
- combined: dict[str, Any] = {}
1539
+ combined: SessionHooks = {}
1541
1540
  if user_hook is not None:
1542
1541
  combined["on_pre_tool_use"] = user_hook
1543
1542
  if caller_hooks:
@@ -1547,7 +1546,7 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1547
1546
  tool.name for tool in all_tools if isinstance(tool, FunctionTool) and tool.approval_mode == "always_require"
1548
1547
  }
1549
1548
 
1550
- if combined:
1549
+ if combined.get("on_pre_tool_use") is not None:
1551
1550
  if approval_required_names:
1552
1551
  logger.warning(
1553
1552
  "Custom session hooks are configured, so %d approval-required tool(s) (%s) "
@@ -1556,15 +1555,15 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1556
1555
  len(approval_required_names),
1557
1556
  ", ".join(sorted(approval_required_names)),
1558
1557
  )
1559
- return cast("SessionHooks", combined)
1558
+ return combined
1560
1559
 
1561
1560
  if not approval_required_names:
1562
- return None
1561
+ return combined or None
1563
1562
 
1564
1563
  # The deprecated on_function_approval callback enforces approval in the tool
1565
1564
  # handler; don't also install the default ask-hook (which would double-gate).
1566
1565
  if self._function_approval_handler is not None:
1567
- return None
1566
+ return combined or None
1568
1567
 
1569
1568
  def default_pre_tool_use(
1570
1569
  hook_input: Mapping[str, Any],
@@ -1580,7 +1579,8 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
1580
1579
  }
1581
1580
  return None
1582
1581
 
1583
- return {"on_pre_tool_use": default_pre_tool_use}
1582
+ combined["on_pre_tool_use"] = default_pre_tool_use
1583
+ return combined
1584
1584
 
1585
1585
  def _session_run_lock(self, service_session_id: str) -> asyncio.Lock:
1586
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.1.0"
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"