diff --git a/Directory.Build.props b/Directory.Build.props index 95c90ef7..85e3ec9c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ 10.0 ..\..\..\packages - 0.14.8 + 0.14.9 true \ No newline at end of file diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj index 20c0d75e..be7abdbd 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj +++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj @@ -56,7 +56,7 @@ - + diff --git a/src/Infrastructure/BotSharp.Core/Routing/Handlers/RoutingHandlerBase.cs b/src/Infrastructure/BotSharp.Core/Routing/Handlers/RoutingHandlerBase.cs index 639904be..0af2f01d 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/Handlers/RoutingHandlerBase.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/Handlers/RoutingHandlerBase.cs @@ -65,10 +65,20 @@ public abstract class RoutingHandlerBase args = JsonSerializer.Deserialize(response.Content); // Sometimes it populate malformed Function in Agent name - if (args.Function == args.AgentName) + if (!string.IsNullOrEmpty(args.Function) && args.Function == args.AgentName) { args.Function = "route_to_agent"; - _logger.LogWarning($"Captured LLM response "); + _logger.LogWarning($"Captured LLM malformed response"); + } + + // Another case of malformed response + var agentService = _services.GetRequiredService(); + var agents = await agentService.GetAgents(); + if (string.IsNullOrEmpty(args.AgentName) && agents.Select(x => x.Name).Contains(args.Function)) + { + args.AgentName = args.Function; + args.Function = "route_to_agent"; + _logger.LogWarning($"Captured LLM malformed response"); } } catch (Exception ex)