agent-framework-github-copilot 1.0.0b260402__tar.gz → 1.0.0b260421__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.4
2
2
  Name: agent-framework-github-copilot
3
- Version: 1.0.0b260402
3
+ Version: 1.0.0b260421
4
4
  Summary: GitHub Copilot integration for Microsoft Agent Framework.
5
5
  Author-email: Microsoft <af-support@microsoft.com>
6
6
  Requires-Python: >=3.10
@@ -16,8 +16,8 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
17
  Classifier: Typing :: Typed
18
18
  License-File: LICENSE
19
- Requires-Dist: agent-framework-core>=1.0.0,<2
20
- Requires-Dist: github-copilot-sdk>=0.1.31,<0.1.33; python_version >= '3.11'
19
+ Requires-Dist: agent-framework-core>=1.1.0,<2
20
+ Requires-Dist: github-copilot-sdk>=0.2.1,<=0.2.1; python_version >= '3.11'
21
21
  Project-URL: homepage, https://aka.ms/agent-framework
22
22
  Project-URL: issues, https://github.com/microsoft/agent-framework/issues
23
23
  Project-URL: release_notes, https://github.com/microsoft/agent-framework/releases?q=tag%3Apython-1&expanded=true
@@ -7,7 +7,7 @@ import contextlib
7
7
  import logging
8
8
  import sys
9
9
  from collections.abc import AsyncIterable, Awaitable, Callable, MutableMapping, Sequence
10
- from typing import Any, ClassVar, Generic, Literal, TypedDict, cast, overload
10
+ from typing import Any, ClassVar, Generic, Literal, TypedDict, overload
11
11
 
12
12
  from agent_framework import (
13
13
  AgentMiddlewareTypes,
@@ -29,20 +29,11 @@ from agent_framework._types import AgentRunInputs, normalize_tools
29
29
  from agent_framework.exceptions import AgentException
30
30
 
31
31
  try:
32
- from copilot import CopilotClient, CopilotSession
32
+ from copilot import CopilotClient, CopilotSession, SubprocessConfig
33
33
  from copilot.generated.session_events import PermissionRequest, SessionEvent, SessionEventType
34
- from copilot.types import (
35
- CopilotClientOptions,
36
- MCPServerConfig,
37
- MessageOptions,
38
- PermissionRequestResult,
39
- ResumeSessionConfig,
40
- SessionConfig,
41
- SystemMessageConfig,
42
- ToolInvocation,
43
- ToolResult,
44
- )
45
- from copilot.types import Tool as CopilotTool
34
+ from copilot.session import MCPServerConfig, PermissionRequestResult, ProviderConfig, SystemMessageConfig
35
+ from copilot.tools import Tool as CopilotTool
36
+ from copilot.tools import ToolInvocation, ToolResult
46
37
  except ImportError as _copilot_import_error:
47
38
  raise ImportError(
48
39
  "GitHubCopilotAgent requires the 'github-copilot-sdk' package, which is only available on Python 3.11+. "
@@ -64,6 +55,14 @@ PermissionHandlerType = Callable[[PermissionRequest, dict[str, str]], Permission
64
55
  logger = logging.getLogger("agent_framework.github_copilot")
65
56
 
66
57
 
58
+ def _deny_all_permissions(
59
+ _request: PermissionRequest,
60
+ _invocation: dict[str, str],
61
+ ) -> PermissionRequestResult:
62
+ """Default permission handler that denies all requests."""
63
+ return PermissionRequestResult()
64
+
65
+
67
66
  class GitHubCopilotSettings(TypedDict, total=False):
68
67
  """GitHub Copilot model settings.
69
68
 
@@ -121,6 +120,12 @@ class GitHubCopilotOptions(TypedDict, total=False):
121
120
  Supports both local (stdio) and remote (HTTP/SSE) servers.
122
121
  """
123
122
 
123
+ provider: ProviderConfig
124
+ """Custom API provider configuration for BYOK (Bring Your Own Key) scenarios.
125
+ Allows routing requests through your own OpenAI, Azure, or Anthropic endpoint
126
+ instead of the default GitHub Copilot backend.
127
+ """
128
+
124
129
 
125
130
  OptionsT = TypeVar(
126
131
  "OptionsT",
@@ -233,6 +238,7 @@ class GitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
233
238
  log_level = opts.pop("log_level", None)
234
239
  on_permission_request: PermissionHandlerType | None = opts.pop("on_permission_request", None)
235
240
  mcp_servers: dict[str, MCPServerConfig] | None = opts.pop("mcp_servers", None)
241
+ provider: ProviderConfig | None = opts.pop("provider", None)
236
242
 
237
243
  self._settings = load_settings(
238
244
  GitHubCopilotSettings,
@@ -248,6 +254,7 @@ class GitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
248
254
  self._tools = normalize_tools(tools)
249
255
  self._permission_handler = on_permission_request
250
256
  self._mcp_servers = mcp_servers
257
+ self._provider = provider
251
258
  self._default_options = opts
252
259
  self._started = False
253
260
 
@@ -274,16 +281,13 @@ class GitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
274
281
  return
275
282
 
276
283
  if self._client is None:
277
- client_options: CopilotClientOptions = {}
278
- cli_path = self._settings.get("cli_path")
279
- if cli_path:
280
- client_options["cli_path"] = cli_path
284
+ cli_path = self._settings.get("cli_path") or None
285
+ log_level = self._settings.get("log_level") or None
281
286
 
282
- log_level = self._settings.get("log_level")
287
+ subprocess_kwargs: dict[str, Any] = {"cli_path": cli_path}
283
288
  if log_level:
284
- client_options["log_level"] = log_level # type: ignore[typeddict-item]
285
-
286
- self._client = CopilotClient(client_options if client_options else None)
289
+ subprocess_kwargs["log_level"] = log_level
290
+ self._client = CopilotClient(SubprocessConfig(**subprocess_kwargs))
287
291
 
288
292
  try:
289
293
  await self._client.start()
@@ -407,10 +411,9 @@ class GitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
407
411
  prompt = "\n".join([message.text for message in context_messages])
408
412
  if session_context.instructions:
409
413
  prompt = "\n".join(session_context.instructions) + "\n" + prompt
410
- message_options = cast(MessageOptions, {"prompt": prompt})
411
414
 
412
415
  try:
413
- response_event = await copilot_session.send_and_wait(message_options, timeout=timeout)
416
+ response_event = await copilot_session.send_and_wait(prompt, timeout=timeout)
414
417
  except Exception as ex:
415
418
  raise AgentException(f"GitHub Copilot request failed: {ex}") from ex
416
419
 
@@ -489,7 +492,6 @@ class GitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
489
492
  prompt = "\n".join([message.text for message in context_messages])
490
493
  if session_context.instructions:
491
494
  prompt = "\n".join(session_context.instructions) + "\n" + prompt
492
- message_options = cast(MessageOptions, {"prompt": prompt})
493
495
 
494
496
  queue: asyncio.Queue[AgentResponseUpdate | Exception | None] = asyncio.Queue()
495
497
 
@@ -550,7 +552,7 @@ class GitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
550
552
  unsubscribe = copilot_session.on(event_handler)
551
553
 
552
554
  try:
553
- await copilot_session.send(message_options)
555
+ await copilot_session.send(prompt)
554
556
 
555
557
  while (item := await queue.get()) is not None:
556
558
  if isinstance(item, Exception):
@@ -730,43 +732,38 @@ class GitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
730
732
  raise RuntimeError("GitHub Copilot client not initialized. Call start() first.")
731
733
 
732
734
  opts = runtime_options or {}
733
- config: SessionConfig = {"streaming": streaming}
734
-
735
- model = opts.get("model") or self._settings.get("model")
736
- if model:
737
- config["model"] = model # type: ignore[typeddict-item]
738
-
739
- system_message = opts.get("system_message") or self._default_options.get("system_message")
740
- if system_message:
741
- config["system_message"] = system_message
742
-
743
- if self._tools:
744
- config["tools"] = self._prepare_tools(self._tools)
745
-
746
- permission_handler = opts.get("on_permission_request") or self._permission_handler
747
- if permission_handler:
748
- config["on_permission_request"] = permission_handler
749
-
750
- mcp_servers = opts.get("mcp_servers") or self._mcp_servers
751
- if mcp_servers:
752
- config["mcp_servers"] = mcp_servers
753
-
754
- return await self._client.create_session(config)
735
+ model = opts.get("model") or self._settings.get("model") or None
736
+ system_message = opts.get("system_message") or self._default_options.get("system_message") or None
737
+ permission_handler: PermissionHandlerType = (
738
+ opts.get("on_permission_request") or self._permission_handler or _deny_all_permissions
739
+ )
740
+ mcp_servers = opts.get("mcp_servers") or self._mcp_servers or None
741
+ provider = opts.get("provider") or self._provider or None
742
+ tools = self._prepare_tools(self._tools) if self._tools else None
743
+
744
+ return await self._client.create_session(
745
+ on_permission_request=permission_handler,
746
+ streaming=streaming,
747
+ model=model or None,
748
+ system_message=system_message or None,
749
+ tools=tools or None,
750
+ mcp_servers=mcp_servers or None,
751
+ provider=provider or None,
752
+ )
755
753
 
756
754
  async def _resume_session(self, session_id: str, streaming: bool) -> CopilotSession:
757
755
  """Resume an existing Copilot session by ID."""
758
756
  if not self._client:
759
757
  raise RuntimeError("GitHub Copilot client not initialized. Call start() first.")
760
758
 
761
- config: ResumeSessionConfig = {"streaming": streaming}
759
+ permission_handler: PermissionHandlerType = self._permission_handler or _deny_all_permissions
760
+ tools = self._prepare_tools(self._tools) if self._tools else None
762
761
 
763
- if self._tools:
764
- config["tools"] = self._prepare_tools(self._tools)
765
-
766
- if self._permission_handler:
767
- config["on_permission_request"] = self._permission_handler
768
-
769
- if self._mcp_servers:
770
- config["mcp_servers"] = self._mcp_servers
771
-
772
- return await self._client.resume_session(session_id, config)
762
+ return await self._client.resume_session(
763
+ session_id,
764
+ on_permission_request=permission_handler,
765
+ streaming=streaming,
766
+ tools=tools or None,
767
+ mcp_servers=self._mcp_servers or None,
768
+ provider=self._provider or None,
769
+ )
@@ -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.10"
7
- version = "1.0.0b260402"
7
+ version = "1.0.0b260421"
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"
@@ -23,8 +23,8 @@ classifiers = [
23
23
  "Typing :: Typed",
24
24
  ]
25
25
  dependencies = [
26
- "agent-framework-core>=1.0.0,<2",
27
- "github-copilot-sdk>=0.1.31,<0.1.33; python_version >= '3.11'",
26
+ "agent-framework-core>=1.1.0,<2",
27
+ "github-copilot-sdk>=0.2.1,<=0.2.1; python_version >= '3.11'",
28
28
  ]
29
29
 
30
30
  [tool.uv]
@@ -102,3 +102,4 @@ interpreter = "posix"
102
102
  [build-system]
103
103
  requires = ["flit-core >= 3.11,<4.0"]
104
104
  build-backend = "flit_core.buildapi"
105
+