From c59216659bb8e0af7b3e0ca322fc7ae35ef40413 Mon Sep 17 00:00:00 2001 From: Jack Date: Mon, 21 Jul 2025 14:38:54 +0800 Subject: [PATCH] fix concurrent issue Operations that change non-concurrent collections must have exclusive access --- .../Agents/Services/AgentService.Rendering.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.Rendering.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.Rendering.cs index ffaffb476..9059dbf2b 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.Rendering.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.Rendering.cs @@ -17,13 +17,14 @@ public string RenderedInstruction(Agent agent) instructions.AddRange(secondaryInstructions); // update states + var renderDict = new Dictionary(agent.TemplateDict); foreach (var t in conv.States.GetStates()) { - agent.TemplateDict[t.Key] = t.Value; + renderDict[t.Key] = t.Value; } - agent.TemplateDict[TemplateRenderConstant.RENDER_AGENT] = agent; - var res = render.Render(string.Join("\r\n", instructions), agent.TemplateDict); + renderDict[TemplateRenderConstant.RENDER_AGENT] = agent; + var res = render.Render(string.Join("\r\n", instructions), renderDict); return res; } @@ -143,4 +144,4 @@ public bool RenderVisibility(string? visibilityExpression, Dictionary