agent-framework-github-copilot 1.0.0rc4__tar.gz → 1.0.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,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-framework-github-copilot
3
- Version: 1.0.0rc4
3
+ Version: 1.0.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.10
7
7
  Description-Content-Type: text/markdown
8
8
  Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Development Status :: 4 - Beta
9
+ Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.10
@@ -16,7 +16,7 @@ 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.11.0,<2
19
+ Requires-Dist: agent-framework-core>=1.13.0,<2
20
20
  Requires-Dist: github-copilot-sdk==1.0.2; 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
@@ -28,7 +28,7 @@ Project-URL: source, https://github.com/microsoft/agent-framework/tree/main/pyth
28
28
  Please install this package via pip:
29
29
 
30
30
  ```bash
31
- pip install agent-framework-github-copilot --pre
31
+ pip install agent-framework-github-copilot
32
32
  ```
33
33
 
34
34
  ## GitHub Copilot Agent
@@ -3,7 +3,7 @@
3
3
  Please install this package via pip:
4
4
 
5
5
  ```bash
6
- pip install agent-framework-github-copilot --pre
6
+ pip install agent-framework-github-copilot
7
7
  ```
8
8
 
9
9
  ## GitHub Copilot Agent
@@ -29,11 +29,18 @@ from agent_framework import (
29
29
  normalize_messages,
30
30
  )
31
31
  from agent_framework._settings import load_settings
32
+ from agent_framework._telemetry import mark_feature_used
32
33
  from agent_framework._tools import FunctionTool, ToolTypes
33
- from agent_framework._types import AgentRunInputs, normalize_tools
34
- from agent_framework.exceptions import AgentException
34
+ from agent_framework._types import (
35
+ AgentRunInputs,
36
+ _get_data_bytes_as_str, # pyright: ignore[reportPrivateUsage]
37
+ normalize_tools,
38
+ )
39
+ from agent_framework.exceptions import AgentException, ContentError
35
40
  from agent_framework.observability import AgentTelemetryLayer
36
41
 
42
+ from ._feature_usage import FeatureIndex
43
+
37
44
  if sys.version_info >= (3, 11):
38
45
  from typing import Self # pragma: no cover
39
46
  else:
@@ -47,6 +54,8 @@ try:
47
54
  from copilot import CopilotClient, CopilotSession, RuntimeConnection
48
55
  from copilot.generated.rpc import PermissionDecisionUserNotAvailable
49
56
  from copilot.session import (
57
+ Attachment,
58
+ BlobAttachment,
50
59
  MCPServerConfig,
51
60
  PermissionRequestResult,
52
61
  PreToolUseHandler,
@@ -656,10 +665,12 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
656
665
  prompt = "\n".join([message.text for message in context_messages])
657
666
  if session_context.instructions:
658
667
  prompt = "\n".join(session_context.instructions) + "\n" + prompt
668
+ attachments = self._prepare_attachments_for_copilot(context_messages)
659
669
 
660
670
  unsubscribe = copilot_session.on(usage_event_handler)
661
671
  try:
662
- response_event = await copilot_session.send_and_wait(prompt, timeout=timeout)
672
+ mark_feature_used(FeatureIndex.GITHUB_COPILOT)
673
+ response_event = await copilot_session.send_and_wait(prompt, attachments=attachments, timeout=timeout)
663
674
  except Exception as ex:
664
675
  raise AgentException(f"GitHub Copilot request failed: {ex}") from ex
665
676
  finally:
@@ -762,6 +773,7 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
762
773
  prompt = "\n".join([message.text for message in context_messages])
763
774
  if session_context.instructions:
764
775
  prompt = "\n".join(session_context.instructions) + "\n" + prompt
776
+ attachments = self._prepare_attachments_for_copilot(context_messages)
765
777
 
766
778
  queue: asyncio.Queue[AgentResponseUpdate | Exception | None] = asyncio.Queue()
767
779
 
@@ -844,7 +856,8 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
844
856
  unsubscribe = copilot_session.on(event_handler)
845
857
 
846
858
  try:
847
- await copilot_session.send(prompt)
859
+ mark_feature_used(FeatureIndex.GITHUB_COPILOT)
860
+ await copilot_session.send(prompt, attachments=attachments)
848
861
 
849
862
  while (item := await queue.get()) is not None:
850
863
  if isinstance(item, Exception):
@@ -916,6 +929,56 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
916
929
  elif opts_system_message is not None:
917
930
  opts["system_message"] = opts_system_message
918
931
 
932
+ @staticmethod
933
+ def _prepare_attachments_for_copilot(messages: Sequence[Message]) -> list[Attachment] | None:
934
+ """Convert inline binary message content into Copilot SDK attachments.
935
+
936
+ Scans the outgoing messages for ``data`` content (binary payloads such as
937
+ images or documents carried as base64 data URIs) and maps each one to an
938
+ inline ``blob`` attachment understood by the Copilot SDK.
939
+
940
+ Only base64 ``data:`` content is forwarded as an attachment. Other content
941
+ is not turned into an attachment: text content is already carried in the
942
+ prompt, while remote URIs (for example ``https://`` links) and malformed or
943
+ non-base64 ``data:`` URIs are skipped -- they are neither attached nor added
944
+ to the prompt.
945
+
946
+ Args:
947
+ messages: The messages being sent to the Copilot session.
948
+
949
+ Returns:
950
+ A list of Copilot ``Attachment`` objects, or ``None`` when the messages
951
+ contain no attachable binary content.
952
+ """
953
+ attachments: list[Attachment] = []
954
+ for message in messages:
955
+ for content in message.contents:
956
+ if content.type != "data":
957
+ continue
958
+ try:
959
+ data_str = _get_data_bytes_as_str(content)
960
+ except ContentError:
961
+ logger.warning(
962
+ "Skipping GitHub Copilot attachment with an unsupported data URI; "
963
+ "only base64-encoded 'data:' URIs can be forwarded as attachments."
964
+ )
965
+ continue
966
+ if not data_str:
967
+ continue
968
+ if not content.media_type:
969
+ logger.warning(
970
+ "Dropping GitHub Copilot attachment with no media type; the Copilot SDK "
971
+ "requires a MIME type for inline binary content."
972
+ )
973
+ continue
974
+ blob: BlobAttachment = {
975
+ "type": "blob",
976
+ "data": data_str,
977
+ "mimeType": content.media_type,
978
+ }
979
+ attachments.append(blob)
980
+ return attachments or None
981
+
919
982
  def _prepare_tools(
920
983
  self,
921
984
  tools: Sequence[ToolTypes | CopilotTool],
@@ -0,0 +1,9 @@
1
+ # Copyright (c) Microsoft. All rights reserved.
2
+
3
+ from enum import IntEnum
4
+
5
+
6
+ class FeatureIndex(IntEnum):
7
+ """GitHub Copilot-owned feature-usage indexes."""
8
+
9
+ GITHUB_COPILOT = 64
@@ -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.0rc4"
7
+ version = "1.0.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"
@@ -12,7 +12,7 @@ urls.release_notes = "https://github.com/microsoft/agent-framework/releases?q=ta
12
12
  urls.issues = "https://github.com/microsoft/agent-framework/issues"
13
13
  classifiers = [
14
14
  "License :: OSI Approved :: MIT License",
15
- "Development Status :: 4 - Beta",
15
+ "Development Status :: 5 - Production/Stable",
16
16
  "Intended Audience :: Developers",
17
17
  "Programming Language :: Python :: 3",
18
18
  "Programming Language :: Python :: 3.10",
@@ -23,7 +23,7 @@ classifiers = [
23
23
  "Typing :: Typed",
24
24
  ]
25
25
  dependencies = [
26
- "agent-framework-core>=1.11.0,<2",
26
+ "agent-framework-core>=1.13.0,<2",
27
27
  "github-copilot-sdk==1.0.2; python_version >= '3.11'",
28
28
  ]
29
29