Skip to content

A programming framework for agentic AI

WriteAsync must be awaited (#4491)

Ryan Sweet79c5aaa1a4c6
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Services/Grpc/GrpcGateway.cs b/dotnet/src/Microsoft.AutoGen/Agents/Services/Grpc/GrpcGateway.cs
index ea488568e..9ba36410a 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Services/Grpc/GrpcGateway.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Services/Grpc/GrpcGateway.cs
@@ -137,7 +137,7 @@ public sealed class GrpcGateway : BackgroundService, IGateway
}
_subscriptionsByAgentType[agentType] = request.Subscription;
_subscriptionsByTopic.GetOrAdd(topic, _ => []).Add(agentType);
- await _subscriptions.Subscribe(topic, agentType);
+ await _subscriptions.SubscribeAsync(topic, agentType);
//var response = new AddSubscriptionResponse { RequestId = request.RequestId, Error = "", Success = true };
Message response = new()
{
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/ISubscriptionsGrain.cs b/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/ISubscriptionsGrain.cs
index 302df9ebf..d3af459bb 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/ISubscriptionsGrain.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/ISubscriptionsGrain.cs
@@ -4,7 +4,7 @@
namespace Microsoft.AutoGen.Agents;
public interface ISubscriptionsGrain : IGrainWithIntegerKey
{
- ValueTask Subscribe(string agentType, string topic);
- ValueTask Unsubscribe(string agentType, string topic);
+ ValueTask SubscribeAsync(string agentType, string topic);
+ ValueTask UnsubscribeAsync(string agentType, string topic);
ValueTask<Dictionary<string, List<string>>> GetSubscriptions(string agentType);
}
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.cs b/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.cs
index 682073f0b..0e647dbab 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Services/Orleans/SubscriptionsGrain.cs
@@ -15,7 +15,7 @@ internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore"
}
return new ValueTask<Dictionary<string, List<string>>>(_subscriptions);
}
- public ValueTask Subscribe(string agentType, string topic)
+ public async ValueTask SubscribeAsync(string agentType, string topic)
{
if (!_subscriptions.TryGetValue(topic, out var subscriptions))
{
@@ -27,11 +27,9 @@ internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore"
}
_subscriptions[topic] = subscriptions;
state.State.Subscriptions = _subscriptions;
- state.WriteStateAsync();
-
- return ValueTask.CompletedTask;
+ await state.WriteStateAsync().ConfigureAwait(false);
}
- public ValueTask Unsubscribe(string agentType, string topic)
+ public async ValueTask UnsubscribeAsync(string agentType, string topic)
{
if (!_subscriptions.TryGetValue(topic, out var subscriptions))
{
@@ -43,8 +41,7 @@ internal sealed class SubscriptionsGrain([PersistentState("state", "PubSubStore"
}
_subscriptions[topic] = subscriptions;
state.State.Subscriptions = _subscriptions;
- state.WriteStateAsync();
- return ValueTask.CompletedTask;
+ await state.WriteStateAsync();
}
}
public sealed class SubscriptionsState