diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
index 63594d08..e9fd7c5e 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
@@ -87,8 +87,12 @@ public class Agent
///
/// Profile by channel
///
- public List Profiles { get; set; }
- = new List();
+ public List Profiles { get; set; } = new();
+
+ ///
+ /// Merge utilities from entry agent
+ ///
+ public bool MergeUtility { get; set; }
///
/// Agent utilities
@@ -215,6 +219,12 @@ public class Agent
return this;
}
+ public Agent SetMergeUtility(bool merge)
+ {
+ MergeUtility = merge;
+ return this;
+ }
+
public Agent SetAgentType(string type)
{
Type = type;
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
index 1a333119..f871a2fe 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
@@ -1,5 +1,4 @@
using BotSharp.Abstraction.Repositories.Enums;
-using BotSharp.Abstraction.Routing.Models;
using BotSharp.Abstraction.Users.Enums;
using BotSharp.Abstraction.Users.Models;
using System.IO;
@@ -28,16 +27,17 @@ public partial class AgentService
record.Description = agent.Description ?? string.Empty;
record.IsPublic = agent.IsPublic;
record.Disabled = agent.Disabled;
+ record.MergeUtility = agent.MergeUtility;
record.Type = agent.Type;
- record.Profiles = agent.Profiles ?? new List();
- record.RoutingRules = agent.RoutingRules ?? new List();
+ record.Profiles = agent.Profiles ?? [];
+ record.RoutingRules = agent.RoutingRules ?? [];
record.Instruction = agent.Instruction ?? string.Empty;
- record.ChannelInstructions = agent.ChannelInstructions ?? new List();
- record.Functions = agent.Functions ?? new List();
- record.Templates = agent.Templates ?? new List();
- record.Responses = agent.Responses ?? new List();
- record.Samples = agent.Samples ?? new List();
- record.Utilities = agent.Utilities ?? new List();
+ record.ChannelInstructions = agent.ChannelInstructions ?? [];
+ record.Functions = agent.Functions ?? [];
+ record.Templates = agent.Templates ?? [];
+ record.Responses = agent.Responses ?? [];
+ record.Samples = agent.Samples ?? [];
+ record.Utilities = agent.Utilities ?? [];
if (agent.LlmConfig != null && !agent.LlmConfig.IsInherit)
{
record.LlmConfig = agent.LlmConfig;
@@ -90,6 +90,7 @@ public partial class AgentService
.SetDescription(foundAgent.Description)
.SetIsPublic(foundAgent.IsPublic)
.SetDisabled(foundAgent.Disabled)
+ .SetMergeUtility(foundAgent.MergeUtility)
.SetAgentType(foundAgent.Type)
.SetProfiles(foundAgent.Profiles)
.SetRoutingRules(foundAgent.RoutingRules)
diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
index de676d28..07915917 100644
--- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
+++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
@@ -55,7 +55,7 @@ namespace BotSharp.Core.Repository
UpdateAgentLlmConfig(agent.Id, agent.LlmConfig);
break;
case AgentField.Utility:
- UpdateAgentUtilities(agent.Id, agent.Utilities);
+ UpdateAgentUtilities(agent.Id, agent.MergeUtility, agent.Utilities);
break;
case AgentField.All:
UpdateAgentAllFields(agent);
@@ -151,13 +151,14 @@ namespace BotSharp.Core.Repository
File.WriteAllText(agentFile, json);
}
- private void UpdateAgentUtilities(string agentId, List utilities)
+ private void UpdateAgentUtilities(string agentId, bool mergeUtility, List utilities)
{
if (utilities == null) return;
var (agent, agentFile) = GetAgentFromFile(agentId);
if (agent == null) return;
+ agent.MergeUtility = mergeUtility;
agent.Utilities = utilities;
agent.UpdatedDateTime = DateTime.UtcNow;
var json = JsonSerializer.Serialize(agent, _options);
@@ -291,6 +292,7 @@ namespace BotSharp.Core.Repository
agent.Description = inputAgent.Description;
agent.IsPublic = inputAgent.IsPublic;
agent.Disabled = inputAgent.Disabled;
+ agent.MergeUtility = inputAgent.MergeUtility;
agent.Type = inputAgent.Type;
agent.Profiles = inputAgent.Profiles;
agent.Utilities = inputAgent.Utilities;
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs
index 4a41a8d8..32b3fdce 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs
@@ -48,6 +48,9 @@ public class AgentCreationModel
/// Combine different Agents together to form a Profile.
///
public List Profiles { get; set; } = new();
+
+ public bool MergeUtility { get; set; }
+
public List Utilities { get; set; } = new();
public List RoutingRules { get; set; } = new();
public AgentLlmConfig? LlmConfig { get; set; }
@@ -68,6 +71,7 @@ public class AgentCreationModel
IsPublic = IsPublic,
Type = Type,
Disabled = Disabled,
+ MergeUtility = MergeUtility,
Profiles = Profiles,
RoutingRules = RoutingRules?.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?.ToList() ?? new List(),
LlmConfig = LlmConfig
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs
index 08e7c85c..30308c9f 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs
@@ -31,6 +31,9 @@ public class AgentUpdateModel
///
public List? Samples { get; set; }
+ [JsonPropertyName("merge_utility")]
+ public bool MergeUtility { get; set; }
+
///
/// Utilities
///
@@ -73,6 +76,7 @@ public class AgentUpdateModel
Description = Description ?? string.Empty,
IsPublic = IsPublic,
Disabled = Disabled,
+ MergeUtility = MergeUtility,
Type = Type,
Profiles = Profiles ?? new List(),
RoutingRules = RoutingRules?.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?.ToList() ?? new List(),
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs
index 066cc030..46dea0af 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs
@@ -20,6 +20,9 @@ public class AgentViewModel
public List Functions { get; set; }
public List Responses { get; set; }
public List Samples { get; set; }
+
+ [JsonPropertyName("merge_utility")]
+ public bool MergeUtility { get; set; }
public List Utilities { get; set; }
[JsonPropertyName("is_public")]
@@ -33,8 +36,7 @@ public class AgentViewModel
[JsonPropertyName("icon_url")]
public string IconUrl { get; set; }
- public List Profiles { get; set; }
- = new List();
+ public List Profiles { get; set; } = new();
[JsonPropertyName("routing_rules")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
@@ -74,6 +76,7 @@ public class AgentViewModel
Utilities = agent.Utilities,
IsPublic= agent.IsPublic,
Disabled = agent.Disabled,
+ MergeUtility = agent.MergeUtility,
IconUrl = agent.IconUrl,
Profiles = agent.Profiles ?? new List(),
RoutingRules = agent.RoutingRules,
diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
index 82b62b62..76fee1b3 100644
--- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
+++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
@@ -8,14 +8,15 @@ public class AgentDocument : MongoBase
public string? InheritAgentId { get; set; }
public string? IconUrl { get; set; }
public string Instruction { get; set; }
+ public bool IsPublic { get; set; }
+ public bool Disabled { get; set; }
+ public bool MergeUtility { get; set; }
public List ChannelInstructions { get; set; }
public List Templates { get; set; }
public List Functions { get; set; }
public List Responses { get; set; }
public List Samples { get; set; }
public List Utilities { get; set; }
- public bool IsPublic { get; set; }
- public bool Disabled { get; set; }
public List Profiles { get; set; }
public List RoutingRules { get; set; }
public AgentLlmConfigMongoElement? LlmConfig { get; set; }
diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
index 3a88dc9c..7f216b6d 100644
--- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
+++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
@@ -2,7 +2,6 @@ using BotSharp.Abstraction.Agents.Models;
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Repositories.Filters;
using BotSharp.Abstraction.Routing.Models;
-using MongoDB.Driver;
namespace BotSharp.Plugin.MongoStorage.Repository;
@@ -57,7 +56,7 @@ public partial class MongoRepository
UpdateAgentLlmConfig(agent.Id, agent.LlmConfig);
break;
case AgentField.Utility:
- UpdateAgentUtilities(agent.Id, agent.Utilities);
+ UpdateAgentUtilities(agent.Id, agent.MergeUtility, agent.Utilities);
break;
case AgentField.All:
UpdateAgentAllFields(agent);
@@ -224,7 +223,7 @@ public partial class MongoRepository
_dc.Agents.UpdateOne(filter, update);
}
- private void UpdateAgentUtilities(string agentId, List utilities)
+ private void UpdateAgentUtilities(string agentId, bool mergeUtility, List utilities)
{
if (utilities == null) return;
@@ -232,6 +231,7 @@ public partial class MongoRepository
var filter = Builders.Filter.Eq(x => x.Id, agentId);
var update = Builders.Update
+ .Set(x => x.MergeUtility, mergeUtility)
.Set(x => x.Utilities, elements)
.Set(x => x.UpdatedTime, DateTime.UtcNow);
@@ -256,6 +256,7 @@ public partial class MongoRepository
.Set(x => x.Name, agent.Name)
.Set(x => x.Description, agent.Description)
.Set(x => x.Disabled, agent.Disabled)
+ .Set(x => x.MergeUtility, agent.MergeUtility)
.Set(x => x.Type, agent.Type)
.Set(x => x.Profiles, agent.Profiles)
.Set(x => x.RoutingRules, agent.RoutingRules.Select(r => RoutingRuleMongoElement.ToMongoElement(r)).ToList())
@@ -418,6 +419,7 @@ public partial class MongoRepository
Type = x.Type,
InheritAgentId = x.InheritAgentId,
Disabled = x.Disabled,
+ MergeUtility = x.MergeUtility,
Profiles = x.Profiles,
RoutingRules = x.RoutingRules?.Select(r => RoutingRuleMongoElement.ToMongoElement(r))?.ToList() ?? [],
LlmConfig = AgentLlmConfigMongoElement.ToMongoElement(x.LlmConfig),
@@ -507,6 +509,7 @@ public partial class MongoRepository
Utilities = agentDoc.Utilities?.Select(u => AgentUtilityMongoElement.ToDomainElement(u))?.ToList() ?? [],
IsPublic = agentDoc.IsPublic,
Disabled = agentDoc.Disabled,
+ MergeUtility = agentDoc.MergeUtility,
Type = agentDoc.Type,
InheritAgentId = agentDoc.InheritAgentId,
Profiles = agentDoc.Profiles,
diff --git a/src/Plugins/BotSharp.Plugin.Planner/data/agents/282a7128-69a1-44b0-878c-a9159b88f3b9/agent.json b/src/Plugins/BotSharp.Plugin.Planner/data/agents/282a7128-69a1-44b0-878c-a9159b88f3b9/agent.json
index c3db4f42..fff27f86 100644
--- a/src/Plugins/BotSharp.Plugin.Planner/data/agents/282a7128-69a1-44b0-878c-a9159b88f3b9/agent.json
+++ b/src/Plugins/BotSharp.Plugin.Planner/data/agents/282a7128-69a1-44b0-878c-a9159b88f3b9/agent.json
@@ -9,6 +9,7 @@
"disabled": false,
"isPublic": true,
"profiles": [ "planning" ],
+ "mergeUtility": true,
"utilities": [
{
"name": "two-stage-planner",