diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 20d26f7ee5fa..8a76bde68948 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -106,6 +106,11 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' + - if: matrix.build-mode == 'manual' + name: Setup .NET 9.0 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' - if: matrix.build-mode == 'manual' shell: bash working-directory: dotnet diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index a485f9ddd799..3d83bdf39d19 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -81,6 +81,10 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' + - name: Setup .NET 9.0 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' - name: Restore dependencies run: dotnet restore -bl - name: Format check @@ -207,6 +211,10 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' + - name: Setup .NET 9.0 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' - name: publish AOT testApp, assert static analysis warning count, and run the app shell: pwsh @@ -249,6 +257,10 @@ jobs: with: dotnet-version: '8.0.x' global-json-file: dotnet/global.json + - name: Setup .NET 9.0 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' - name: Install dev certs run: dotnet --version && dotnet dev-certs https --trust - name: Restore dependencies diff --git a/dotnet/.tools/test-aot-compatibility.ps1 b/dotnet/.tools/test-aot-compatibility.ps1 index d70139fd1fd2..2579d3fef6d3 100644 --- a/dotnet/.tools/test-aot-compatibility.ps1 +++ b/dotnet/.tools/test-aot-compatibility.ps1 @@ -15,7 +15,7 @@ foreach ($line in $($publishOutput -split "`r`n")) } } -pushd $rootDirectory/artifacts/bin/AutoGen.AotCompatibility.Tests/release +pushd $rootDirectory/artifacts/bin/AutoGen.AotCompatibility.Tests/release/native Write-Host "Executing test App..." ./AutoGen.AotCompatibility.Tests diff --git a/dotnet/global.json b/dotnet/global.json index 4f9e9b79a15a..cdbb589edad7 100644 --- a/dotnet/global.json +++ b/dotnet/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.401", - "rollForward": "latestMinor" + "version": "9.0.100", + "rollForward": "latestFeature" } } diff --git a/dotnet/samples/AgentChat/AutoGen.OpenAI.Sample/Tool_Call_With_Ollama_And_LiteLLM.cs b/dotnet/samples/AgentChat/AutoGen.OpenAI.Sample/Tool_Call_With_Ollama_And_LiteLLM.cs index 05c09f49dfdd..687281b3219f 100644 --- a/dotnet/samples/AgentChat/AutoGen.OpenAI.Sample/Tool_Call_With_Ollama_And_LiteLLM.cs +++ b/dotnet/samples/AgentChat/AutoGen.OpenAI.Sample/Tool_Call_With_Ollama_And_LiteLLM.cs @@ -42,8 +42,6 @@ public static async Task RunAsync() }); #endregion Create_tools #region Create_Agent - var liteLLMUrl = "http://localhost:4000"; - // api-key is not required for local server // so you can use any string here var openAIClient = new OpenAIClient(new ApiKeyCredential("api-key"), new OpenAIClientOptions @@ -59,7 +57,7 @@ public static async Task RunAsync() .RegisterMiddleware(functionMiddleware) .RegisterPrintMessage(); - var reply = await agent.SendAsync("what's the weather in new york"); + await agent.SendAsync("what's the weather in new york"); #endregion Create_Agent } } diff --git a/dotnet/samples/AgentChat/AutoGen.WebAPI.Sample/Program.cs b/dotnet/samples/AgentChat/AutoGen.WebAPI.Sample/Program.cs index 18ce4b023907..315ac00554fa 100644 --- a/dotnet/samples/AgentChat/AutoGen.WebAPI.Sample/Program.cs +++ b/dotnet/samples/AgentChat/AutoGen.WebAPI.Sample/Program.cs @@ -40,6 +40,6 @@ public async IAsyncEnumerable GenerateStreamingReplyAsync(IEnumerable< foreach (var c in reply) { yield return new TextMessageUpdate(Role.Assistant, c.ToString(), this.Name); - }; + } } } diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/ChatAgent.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/ChatAgent.cs index 6cad4f88dfe2..b4cf2f738f46 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/ChatAgent.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/ChatAgent.cs @@ -170,24 +170,23 @@ public interface IChatAgent : /// /// The name of the agent. This is used by team to uniquely identify the agent.It should be unique within the team. /// - AgentName Name { get; } + public AgentName Name { get; } /// /// The description of the agent. This is used by team to make decisions about which agents to use.The description /// should describe the agent's capabilities and how to interact with it. /// - string Description { get; } + public string Description { get; } /// /// The types of messages that the agent produces. /// - IEnumerable ProducedMessageTypes { get; } // TODO: Is there a way to make this part of the type somehow? - // Annotations, or IProduce<>? Do we ever actually access this? + public IEnumerable ProducedMessageTypes { get; } // TODO: Is there a way to make this part of the type somehow? Annotations, or IProduce<>? Do we ever actually access this? /// /// Reset the agent to its initialization state. /// /// /// - ValueTask ResetAsync(CancellationToken cancellationToken); + public ValueTask ResetAsync(CancellationToken cancellationToken); } diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/MessageHandling.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/MessageHandling.cs index 4183723e8c81..4239e6135b8e 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/MessageHandling.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/MessageHandling.cs @@ -5,22 +5,22 @@ namespace Microsoft.AutoGen.AgentChat.Abstractions; public interface IHandleChat { - ValueTask HandleAsync(TIn item) + public ValueTask HandleAsync(TIn item) { return this.HandleAsync(item, CancellationToken.None); } - ValueTask HandleAsync(TIn item, CancellationToken cancellationToken); + public ValueTask HandleAsync(TIn item, CancellationToken cancellationToken); } public interface IHandleChat // TODO: Map this to IHandle<> somehow? { - ValueTask HandleAsync(TIn item) + public ValueTask HandleAsync(TIn item) { return this.HandleAsync(item, CancellationToken.None); } - ValueTask HandleAsync(TIn item, CancellationToken cancellationToken); + public ValueTask HandleAsync(TIn item, CancellationToken cancellationToken); } public interface IHandleDefault : IHandleChat @@ -29,10 +29,10 @@ public interface IHandleDefault : IHandleChat public interface IHandleStream { - IAsyncEnumerable StreamAsync(TIn item) + public IAsyncEnumerable StreamAsync(TIn item) { return this.StreamAsync(item, CancellationToken.None); } - IAsyncEnumerable StreamAsync(TIn item, CancellationToken cancellationToken); + public IAsyncEnumerable StreamAsync(TIn item, CancellationToken cancellationToken); } diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tasks.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tasks.cs index 2b4d66d93bdd..1c11bbaa6c3d 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tasks.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tasks.cs @@ -59,7 +59,7 @@ public interface ITaskRunner /// The task definition in text form. /// /// The result of running the task. - async ValueTask RunAsync(string task, CancellationToken cancellationToken = default) => + public async ValueTask RunAsync(string task, CancellationToken cancellationToken = default) => await this.RunAsync(ToMessage(task)!, cancellationToken); /// @@ -73,7 +73,7 @@ async ValueTask RunAsync(string task, CancellationToken cancellation /// /// The result of running the task. /// If no response is generated. - async ValueTask RunAsync(ChatMessage task, CancellationToken cancellationToken = default) + public async ValueTask RunAsync(ChatMessage task, CancellationToken cancellationToken = default) { await foreach (TaskFrame frame in this.StreamAsync(task, cancellationToken)) { @@ -98,7 +98,7 @@ async ValueTask RunAsync(ChatMessage task, CancellationToken cancell /// /// A stream of containing internal messages and intermediate results followed by /// the final - IAsyncEnumerable StreamAsync(string task, CancellationToken cancellationToken = default) => + public IAsyncEnumerable StreamAsync(string task, CancellationToken cancellationToken = default) => this.StreamAsync(ToMessage(task), cancellationToken); /// @@ -113,5 +113,5 @@ IAsyncEnumerable StreamAsync(string task, CancellationToken cancellat /// /// A stream of containing internal messages and intermediate results followed by /// the final - IAsyncEnumerable StreamAsync(ChatMessage? task, CancellationToken cancellationToken = default); + public IAsyncEnumerable StreamAsync(ChatMessage? task, CancellationToken cancellationToken = default); } diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs index f5cb00cfe979..352b2529821d 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Termination.cs @@ -19,7 +19,7 @@ public interface ITerminationCondition /// /// Checks if the termination condition has been reached /// - bool IsTerminated { get; } + public bool IsTerminated { get; } /// /// Check if the conversation should be terminated based on the messages received @@ -30,19 +30,19 @@ public interface ITerminationCondition /// A if the conversation should be terminated, or null /// otherwise. /// If the termination condition has already been reached. - ValueTask CheckAndUpdateAsync(IList messages); + public ValueTask CheckAndUpdateAsync(IList messages); /// /// Resets the termination condition. /// - void Reset(); + public void Reset(); /// /// Combine this termination condition with another using a logical OR. /// /// Another termination condition. /// The combined termination condition, with appropriate short-circuiting. - ITerminationCondition Or(ITerminationCondition other) + public ITerminationCondition Or(ITerminationCondition other) { return new CombinerCondition(CombinerCondition.Or, this, other); } @@ -52,7 +52,7 @@ ITerminationCondition Or(ITerminationCondition other) /// /// Another termination condition. /// The combined termination condition, with appropriate short-circuiting. - ITerminationCondition And(ITerminationCondition other) + public ITerminationCondition And(ITerminationCondition other) { return new CombinerCondition(CombinerCondition.And, this, other); } diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tools.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tools.cs index fe10182d11bf..1c0c276b7bbf 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tools.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/Abstractions/Tools.cs @@ -82,8 +82,8 @@ public static ParameterSchema Create(Type type, string name, bool isRequired = f /// public interface ITool { - string Name { get; } - string Description { get; } + public string Name { get; } + public string Description { get; } public IEnumerable Parameters { get; } public Type ReturnType { get; } diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs index 5192cac6d086..f6ec12ca8427 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatBase.cs @@ -114,7 +114,7 @@ public virtual TManager CreateChatManager(GroupChatOptions options) if (Activator.CreateInstance(typeof(TManager), options) is TManager result) { return result; - }; + } } catch (TargetInvocationException tie) { diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatHandlerRouter.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatHandlerRouter.cs index 9855dcafb7ea..fabcc574df8d 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatHandlerRouter.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/GroupChatHandlerRouter.cs @@ -11,8 +11,8 @@ namespace Microsoft.AutoGen.AgentChat.GroupChat; internal interface IGroupChatHandler : IHandle, IHandle, IHandle { - void AttachMessagePublishServicer(MessagePublishServicer? servicer = null); - void DetachMessagePublishServicer() => this.AttachMessagePublishServicer(null); + public void AttachMessagePublishServicer(MessagePublishServicer? servicer = null); + public void DetachMessagePublishServicer() => this.AttachMessagePublishServicer(null); } internal sealed class GroupChatHandlerRouter : HostableAgentAdapter, diff --git a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/OutputCollectorAgent.cs b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/OutputCollectorAgent.cs index d17fa266b6aa..3c9fd61019be 100644 --- a/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/OutputCollectorAgent.cs +++ b/dotnet/src/Microsoft.AutoGen/AgentChat/GroupChat/OutputCollectorAgent.cs @@ -11,8 +11,8 @@ namespace Microsoft.AutoGen.AgentChat.Abstractions; internal interface IOutputCollectionSink { - void CollectMessage(AgentMessage message); - void Terminate(StopMessage message); + public void CollectMessage(AgentMessage message); + public void Terminate(StopMessage message); } internal sealed class OutputSink : IOutputCollectionSink diff --git a/dotnet/src/Microsoft.AutoGen/Core.Grpc/GrpcMessageRouter.cs b/dotnet/src/Microsoft.AutoGen/Core.Grpc/GrpcMessageRouter.cs index 32317cbc7a30..26d3827b0ff3 100644 --- a/dotnet/src/Microsoft.AutoGen/Core.Grpc/GrpcMessageRouter.cs +++ b/dotnet/src/Microsoft.AutoGen/Core.Grpc/GrpcMessageRouter.cs @@ -43,7 +43,7 @@ public void EnsureConnected() if (this.RecreateChannel(null) == null) { throw new Exception("Failed to connect to gRPC endpoint."); - }; + } } public AsyncDuplexStreamingCall StreamingCall @@ -117,8 +117,9 @@ internal sealed class GrpcMessageRouter(AgentRpc.AgentRpcClient client, private readonly CancellationTokenSource _shutdownCts = CancellationTokenSource.CreateLinkedTokenSource(shutdownCancellation); private readonly IMessageSink _incomingMessageSink = incomingMessageSink; + + // TODO: Enable a way to configure the channel options private readonly Channel<(Message Message, TaskCompletionSource WriteCompletionSource)> _outboundMessagesChannel - // TODO: Enable a way to configure the channel options = Channel.CreateBounded<(Message, TaskCompletionSource)>(DefaultChannelOptions); private readonly AutoRestartChannel _incomingMessageChannel = new AutoRestartChannel(client, clientId, logger, shutdownCancellation); diff --git a/dotnet/src/Microsoft.AutoGen/Core/ResultSink.cs b/dotnet/src/Microsoft.AutoGen/Core/ResultSink.cs index d103bdfda621..ef8958366a7b 100644 --- a/dotnet/src/Microsoft.AutoGen/Core/ResultSink.cs +++ b/dotnet/src/Microsoft.AutoGen/Core/ResultSink.cs @@ -7,11 +7,11 @@ namespace Microsoft.AutoGen.Core; internal interface IResultSink : IValueTaskSource { - void SetResult(TResult result); - void SetException(Exception exception); - void SetCancelled(); + public void SetResult(TResult result); + public void SetException(Exception exception); + public void SetCancelled(); - ValueTask Future { get; } + public ValueTask Future { get; } } public sealed class ResultSink : IResultSink diff --git a/dotnet/src/Microsoft.AutoGen/RuntimeGateway.Grpc/Services/Grpc/GrpcGateway.cs b/dotnet/src/Microsoft.AutoGen/RuntimeGateway.Grpc/Services/Grpc/GrpcGateway.cs index e657ac36fef0..97bc8df3f425 100644 --- a/dotnet/src/Microsoft.AutoGen/RuntimeGateway.Grpc/Services/Grpc/GrpcGateway.cs +++ b/dotnet/src/Microsoft.AutoGen/RuntimeGateway.Grpc/Services/Grpc/GrpcGateway.cs @@ -243,7 +243,7 @@ internal async Task OnReceivedMessageAsync(GrpcWorkerConnection connection, Mess default: await RespondBadRequestAsync(connection, $"Unknown message type for message '{message}'."); break; - }; + } } /// diff --git a/dotnet/test/AutoGen.AotCompatibility.Tests/AutoGen.AotCompatibility.Tests.csproj b/dotnet/test/AutoGen.AotCompatibility.Tests/AutoGen.AotCompatibility.Tests.csproj index 379bca541012..aec9660bb922 100644 --- a/dotnet/test/AutoGen.AotCompatibility.Tests/AutoGen.AotCompatibility.Tests.csproj +++ b/dotnet/test/AutoGen.AotCompatibility.Tests/AutoGen.AotCompatibility.Tests.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net8.0 enable enable true diff --git a/dotnet/test/AutoGen.Tests/MiddlewareTest.cs b/dotnet/test/AutoGen.Tests/MiddlewareTest.cs index 564406ec7469..7dd48fec646b 100644 --- a/dotnet/test/AutoGen.Tests/MiddlewareTest.cs +++ b/dotnet/test/AutoGen.Tests/MiddlewareTest.cs @@ -72,7 +72,7 @@ public async Task HumanInputMiddlewareTestAsync() public async Task FunctionCallMiddlewareTestAsync() { var agent = new EchoAgent("echo"); - var args = new EchoSchema { message = "hello" }; + var args = new AutoGen.Tests.MiddlewareTest.EchoSchema { message = "hello" }; // make the format check happy on linux var argsJson = JsonSerializer.Serialize(args) ?? throw new InvalidOperationException("Failed to serialize args"); var functionCall = new ToolCall("Echo", argsJson); var functionCallAgent = agent.RegisterMiddleware(async (messages, options, agent, ct) => diff --git a/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/TestGrpcWorkerConnection.cs b/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/TestGrpcWorkerConnection.cs index 20b8169db11f..2a4d9ea0ac53 100644 --- a/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/TestGrpcWorkerConnection.cs +++ b/dotnet/test/Microsoft.AutoGen.Core.Grpc.Tests/TestGrpcWorkerConnection.cs @@ -92,7 +92,7 @@ public async Task RunReadPump() default: // if it wasn't recognized return bad request throw new RpcException(new Status(StatusCode.InvalidArgument, $"Unknown message type for message '{message}'")); - }; + } } } catch (OperationCanceledException)