agent-framework-github-copilot 1.0.0rc2__tar.gz → 1.0.0rc4__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.
- {agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/PKG-INFO +2 -2
- {agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/agent_framework_github_copilot/_agent.py +198 -83
- {agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/pyproject.toml +2 -3
- {agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/LICENSE +0 -0
- {agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/README.md +0 -0
- {agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/agent_framework_github_copilot/__init__.py +0 -0
{agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-framework-github-copilot
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0rc4
|
|
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,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.
|
|
19
|
+
Requires-Dist: agent-framework-core>=1.11.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
|
|
@@ -9,12 +9,7 @@ import logging
|
|
|
9
9
|
import sys
|
|
10
10
|
import warnings
|
|
11
11
|
from collections.abc import AsyncIterable, Awaitable, Callable, Mapping, MutableMapping, Sequence
|
|
12
|
-
from typing import Any, ClassVar, Generic, Literal, TypedDict, overload
|
|
13
|
-
|
|
14
|
-
if sys.version_info >= (3, 11):
|
|
15
|
-
from typing import Self # pragma: no cover
|
|
16
|
-
else:
|
|
17
|
-
from typing_extensions import Self # pragma: no cover
|
|
12
|
+
from typing import Any, ClassVar, Generic, Literal, TypedDict, cast, overload
|
|
18
13
|
|
|
19
14
|
from agent_framework import (
|
|
20
15
|
AgentMiddlewareLayer,
|
|
@@ -29,6 +24,8 @@ from agent_framework import (
|
|
|
29
24
|
Message,
|
|
30
25
|
ResponseStream,
|
|
31
26
|
SessionContext,
|
|
27
|
+
UsageDetails,
|
|
28
|
+
add_usage_details,
|
|
32
29
|
normalize_messages,
|
|
33
30
|
)
|
|
34
31
|
from agent_framework._settings import load_settings
|
|
@@ -37,6 +34,15 @@ from agent_framework._types import AgentRunInputs, normalize_tools
|
|
|
37
34
|
from agent_framework.exceptions import AgentException
|
|
38
35
|
from agent_framework.observability import AgentTelemetryLayer
|
|
39
36
|
|
|
37
|
+
if sys.version_info >= (3, 11):
|
|
38
|
+
from typing import Self # pragma: no cover
|
|
39
|
+
else:
|
|
40
|
+
from typing_extensions import Self # pragma: no cover
|
|
41
|
+
if sys.version_info >= (3, 13):
|
|
42
|
+
from typing import TypeVar # pragma: no cover
|
|
43
|
+
else:
|
|
44
|
+
from typing_extensions import TypeVar # pragma: no cover
|
|
45
|
+
|
|
40
46
|
try:
|
|
41
47
|
from copilot import CopilotClient, CopilotSession, RuntimeConnection
|
|
42
48
|
from copilot.generated.rpc import PermissionDecisionUserNotAvailable
|
|
@@ -49,7 +55,7 @@ try:
|
|
|
49
55
|
SessionHooks,
|
|
50
56
|
SystemMessageConfig,
|
|
51
57
|
)
|
|
52
|
-
from copilot.session_events import PermissionRequest, SessionEvent, SessionEventType
|
|
58
|
+
from copilot.session_events import AssistantUsageData, PermissionRequest, SessionEvent, SessionEventType
|
|
53
59
|
from copilot.tools import Tool as CopilotTool
|
|
54
60
|
from copilot.tools import ToolInvocation, ToolResult
|
|
55
61
|
except ImportError as _copilot_import_error:
|
|
@@ -58,12 +64,6 @@ except ImportError as _copilot_import_error:
|
|
|
58
64
|
"Please use Python 3.11 or later."
|
|
59
65
|
) from _copilot_import_error
|
|
60
66
|
|
|
61
|
-
if sys.version_info >= (3, 13):
|
|
62
|
-
from typing import TypeVar # pragma: no cover
|
|
63
|
-
else:
|
|
64
|
-
from typing_extensions import TypeVar # pragma: no cover
|
|
65
|
-
|
|
66
|
-
|
|
67
67
|
DEFAULT_TIMEOUT_SECONDS: float = 60.0
|
|
68
68
|
"""Default timeout in seconds for Copilot requests."""
|
|
69
69
|
|
|
@@ -162,7 +162,16 @@ class GitHubCopilotSettings(TypedDict, total=False):
|
|
|
162
162
|
|
|
163
163
|
|
|
164
164
|
class GitHubCopilotOptions(TypedDict, total=False):
|
|
165
|
-
"""GitHub Copilot-specific options.
|
|
165
|
+
"""GitHub Copilot-specific options.
|
|
166
|
+
|
|
167
|
+
The keys below have first-class typing and inline documentation because they are
|
|
168
|
+
the commonly used options. They are **not** an exhaustive list: any other
|
|
169
|
+
parameter accepted by the Copilot SDK's ``create_session`` (for example
|
|
170
|
+
``reasoning_effort``, ``context_tier``, ``enable_citations``, ``available_tools``,
|
|
171
|
+
``memory``, ...) may also be supplied and is forwarded verbatim to the SDK. An
|
|
172
|
+
unrecognized parameter name surfaces as a ``TypeError`` from the SDK, so typos are
|
|
173
|
+
caught rather than silently ignored.
|
|
174
|
+
"""
|
|
166
175
|
|
|
167
176
|
system_message: SystemMessageConfig
|
|
168
177
|
"""System message configuration for the session. Use mode 'append' to add to the default
|
|
@@ -206,6 +215,18 @@ class GitHubCopilotOptions(TypedDict, total=False):
|
|
|
206
215
|
files beyond the default locations.
|
|
207
216
|
"""
|
|
208
217
|
|
|
218
|
+
skill_directories: list[str]
|
|
219
|
+
"""Directories containing SKILL.md files to load into the Copilot CLI session.
|
|
220
|
+
These are loaded natively by the Copilot CLI process, letting applications point
|
|
221
|
+
the CLI at project-specific or team-shared skills beyond the default locations.
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
disabled_skills: list[str]
|
|
225
|
+
"""Names of skills to disable for the session.
|
|
226
|
+
Lets applications opt out of specific skills that would otherwise be discovered
|
|
227
|
+
from ``skill_directories`` or the default locations.
|
|
228
|
+
"""
|
|
229
|
+
|
|
209
230
|
base_directory: str
|
|
210
231
|
"""Directory where the CLI stores session state, configuration, and other persistent data."""
|
|
211
232
|
|
|
@@ -343,9 +364,6 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
343
364
|
timeout = opts.pop("timeout", None)
|
|
344
365
|
log_level = opts.pop("log_level", None)
|
|
345
366
|
on_permission_request: PermissionHandlerType | None = opts.pop("on_permission_request", None)
|
|
346
|
-
mcp_servers: dict[str, MCPServerConfig] | None = opts.pop("mcp_servers", None)
|
|
347
|
-
provider: ProviderConfig | None = opts.pop("provider", None)
|
|
348
|
-
instruction_directories: list[str] | None = opts.pop("instruction_directories", None)
|
|
349
367
|
on_pre_tool_use: PreToolUseHandler | None = opts.pop("on_pre_tool_use", None)
|
|
350
368
|
on_function_approval: FunctionApprovalCallback | None = opts.pop("on_function_approval", None)
|
|
351
369
|
base_directory = opts.pop("base_directory", None)
|
|
@@ -383,9 +401,9 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
383
401
|
self._permission_handler = on_permission_request
|
|
384
402
|
self._on_pre_tool_use: PreToolUseHandler | None = on_pre_tool_use
|
|
385
403
|
self._function_approval_handler: FunctionApprovalCallback | None = on_function_approval
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
404
|
+
# Remaining options (e.g. mcp_servers, provider, instruction_directories,
|
|
405
|
+
# skill_directories, disabled_skills, and any other create_session parameter)
|
|
406
|
+
# are forwarded verbatim to the Copilot SDK by _build_session_kwargs.
|
|
389
407
|
self._default_options = opts
|
|
390
408
|
self._started = False
|
|
391
409
|
|
|
@@ -547,6 +565,27 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
547
565
|
)
|
|
548
566
|
return self._run_impl(messages=messages, session=session, options=options)
|
|
549
567
|
|
|
568
|
+
@staticmethod
|
|
569
|
+
def _parse_usage_details_from_copilot(data: AssistantUsageData) -> UsageDetails | None:
|
|
570
|
+
total_token_count = (
|
|
571
|
+
data.input_tokens + data.output_tokens
|
|
572
|
+
if data.input_tokens is not None and data.output_tokens is not None
|
|
573
|
+
else None
|
|
574
|
+
)
|
|
575
|
+
usage_details = UsageDetails(**{
|
|
576
|
+
key: value
|
|
577
|
+
for key, value in {
|
|
578
|
+
"input_token_count": data.input_tokens,
|
|
579
|
+
"output_token_count": data.output_tokens,
|
|
580
|
+
"total_token_count": total_token_count,
|
|
581
|
+
"cache_read_input_token_count": data.cache_read_tokens,
|
|
582
|
+
"cache_creation_input_token_count": data.cache_write_tokens,
|
|
583
|
+
"reasoning_output_token_count": data.reasoning_tokens,
|
|
584
|
+
}.items()
|
|
585
|
+
if value is not None
|
|
586
|
+
})
|
|
587
|
+
return usage_details or None
|
|
588
|
+
|
|
550
589
|
async def _run_impl(
|
|
551
590
|
self,
|
|
552
591
|
messages: AgentRunInputs | None = None,
|
|
@@ -586,6 +625,30 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
586
625
|
opts["tools"] = existing + list(session_context.tools)
|
|
587
626
|
|
|
588
627
|
copilot_session = await self._get_or_create_session(session, streaming=False, runtime_options=opts)
|
|
628
|
+
usage_details: UsageDetails | None = None
|
|
629
|
+
finish_reason: str | None = None
|
|
630
|
+
model: str | None = None
|
|
631
|
+
|
|
632
|
+
def usage_event_handler(event: SessionEvent) -> None:
|
|
633
|
+
nonlocal usage_details, finish_reason, model
|
|
634
|
+
if event.type != SessionEventType.ASSISTANT_USAGE:
|
|
635
|
+
return
|
|
636
|
+
if isinstance(event.data, AssistantUsageData):
|
|
637
|
+
parsed_usage_details = self._parse_usage_details_from_copilot(event.data)
|
|
638
|
+
if parsed_usage_details:
|
|
639
|
+
usage_details = add_usage_details(usage_details, parsed_usage_details)
|
|
640
|
+
event_finish_reason = (
|
|
641
|
+
"content_filter" if event.data.content_filter_triggered else event.data.finish_reason
|
|
642
|
+
)
|
|
643
|
+
if event_finish_reason:
|
|
644
|
+
finish_reason = event_finish_reason
|
|
645
|
+
if event.data.model:
|
|
646
|
+
model = event.data.model
|
|
647
|
+
else:
|
|
648
|
+
logger.warning(
|
|
649
|
+
"Ignoring GitHub Copilot assistant usage event with unexpected payload type: %s",
|
|
650
|
+
type(event.data).__name__,
|
|
651
|
+
)
|
|
589
652
|
|
|
590
653
|
# Build the prompt from the full set of messages in the session context,
|
|
591
654
|
# so that any context/history provider-injected messages are included.
|
|
@@ -594,10 +657,13 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
594
657
|
if session_context.instructions:
|
|
595
658
|
prompt = "\n".join(session_context.instructions) + "\n" + prompt
|
|
596
659
|
|
|
660
|
+
unsubscribe = copilot_session.on(usage_event_handler)
|
|
597
661
|
try:
|
|
598
662
|
response_event = await copilot_session.send_and_wait(prompt, timeout=timeout)
|
|
599
663
|
except Exception as ex:
|
|
600
664
|
raise AgentException(f"GitHub Copilot request failed: {ex}") from ex
|
|
665
|
+
finally:
|
|
666
|
+
unsubscribe()
|
|
601
667
|
|
|
602
668
|
response_messages: list[Message] = []
|
|
603
669
|
response_id: str | None = None
|
|
@@ -619,7 +685,13 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
619
685
|
)
|
|
620
686
|
response_id = message_id
|
|
621
687
|
|
|
622
|
-
response = AgentResponse(
|
|
688
|
+
response = AgentResponse(
|
|
689
|
+
messages=response_messages,
|
|
690
|
+
response_id=response_id,
|
|
691
|
+
finish_reason=cast(Any, finish_reason),
|
|
692
|
+
usage_details=usage_details,
|
|
693
|
+
additional_properties={"model": model} if model else None,
|
|
694
|
+
)
|
|
623
695
|
session_context._response = response # type: ignore[assignment]
|
|
624
696
|
await self._run_after_providers(session=session, context=session_context)
|
|
625
697
|
return response
|
|
@@ -705,6 +777,26 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
705
777
|
raw_representation=event,
|
|
706
778
|
)
|
|
707
779
|
queue.put_nowait(update)
|
|
780
|
+
elif event.type == SessionEventType.ASSISTANT_USAGE:
|
|
781
|
+
if not isinstance(event.data, AssistantUsageData):
|
|
782
|
+
logger.warning(
|
|
783
|
+
"Ignoring GitHub Copilot assistant usage event with unexpected payload type: %s",
|
|
784
|
+
type(event.data).__name__,
|
|
785
|
+
)
|
|
786
|
+
return
|
|
787
|
+
usage_details = self._parse_usage_details_from_copilot(event.data)
|
|
788
|
+
finish_reason = "content_filter" if event.data.content_filter_triggered else event.data.finish_reason
|
|
789
|
+
model = event.data.model or None
|
|
790
|
+
if usage_details or finish_reason or model:
|
|
791
|
+
update = AgentResponseUpdate(
|
|
792
|
+
contents=[Content.from_usage(usage_details, raw_representation=event.data)]
|
|
793
|
+
if usage_details
|
|
794
|
+
else None,
|
|
795
|
+
finish_reason=cast(Any, finish_reason),
|
|
796
|
+
additional_properties={"model": model} if model else None,
|
|
797
|
+
raw_representation=event,
|
|
798
|
+
)
|
|
799
|
+
queue.put_nowait(update)
|
|
708
800
|
elif event.type == SessionEventType.TOOL_EXECUTION_START:
|
|
709
801
|
tool_call_id = getattr(event.data, "tool_call_id", None) or ""
|
|
710
802
|
tool_name = getattr(event.data, "tool_name", None) or ""
|
|
@@ -912,7 +1004,7 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
912
1004
|
def _build_session_hooks(
|
|
913
1005
|
self,
|
|
914
1006
|
all_tools: Sequence[ToolTypes | CopilotTool],
|
|
915
|
-
|
|
1007
|
+
options: Mapping[str, Any],
|
|
916
1008
|
) -> SessionHooks | None:
|
|
917
1009
|
"""Build the ``SessionHooks`` to pass to the Copilot SDK for this session.
|
|
918
1010
|
|
|
@@ -920,11 +1012,14 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
920
1012
|
``approval_mode="always_require"`` is delegated to the Copilot SDK's native
|
|
921
1013
|
``on_pre_tool_use`` hook:
|
|
922
1014
|
|
|
923
|
-
- If the caller supplies their own
|
|
924
|
-
|
|
1015
|
+
- If the caller supplies their own session hooks -- either the SDK-native
|
|
1016
|
+
``hooks`` dict or the convenience ``on_pre_tool_use`` handler (via per-run
|
|
1017
|
+
``options`` or ``default_options``) -- those take precedence and are used
|
|
1018
|
+
as-is. When both are given, the explicit ``hooks`` dict wins for any key it
|
|
1019
|
+
defines and the ``on_pre_tool_use`` shortcut fills in that key otherwise. A
|
|
925
1020
|
warning is logged naming any approval-required tool that will therefore not
|
|
926
|
-
be automatically gated, since the caller's
|
|
927
|
-
approval.
|
|
1021
|
+
be automatically gated, since the caller's hooks are responsible for
|
|
1022
|
+
enforcing approval.
|
|
928
1023
|
- Otherwise, when any approval-required tool is present, a default hook is
|
|
929
1024
|
installed that returns ``"ask"`` for those tools (routing the decision to
|
|
930
1025
|
``on_permission_request``) and defers (``None``) for all other tools.
|
|
@@ -932,32 +1027,43 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
932
1027
|
``on_function_approval`` callback is configured: in that case approval is
|
|
933
1028
|
enforced inside the tool handler (see :meth:`_tool_to_copilot_tool`) to
|
|
934
1029
|
preserve backward-compatible behavior.
|
|
935
|
-
- When there are no approval-required tools and no caller
|
|
1030
|
+
- When there are no approval-required tools and no caller hooks, ``None`` is
|
|
936
1031
|
returned so no hooks are registered.
|
|
937
1032
|
|
|
938
1033
|
Args:
|
|
939
1034
|
all_tools: The full set of tools resolved for the session.
|
|
940
|
-
|
|
1035
|
+
options: The merged session options (``default_options`` overlaid with
|
|
1036
|
+
per-run ``options``).
|
|
941
1037
|
|
|
942
1038
|
Returns:
|
|
943
1039
|
The hooks to register for the session, or ``None`` if none are needed.
|
|
944
1040
|
"""
|
|
945
|
-
user_hook: PreToolUseHandler | None =
|
|
1041
|
+
user_hook: PreToolUseHandler | None = options.get("on_pre_tool_use") or self._on_pre_tool_use
|
|
1042
|
+
caller_hooks: Mapping[str, Any] | None = options.get("hooks")
|
|
1043
|
+
|
|
1044
|
+
# Combine caller-provided hooks: the SDK-native ``hooks`` dict plus the
|
|
1045
|
+
# convenience ``on_pre_tool_use`` shortcut. The explicit dict wins for the
|
|
1046
|
+
# keys it defines; the shortcut only fills in ``on_pre_tool_use`` otherwise.
|
|
1047
|
+
combined: dict[str, Any] = {}
|
|
1048
|
+
if user_hook is not None:
|
|
1049
|
+
combined["on_pre_tool_use"] = user_hook
|
|
1050
|
+
if caller_hooks:
|
|
1051
|
+
combined.update(caller_hooks)
|
|
946
1052
|
|
|
947
1053
|
approval_required_names = {
|
|
948
1054
|
tool.name for tool in all_tools if isinstance(tool, FunctionTool) and tool.approval_mode == "always_require"
|
|
949
1055
|
}
|
|
950
1056
|
|
|
951
|
-
if
|
|
1057
|
+
if combined:
|
|
952
1058
|
if approval_required_names:
|
|
953
1059
|
logger.warning(
|
|
954
|
-
"
|
|
955
|
-
"will not be automatically gated by GitHubCopilotAgent. The custom
|
|
1060
|
+
"Custom session hooks are configured, so %d approval-required tool(s) (%s) "
|
|
1061
|
+
"will not be automatically gated by GitHubCopilotAgent. The custom hooks are responsible "
|
|
956
1062
|
"for enforcing approval (for example, by returning a 'deny' or 'ask' decision).",
|
|
957
1063
|
len(approval_required_names),
|
|
958
1064
|
", ".join(sorted(approval_required_names)),
|
|
959
1065
|
)
|
|
960
|
-
return
|
|
1066
|
+
return cast("SessionHooks", combined)
|
|
961
1067
|
|
|
962
1068
|
if not approval_required_names:
|
|
963
1069
|
return None
|
|
@@ -1007,7 +1113,12 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
1007
1113
|
|
|
1008
1114
|
try:
|
|
1009
1115
|
if agent_session.service_session_id:
|
|
1010
|
-
|
|
1116
|
+
service_session_id = agent_session.service_session_id
|
|
1117
|
+
if not isinstance(service_session_id, str):
|
|
1118
|
+
raise AgentException(
|
|
1119
|
+
"GitHubCopilotAgent expects a string service_session_id for session resumption."
|
|
1120
|
+
)
|
|
1121
|
+
return await self._resume_session(service_session_id, streaming, runtime_options)
|
|
1011
1122
|
|
|
1012
1123
|
session = await self._create_session(streaming, runtime_options)
|
|
1013
1124
|
agent_session.service_session_id = session.session_id
|
|
@@ -1015,6 +1126,57 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
1015
1126
|
except Exception as ex:
|
|
1016
1127
|
raise AgentException(f"Failed to create GitHub Copilot session: {ex}") from ex
|
|
1017
1128
|
|
|
1129
|
+
def _build_session_kwargs(
|
|
1130
|
+
self,
|
|
1131
|
+
streaming: bool,
|
|
1132
|
+
runtime_options: dict[str, Any] | None,
|
|
1133
|
+
) -> dict[str, Any]:
|
|
1134
|
+
"""Assemble keyword arguments for ``create_session`` / ``resume_session``.
|
|
1135
|
+
|
|
1136
|
+
Options are layered: the agent's ``default_options`` first, then per-run
|
|
1137
|
+
``runtime_options`` which override them. Every key is forwarded verbatim to
|
|
1138
|
+
the Copilot SDK, so any ``create_session`` parameter is supported without a
|
|
1139
|
+
dedicated mapping here (an unknown name surfaces as a ``TypeError`` from the
|
|
1140
|
+
SDK). A few keys are handled specially because they need a secure default
|
|
1141
|
+
(``on_permission_request`` defaults to denying all requests) or transforming:
|
|
1142
|
+
``tools`` are merged with the agent's tools and converted to SDK tools, and
|
|
1143
|
+
approval callbacks are turned into ``hooks``.
|
|
1144
|
+
|
|
1145
|
+
Args:
|
|
1146
|
+
streaming: Whether to enable streaming for the session.
|
|
1147
|
+
runtime_options: Runtime options that take precedence over default_options.
|
|
1148
|
+
|
|
1149
|
+
Returns:
|
|
1150
|
+
The keyword arguments to splat into the SDK session factory.
|
|
1151
|
+
"""
|
|
1152
|
+
opts = runtime_options or {}
|
|
1153
|
+
|
|
1154
|
+
# Passthrough layer: agent defaults first, per-run options override.
|
|
1155
|
+
kwargs: dict[str, Any] = {**self._default_options, **opts}
|
|
1156
|
+
|
|
1157
|
+
# Merge agent-level tools with any caller-supplied tools (from default_options
|
|
1158
|
+
# or per-run options, the latter winning) and convert to SDK tools.
|
|
1159
|
+
all_tools = list(self._tools or []) + list(kwargs.get("tools") or [])
|
|
1160
|
+
kwargs["tools"] = self._prepare_tools(all_tools) if all_tools else None
|
|
1161
|
+
|
|
1162
|
+
kwargs["streaming"] = streaming
|
|
1163
|
+
# model may already be present from per-run options (merged above); otherwise fall
|
|
1164
|
+
# back to the resolved setting (which carries the default_options / env model).
|
|
1165
|
+
if not kwargs.get("model"):
|
|
1166
|
+
kwargs["model"] = self._settings.get("model") or None
|
|
1167
|
+
kwargs["on_permission_request"] = (
|
|
1168
|
+
opts.get("on_permission_request") or self._permission_handler or _deny_all_permissions
|
|
1169
|
+
)
|
|
1170
|
+
kwargs["hooks"] = self._build_session_hooks(all_tools, kwargs)
|
|
1171
|
+
|
|
1172
|
+
# Strip agent-internal and client-level keys that are consumed here or in the
|
|
1173
|
+
# run methods (and settings) but are NOT valid create_session parameters, so
|
|
1174
|
+
# they don't leak through the passthrough layer and raise TypeError.
|
|
1175
|
+
for key in ("on_pre_tool_use", "on_function_approval", "timeout", "cli_path", "log_level", "base_directory"):
|
|
1176
|
+
kwargs.pop(key, None)
|
|
1177
|
+
|
|
1178
|
+
return kwargs
|
|
1179
|
+
|
|
1018
1180
|
async def _create_session(
|
|
1019
1181
|
self,
|
|
1020
1182
|
streaming: bool,
|
|
@@ -1029,30 +1191,7 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
1029
1191
|
if not self._client:
|
|
1030
1192
|
raise RuntimeError("GitHub Copilot client not initialized. Call start() first.")
|
|
1031
1193
|
|
|
1032
|
-
|
|
1033
|
-
model = opts.get("model") or self._settings.get("model") or None
|
|
1034
|
-
system_message = opts.get("system_message") or self._default_options.get("system_message") or None
|
|
1035
|
-
permission_handler: PermissionHandlerType = (
|
|
1036
|
-
opts.get("on_permission_request") or self._permission_handler or _deny_all_permissions
|
|
1037
|
-
)
|
|
1038
|
-
mcp_servers = opts.get("mcp_servers") or self._mcp_servers or None
|
|
1039
|
-
provider = opts.get("provider") or self._provider or None
|
|
1040
|
-
instruction_directories = opts.get("instruction_directories", self._instruction_directories)
|
|
1041
|
-
all_tools = list(self._tools or []) + list(opts.get("tools") or [])
|
|
1042
|
-
tools = self._prepare_tools(all_tools) if all_tools else None
|
|
1043
|
-
hooks = self._build_session_hooks(all_tools, opts)
|
|
1044
|
-
|
|
1045
|
-
return await self._client.create_session(
|
|
1046
|
-
on_permission_request=permission_handler,
|
|
1047
|
-
streaming=streaming,
|
|
1048
|
-
model=model or None,
|
|
1049
|
-
system_message=system_message or None,
|
|
1050
|
-
tools=tools or None,
|
|
1051
|
-
mcp_servers=mcp_servers or None,
|
|
1052
|
-
provider=provider or None,
|
|
1053
|
-
instruction_directories=instruction_directories,
|
|
1054
|
-
hooks=hooks,
|
|
1055
|
-
)
|
|
1194
|
+
return await self._client.create_session(**self._build_session_kwargs(streaming, runtime_options))
|
|
1056
1195
|
|
|
1057
1196
|
async def _resume_session(
|
|
1058
1197
|
self,
|
|
@@ -1070,31 +1209,7 @@ class RawGitHubCopilotAgent(BaseAgent, Generic[OptionsT]):
|
|
|
1070
1209
|
if not self._client:
|
|
1071
1210
|
raise RuntimeError("GitHub Copilot client not initialized. Call start() first.")
|
|
1072
1211
|
|
|
1073
|
-
|
|
1074
|
-
model = opts.get("model") or self._settings.get("model") or None
|
|
1075
|
-
system_message = opts.get("system_message") or self._default_options.get("system_message") or None
|
|
1076
|
-
permission_handler: PermissionHandlerType = (
|
|
1077
|
-
opts.get("on_permission_request") or self._permission_handler or _deny_all_permissions
|
|
1078
|
-
)
|
|
1079
|
-
mcp_servers = opts.get("mcp_servers") or self._mcp_servers or None
|
|
1080
|
-
provider = opts.get("provider") or self._provider or None
|
|
1081
|
-
instruction_directories = opts.get("instruction_directories", self._instruction_directories)
|
|
1082
|
-
all_tools = list(self._tools or []) + list(opts.get("tools") or [])
|
|
1083
|
-
tools = self._prepare_tools(all_tools) if all_tools else None
|
|
1084
|
-
hooks = self._build_session_hooks(all_tools, opts)
|
|
1085
|
-
|
|
1086
|
-
return await self._client.resume_session(
|
|
1087
|
-
session_id,
|
|
1088
|
-
on_permission_request=permission_handler,
|
|
1089
|
-
streaming=streaming,
|
|
1090
|
-
model=model or None,
|
|
1091
|
-
system_message=system_message or None,
|
|
1092
|
-
tools=tools or None,
|
|
1093
|
-
mcp_servers=mcp_servers or None,
|
|
1094
|
-
provider=provider or None,
|
|
1095
|
-
instruction_directories=instruction_directories,
|
|
1096
|
-
hooks=hooks,
|
|
1097
|
-
)
|
|
1212
|
+
return await self._client.resume_session(session_id, **self._build_session_kwargs(streaming, runtime_options))
|
|
1098
1213
|
|
|
1099
1214
|
|
|
1100
1215
|
class GitHubCopilotAgent( # type: ignore[misc]
|
{agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/pyproject.toml
RENAMED
|
@@ -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.
|
|
7
|
+
version = "1.0.0rc4"
|
|
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,7 +23,7 @@ classifiers = [
|
|
|
23
23
|
"Typing :: Typed",
|
|
24
24
|
]
|
|
25
25
|
dependencies = [
|
|
26
|
-
"agent-framework-core>=1.
|
|
26
|
+
"agent-framework-core>=1.11.0,<2",
|
|
27
27
|
"github-copilot-sdk==1.0.2; python_version >= '3.11'",
|
|
28
28
|
]
|
|
29
29
|
|
|
@@ -102,4 +102,3 @@ interpreter = "posix"
|
|
|
102
102
|
[build-system]
|
|
103
103
|
requires = ["flit-core >= 3.11,<4.0"]
|
|
104
104
|
build-backend = "flit_core.buildapi"
|
|
105
|
-
|
|
File without changes
|
{agent_framework_github_copilot-1.0.0rc2 → agent_framework_github_copilot-1.0.0rc4}/README.md
RENAMED
|
File without changes
|