mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a1ad0199a | ||
|
|
cbc471dc18 | ||
|
|
6ddb74f8b3 | ||
|
|
2f93971a59 | ||
|
|
93ccf52c39 |
@@ -98,7 +98,7 @@
|
|||||||
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.67.0-preview" />
|
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.67.0-preview" />
|
||||||
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.Qdrant" Version="1.67.0-preview" />
|
<PackageVersion Include="Microsoft.SemanticKernel.Connectors.Qdrant" Version="1.67.0-preview" />
|
||||||
<!-- Agent SDKs -->
|
<!-- Agent SDKs -->
|
||||||
<PackageVersion Include="GitHub.Copilot.SDK" Version="0.1.29" />
|
<PackageVersion Include="GitHub.Copilot.SDK" Version="1.0.0-beta.2" />
|
||||||
<PackageVersion Include="Microsoft.Agents.CopilotStudio.Client" Version="1.3.171-beta" />
|
<PackageVersion Include="Microsoft.Agents.CopilotStudio.Client" Version="1.3.171-beta" />
|
||||||
<!-- M365 Agents SDK -->
|
<!-- M365 Agents SDK -->
|
||||||
<PackageVersion Include="AdaptiveCards" Version="3.1.0" />
|
<PackageVersion Include="AdaptiveCards" Version="3.1.0" />
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ static Task<PermissionRequestResult> PromptPermission(PermissionRequest request,
|
|||||||
Console.Write("Approve? (y/n): ");
|
Console.Write("Approve? (y/n): ");
|
||||||
|
|
||||||
string? input = Console.ReadLine()?.Trim().ToUpperInvariant();
|
string? input = Console.ReadLine()?.Trim().ToUpperInvariant();
|
||||||
string kind = input is "Y" or "YES" ? "approved" : "denied-interactively-by-user";
|
PermissionRequestResultKind kind = input is "Y" or "YES"
|
||||||
|
? PermissionRequestResultKind.Approved
|
||||||
|
: PermissionRequestResultKind.Rejected;
|
||||||
|
|
||||||
return Task.FromResult(new PermissionRequestResult { Kind = kind });
|
return Task.FromResult(new PermissionRequestResult { Kind = kind });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public sealed class GitHubCopilotAgent : AIAgent, IAsyncDisposable
|
|||||||
string prompt = string.Join("\n", messages.Select(m => m.Text));
|
string prompt = string.Join("\n", messages.Select(m => m.Text));
|
||||||
|
|
||||||
// Handle DataContent as attachments
|
// Handle DataContent as attachments
|
||||||
(List<UserMessageDataAttachmentsItem>? attachments, tempDir) = await ProcessDataContentAttachmentsAsync(
|
(List<UserMessageAttachmentFile>? attachments, tempDir) = await ProcessDataContentAttachmentsAsync(
|
||||||
messages,
|
messages,
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
@@ -443,11 +443,11 @@ public sealed class GitHubCopilotAgent : AIAgent, IAsyncDisposable
|
|||||||
return new SessionConfig { Tools = mappedTools, SystemMessage = systemMessage };
|
return new SessionConfig { Tools = mappedTools, SystemMessage = systemMessage };
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<(List<UserMessageDataAttachmentsItem>? Attachments, string? TempDir)> ProcessDataContentAttachmentsAsync(
|
private static async Task<(List<UserMessageAttachmentFile>? Attachments, string? TempDir)> ProcessDataContentAttachmentsAsync(
|
||||||
IEnumerable<ChatMessage> messages,
|
IEnumerable<ChatMessage> messages,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
List<UserMessageDataAttachmentsItem>? attachments = null;
|
List<UserMessageAttachmentFile>? attachments = null;
|
||||||
string? tempDir = null;
|
string? tempDir = null;
|
||||||
foreach (ChatMessage message in messages)
|
foreach (ChatMessage message in messages)
|
||||||
{
|
{
|
||||||
@@ -461,7 +461,7 @@ public sealed class GitHubCopilotAgent : AIAgent, IAsyncDisposable
|
|||||||
string tempFilePath = await dataContent.SaveToAsync(tempDir, cancellationToken).ConfigureAwait(false);
|
string tempFilePath = await dataContent.SaveToAsync(tempDir, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
attachments ??= [];
|
attachments ??= [];
|
||||||
attachments.Add(new UserMessageDataAttachmentsItemFile
|
attachments.Add(new UserMessageAttachmentFile
|
||||||
{
|
{
|
||||||
Path = tempFilePath,
|
Path = tempFilePath,
|
||||||
DisplayName = Path.GetFileName(tempFilePath)
|
DisplayName = Path.GetFileName(tempFilePath)
|
||||||
|
|||||||
+5
-7
@@ -14,7 +14,7 @@ public class GitHubCopilotAgentTests
|
|||||||
private const string SkipReason = "Integration tests require GitHub Copilot CLI installed. For local execution only.";
|
private const string SkipReason = "Integration tests require GitHub Copilot CLI installed. For local execution only.";
|
||||||
|
|
||||||
private static Task<PermissionRequestResult> OnPermissionRequestAsync(PermissionRequest request, PermissionInvocation invocation)
|
private static Task<PermissionRequestResult> OnPermissionRequestAsync(PermissionRequest request, PermissionInvocation invocation)
|
||||||
=> Task.FromResult(new PermissionRequestResult { Kind = "approved" });
|
=> Task.FromResult(new PermissionRequestResult { Kind = PermissionRequestResultKind.Approved });
|
||||||
|
|
||||||
[Fact(Skip = SkipReason)]
|
[Fact(Skip = SkipReason)]
|
||||||
public async Task RunAsync_WithSimplePrompt_ReturnsResponseAsync()
|
public async Task RunAsync_WithSimplePrompt_ReturnsResponseAsync()
|
||||||
@@ -201,11 +201,10 @@ public class GitHubCopilotAgentTests
|
|||||||
SessionConfig sessionConfig = new()
|
SessionConfig sessionConfig = new()
|
||||||
{
|
{
|
||||||
OnPermissionRequest = OnPermissionRequestAsync,
|
OnPermissionRequest = OnPermissionRequestAsync,
|
||||||
McpServers = new Dictionary<string, object>
|
McpServers = new Dictionary<string, McpServerConfig>
|
||||||
{
|
{
|
||||||
["filesystem"] = new McpLocalServerConfig
|
["filesystem"] = new McpStdioServerConfig
|
||||||
{
|
{
|
||||||
Type = "stdio",
|
|
||||||
Command = "npx",
|
Command = "npx",
|
||||||
Args = ["-y", "@modelcontextprotocol/server-filesystem", "."],
|
Args = ["-y", "@modelcontextprotocol/server-filesystem", "."],
|
||||||
Tools = ["*"],
|
Tools = ["*"],
|
||||||
@@ -234,11 +233,10 @@ public class GitHubCopilotAgentTests
|
|||||||
SessionConfig sessionConfig = new()
|
SessionConfig sessionConfig = new()
|
||||||
{
|
{
|
||||||
OnPermissionRequest = OnPermissionRequestAsync,
|
OnPermissionRequest = OnPermissionRequestAsync,
|
||||||
McpServers = new Dictionary<string, object>
|
McpServers = new Dictionary<string, McpServerConfig>
|
||||||
{
|
{
|
||||||
["microsoft-learn"] = new McpRemoteServerConfig
|
["microsoft-learn"] = new McpHttpServerConfig
|
||||||
{
|
{
|
||||||
Type = "http",
|
|
||||||
Url = "https://learn.microsoft.com/api/mcp",
|
Url = "https://learn.microsoft.com/api/mcp",
|
||||||
Tools = ["*"],
|
Tools = ["*"],
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -111,7 +111,7 @@ public sealed class GitHubCopilotAgentTests
|
|||||||
var systemMessage = new SystemMessageConfig { Mode = SystemMessageMode.Append, Content = "Be helpful" };
|
var systemMessage = new SystemMessageConfig { Mode = SystemMessageMode.Append, Content = "Be helpful" };
|
||||||
PermissionRequestHandler permissionHandler = (_, _) => Task.FromResult(new PermissionRequestResult());
|
PermissionRequestHandler permissionHandler = (_, _) => Task.FromResult(new PermissionRequestResult());
|
||||||
UserInputHandler userInputHandler = (_, _) => Task.FromResult(new UserInputResponse { Answer = "input" });
|
UserInputHandler userInputHandler = (_, _) => Task.FromResult(new UserInputResponse { Answer = "input" });
|
||||||
var mcpServers = new Dictionary<string, object> { ["server1"] = new McpLocalServerConfig() };
|
var mcpServers = new Dictionary<string, McpServerConfig> { ["server1"] = new McpStdioServerConfig() };
|
||||||
|
|
||||||
var source = new SessionConfig
|
var source = new SessionConfig
|
||||||
{
|
{
|
||||||
@@ -162,7 +162,7 @@ public sealed class GitHubCopilotAgentTests
|
|||||||
var systemMessage = new SystemMessageConfig { Mode = SystemMessageMode.Append, Content = "Be helpful" };
|
var systemMessage = new SystemMessageConfig { Mode = SystemMessageMode.Append, Content = "Be helpful" };
|
||||||
PermissionRequestHandler permissionHandler = (_, _) => Task.FromResult(new PermissionRequestResult());
|
PermissionRequestHandler permissionHandler = (_, _) => Task.FromResult(new PermissionRequestResult());
|
||||||
UserInputHandler userInputHandler = (_, _) => Task.FromResult(new UserInputResponse { Answer = "input" });
|
UserInputHandler userInputHandler = (_, _) => Task.FromResult(new UserInputResponse { Answer = "input" });
|
||||||
var mcpServers = new Dictionary<string, object> { ["server1"] = new McpLocalServerConfig() };
|
var mcpServers = new Dictionary<string, McpServerConfig> { ["server1"] = new McpStdioServerConfig() };
|
||||||
|
|
||||||
var source = new SessionConfig
|
var source = new SessionConfig
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user