Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5837 +/- ##
==========================================
- Coverage 70.16% 70.14% -0.02%
==========================================
Files 262 263 +1
Lines 14712 14716 +4
Branches 243 243
==========================================
Hits 10322 10322
- Misses 4200 4204 +4
Partials 190 190
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7f1752a to
357cac8
Compare
There was a problem hiding this comment.
PR Overview
This PR implements five new AgentChat agents for the .NET project, mirroring existing Python agents. Key changes include new agent implementations (CodeExecutorAgent, UserProxyAgent, SocietyOfMindAgent, CodingAssistantAgent, and AssistantAgent), additions to shared abstractions (PromptTemplate, ICodeExecutor), and a new ToolManager component for tool/handoff handling.
Reviewed Changes
| File | Description |
|---|---|
| dotnet/src/Microsoft.AutoGen/AgentChat/Agents/CodeExecutorAgent.cs | Implements an agent to execute code blocks and return results (note a logic error in response construction and non‐standard collection initialization). |
| dotnet/src/Microsoft.AutoGen/AgentChat/Agents/UserProxyAgent.cs | Introduces an agent that proxies user input with custom async conversion (collection initializer syntax is used). |
| dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/PromptTemplate.cs | Implements a message templating mechanism with parameter checking and formatting (contains an invalid list initializer). |
| dotnet/src/Microsoft.AutoGen/Contracts/ICodeExecutor.cs | Defines code execution contracts and related types (includes a typo in documentation). |
| dotnet/src/Microsoft.AutoGen/AgentChat/Agents/SocietyOfMindAgent.cs | Provides an agent to manage conversation streams and handoffs (contains several instances of non‐standard empty list initializations). |
| dotnet/src/Microsoft.AutoGen/AgentChat/Agents/ToolManager.cs | Implements tool lookup/invocation logic along with handoff configuration (utilizes an invalid empty list initializer). |
| dotnet/src/Microsoft.AutoGen/AgentChat/Agents/CodingAssistantAgent.cs | Adds an agent for coding assistance based on a custom prompt and message translation. |
| dotnet/src/Microsoft.AutoGen/AgentChat/Agents/AssistantAgent.cs | Implements an assistant agent coordinating tool calls and model inferences (uses non‐standard collection initializers in several places). |
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
dotnet/src/Microsoft.AutoGen/AgentChat/Agents/CodeExecutorAgent.cs
Outdated
Show resolved
Hide resolved
Implements the pre-defined AgentChat agents: Assistant, CodeExecutor, CodingAssistant, SocietOfMind, and UserProxy, based on their Python counterparts.
357cac8 to
d8a6b6f
Compare
|
|
||
| if (handoffs.Count > 1) | ||
| { | ||
| throw new InvalidOperationException($"Multiple handoffs detected: {String.Join(", ", from handoff in handoffs select handoff.Name)}"); |
There was a problem hiding this comment.
It's possible that mutiple handoffs can happen. In that case it's better to warn and choose the first one, and remind user to disable parallel tool calling.
| namespace Microsoft.AutoGen.AgentChat.Agents; | ||
|
|
||
| // TODO: Replatfrom this on top of AssistantAgent | ||
| public class CodingAssistantAgent : ChatAgentBase |
There was a problem hiding this comment.
This class potentially is going to be depreciated. Consider removing it from the PR?
| // In the Python implementation AssistantAgent and SocietyOfMindAgent have different strategies for | ||
| // reducing on_messages to on_messages_stream. The former returns the first Response as the final | ||
| // result, while the latter takes the last | ||
| Response? response = null; |
There was a problem hiding this comment.
There should ever be only one. If there are more it's bug.
| public override async IAsyncEnumerable<ChatStreamFrame> StreamAsync(IEnumerable<ChatMessage> item, [EnumeratorCancellation] CancellationToken cancellationToken) | ||
| { | ||
| List<ChatMessage> delta = item.ToList(); | ||
| string taskSpecification = this.FormatTask(this.CreateTranscript(delta)); |
There was a problem hiding this comment.
We may use multi message list as a task for the inner team to avoid creating transcript string
| } | ||
| else | ||
| { | ||
| string prompt = this.FormatResponse(this.CreateTranscript(innerMessages.Skip(1))); |
There was a problem hiding this comment.
Same here we may use multi message list to get a model response rather than using a single transcript string.
| select this.toolManager.InvokeToolAsync(call, cancellationToken)) | ||
| .ToList(); | ||
|
|
||
| // TODO: Enable streaming the results as they come in, rather than in a batch? |
| }; | ||
|
|
||
| List<Task<FunctionResultContent>> toolCallTasks = (from call in calls | ||
| select this.toolManager.InvokeToolAsync(call, cancellationToken)) |
There was a problem hiding this comment.
If tools not found or parameter is incorrect. It's better to return a well formatted string with the error rather than throw. The model can use this to generate a new call again next time the agent is invoked.
rysweet
left a comment
There was a problem hiding this comment.
I think there are tests for tests for most of these (except prompt template) in the python side that we could port. if you don't get to it before me I'll try to do that - I'll check with you again before I start
|
Thanks for the great work on this! Could you please let us know when this implementation is expected to be available in a release? |
Implements the pre-defined AgentChat agents: Assistant, CodeExecutor, CodingAssistant, SocietOfMind, and UserProxy, based on their Python counterparts.
Closes #5802