A programming framework for agentic AI
fix bug in dcp update for rpc requests (#4636)
Ryan Sweet0aeb78145f34
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentRuntime.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentRuntime.csindex 5cf32e14c..efa5fe1b6 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentRuntime.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/AgentRuntime.cs@@ -46,7 +46,18 @@ internal sealed class AgentRuntime(AgentId agentId, IAgentWorker worker, ILogger}public void Update(RpcRequest request, Activity? activity = null){- DistributedContextPropagator.Inject(activity, request.Metadata, static (carrier, key, value) => ((IDictionary<string, string>)carrier!)[key] = value);+ DistributedContextPropagator.Inject(activity, request.Metadata, static (carrier, key, value) =>+ {+ var metadata = (IDictionary<string, string>)carrier!;+ if (metadata.TryGetValue(key, out _))+ {+ metadata[key] = value;+ }+ else+ {+ metadata.Add(key, value);+ }+ });}public void Update(CloudEvent cloudEvent, Activity? activity = null){