Fix CheckArgType null

This commit is contained in:
Haiping 2025-05-24 16:30:14 -05:00 committed by GitHub
parent bc72d661c8
commit ca36b140c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -415,7 +415,18 @@ public class ConversationStateService : IConversationStateService
private bool CheckArgType(string name, string value)
{
var agentTypes = AgentService.AgentParameterTypes.SelectMany(p => p.Value).ToList();
// Defensive: Ensure AgentParameterTypes is not null or empty and values are not null
if (AgentService.AgentParameterTypes == null || !AgentService.AgentParameterTypes.Any())
return true;
var agentTypes = AgentService.AgentParameterTypes
.Where(p => p.Value != null)
.SelectMany(p => p.Value)
.ToList();
if (agentTypes == null || agentTypes.Count == 0)
return true;
var found = agentTypes.FirstOrDefault(t => t.Key == name);
if (found.Key != null)
{