resolve conflict

This commit is contained in:
Jicheng Lu 2025-05-07 16:38:55 -05:00
commit 5c5c643856
3 changed files with 12 additions and 5 deletions

View file

@ -28,7 +28,7 @@ public class McpToolAgentHook : AgentHookBase
agent.SecondaryFunctions ??= [];
var functions = GetMcpContent(agent).Result;
agent.SecondaryFunctions = agent.SecondaryFunctions.Concat(functions).DistinctBy(x => x.Name).ToList();
agent.SecondaryFunctions = agent.SecondaryFunctions.Concat(functions).DistinctBy(x => x.Name, StringComparer.OrdinalIgnoreCase).ToList();
}
private async Task<IEnumerable<FunctionDef>> GetMcpContent(Agent agent)

View file

@ -25,12 +25,13 @@ public class BasicAgentHook : AgentHookBase
var (functions, templates) = GetUtilityContent(agent);
agent.SecondaryFunctions = agent.SecondaryFunctions.Concat(functions).DistinctBy(x => x.Name).ToList();
agent.SecondaryInstructions = agent.SecondaryInstructions.Concat(templates).Distinct().ToList();
agent.SecondaryFunctions = agent.SecondaryFunctions.Concat(functions).DistinctBy(x => x.Name, StringComparer.OrdinalIgnoreCase).ToList();
var contents = templates.Select(x => x.Content);
agent.SecondaryInstructions = agent.SecondaryInstructions.Concat(contents).Distinct(StringComparer.OrdinalIgnoreCase).ToList();
}
private (IEnumerable<FunctionDef>, IEnumerable<string>) GetUtilityContent(Agent agent)
private (IEnumerable<FunctionDef>, IEnumerable<AgentTemplate>) GetUtilityContent(Agent agent)
{
var db = _services.GetRequiredService<IBotSharpRepository>();
var (functionNames, templateNames) = GetUniqueContent(agent.Utilities);
@ -50,7 +51,7 @@ public class BasicAgentHook : AgentHookBase
var ua = db.GetAgent(BuiltInAgentId.UtilityAssistant);
var functions = ua?.Functions?.Where(x => functionNames.Contains(x.Name, StringComparer.OrdinalIgnoreCase))?.ToList() ?? [];
var templates = ua?.Templates?.Where(x => templateNames.Contains(x.Name, StringComparer.OrdinalIgnoreCase))?.Select(x => x.Content)?.ToList() ?? [];
var templates = ua?.Templates?.Where(x => templateNames.Contains(x.Name, StringComparer.OrdinalIgnoreCase))?.ToList() ?? [];
return (functions, templates);
}

View file

@ -167,6 +167,12 @@ public class TwilioInboundController : TwilioController
new("twilio_call_sid", request.CallSid),
};
if (request.Direction == "inbound")
{
states.Add(new MessageState("calling_phone_from", request.From));
states.Add(new MessageState("calling_phone_to", request.To));
}
var requestStates = ParseStates(request.States);
foreach (var s in requestStates)
{