diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs
index 0617a9de..914f08c3 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs
@@ -9,6 +9,7 @@ public enum AgentField
Disabled,
Type,
RoutingMode,
+ FuncVisMode,
InheritAgentId,
Profile,
Label,
diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentFuncVisMode.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentFuncVisMode.cs
new file mode 100644
index 00000000..21224815
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentFuncVisMode.cs
@@ -0,0 +1,7 @@
+namespace BotSharp.Abstraction.Agents.Enums;
+
+public class AgentFuncVisMode
+{
+ public const string Manual = "manual";
+ public const string Auto = "auto";
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
index 431a78c5..adf4d334 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
@@ -21,6 +21,13 @@ public class Agent
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Mode { get; set; }
+ ///
+ /// Function Visibility Mode: Manual or Auto
+ ///
+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
+ [JsonPropertyName("functionVisibilityMode")]
+ public string? FuncVisMode { get; set; }
+
public DateTime CreatedDateTime { get; set; }
public DateTime UpdatedDateTime { get; set; }
@@ -296,6 +303,12 @@ public class Agent
return this;
}
+ public Agent SetFuncVisMode(string? visMode)
+ {
+ FuncVisMode = visMode;
+ return this;
+ }
+
public Agent SetProfiles(List profiles)
{
Profiles = profiles ?? [];
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
index 41174886..d99b39d9 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
@@ -32,6 +32,7 @@ public partial class AgentService
record.MaxMessageCount = agent.MaxMessageCount;
record.Type = agent.Type;
record.Mode = agent.Mode;
+ record.FuncVisMode = agent.FuncVisMode;
record.Profiles = agent.Profiles ?? [];
record.Labels = agent.Labels ?? [];
record.RoutingRules = agent.RoutingRules ?? [];
@@ -96,6 +97,7 @@ public partial class AgentService
.SetName(foundAgent.Name)
.SetType(foundAgent.Type)
.SetRoutingMode(foundAgent.Mode)
+ .SetFuncVisMode(foundAgent.FuncVisMode)
.SetIsPublic(foundAgent.IsPublic)
.SetDisabled(foundAgent.Disabled)
.SetDescription(foundAgent.Description)
diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
index c5947708..35351311 100644
--- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
+++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
@@ -30,6 +30,9 @@ namespace BotSharp.Core.Repository
case AgentField.RoutingMode:
UpdateAgentRoutingMode(agent.Id, agent.Mode);
break;
+ case AgentField.FuncVisMode:
+ UpdateAgentFuncVisMode(agent.Id, agent.FuncVisMode);
+ break;
case AgentField.InheritAgentId:
UpdateAgentInheritAgentId(agent.Id, agent.InheritAgentId);
break;
@@ -156,6 +159,17 @@ namespace BotSharp.Core.Repository
File.WriteAllText(agentFile, json);
}
+ private void UpdateAgentFuncVisMode(string agentId, string? visMode)
+ {
+ var (agent, agentFile) = GetAgentFromFile(agentId);
+ if (agent == null) return;
+
+ agent.FuncVisMode = visMode;
+ agent.UpdatedDateTime = DateTime.UtcNow;
+ var json = JsonSerializer.Serialize(agent, _options);
+ File.WriteAllText(agentFile, json);
+ }
+
private void UpdateAgentInheritAgentId(string agentId, string? inheritAgentId)
{
var (agent, agentFile) = GetAgentFromFile(agentId);
@@ -385,6 +399,7 @@ namespace BotSharp.Core.Repository
agent.Name = inputAgent.Name;
agent.Type = inputAgent.Type;
agent.Mode = inputAgent.Mode;
+ agent.FuncVisMode = inputAgent.FuncVisMode;
agent.IsPublic = inputAgent.IsPublic;
agent.Disabled = inputAgent.Disabled;
agent.Description = inputAgent.Description;
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs
index 33553e48..f940a945 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs
@@ -1,6 +1,6 @@
using BotSharp.Abstraction.Agents.Models;
using BotSharp.Abstraction.Functions.Models;
-using BotSharp.Abstraction.Routing.Enums;
+using System.Text.Json.Serialization;
namespace BotSharp.OpenAPI.ViewModels.Agents;
@@ -15,6 +15,12 @@ public class AgentCreationModel
///
public string? Mode { get; set; }
+ ///
+ /// Agent function visibility mode
+ ///
+ [JsonPropertyName("function_visibility_mode")]
+ public string? FuncVisMode { get; set; }
+
///
/// LLM default system instructions
///
@@ -74,6 +80,7 @@ public class AgentCreationModel
Name = Name,
Type = Type,
Mode = Mode,
+ FuncVisMode = FuncVisMode,
Disabled = Disabled,
IsPublic = IsPublic,
Description = Description,
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs
index 3b69055f..b13c334f 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs
@@ -15,6 +15,12 @@ public class AgentUpdateModel
///
public string? Mode { get; set; }
+ ///
+ /// Agent function visibility mode
+ ///
+ [JsonPropertyName("function_visibility_mode")]
+ public string? FuncVisMode { get; set; }
+
///
/// Instruction
///
@@ -101,6 +107,7 @@ public class AgentUpdateModel
Name = Name ?? string.Empty,
Type = Type,
Mode = Mode,
+ FuncVisMode = FuncVisMode,
IsPublic = IsPublic,
Disabled = Disabled,
Description = Description ?? string.Empty,
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/View/AgentViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/View/AgentViewModel.cs
index 728a73e6..41657200 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/View/AgentViewModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/View/AgentViewModel.cs
@@ -15,6 +15,11 @@ public class AgentViewModel
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Mode { get; set; }
+
+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
+ [JsonPropertyName("function_visibility_mode")]
+ public string? FuncVisMode { get; set; }
+
public string Instruction { get; set; }
[JsonPropertyName("channel_instructions")]
@@ -86,6 +91,7 @@ public class AgentViewModel
Description = agent.Description,
Type = agent.Type,
Mode = agent.Mode,
+ FuncVisMode = agent.FuncVisMode,
Instruction = agent.Instruction,
ChannelInstructions = agent.ChannelInstructions ?? [],
Templates = agent.Templates ?? [],
diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
index 767a054a..16184265 100644
--- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
+++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
@@ -6,6 +6,7 @@ public class AgentDocument : MongoBase
public string Description { get; set; } = default!;
public string Type { get; set; } = default!;
public string? Mode { get; set; }
+ public string? FunctionVisibilityMode { get; set; }
public string? InheritAgentId { get; set; }
public string? IconUrl { get; set; }
public string Instruction { get; set; } = default!;
diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
index 5e0e741a..40558e13 100644
--- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
+++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
@@ -31,6 +31,9 @@ public partial class MongoRepository
case AgentField.RoutingMode:
UpdateAgentRoutingMode(agent.Id, agent.Mode);
break;
+ case AgentField.FuncVisMode:
+ UpdateAgentFuncVisMode(agent.Id, agent.FuncVisMode);
+ break;
case AgentField.InheritAgentId:
UpdateAgentInheritAgentId(agent.Id, agent.InheritAgentId);
break;
@@ -149,6 +152,16 @@ public partial class MongoRepository
_dc.Agents.UpdateOne(filter, update);
}
+ private void UpdateAgentFuncVisMode(string agentId, string? visMode)
+ {
+ var filter = Builders.Filter.Eq(x => x.Id, agentId);
+ var update = Builders.Update
+ .Set(x => x.FunctionVisibilityMode, visMode)
+ .Set(x => x.UpdatedTime, DateTime.UtcNow);
+
+ _dc.Agents.UpdateOne(filter, update);
+ }
+
private void UpdateAgentInheritAgentId(string agentId, string? inheritAgentId)
{
var filter = Builders.Filter.Eq(x => x.Id, agentId);
@@ -349,6 +362,7 @@ public partial class MongoRepository
.Set(x => x.MergeUtility, agent.MergeUtility)
.Set(x => x.Type, agent.Type)
.Set(x => x.Mode, agent.Mode)
+ .Set(x => x.FunctionVisibilityMode, agent.FuncVisMode)
.Set(x => x.MaxMessageCount, agent.MaxMessageCount)
.Set(x => x.Profiles, agent.Profiles)
.Set(x => x.Labels, agent.Labels)
@@ -529,6 +543,7 @@ public partial class MongoRepository
IsPublic = x.IsPublic,
Type = x.Type,
Mode = x.Mode,
+ FunctionVisibilityMode = x.FuncVisMode,
InheritAgentId = x.InheritAgentId,
Disabled = x.Disabled,
MergeUtility = x.MergeUtility,
@@ -627,6 +642,7 @@ public partial class MongoRepository
MergeUtility = agentDoc.MergeUtility,
Type = agentDoc.Type,
Mode = agentDoc.Mode,
+ FuncVisMode = agentDoc.FunctionVisibilityMode,
InheritAgentId = agentDoc.InheritAgentId,
Profiles = agentDoc.Profiles ?? [],
Labels = agentDoc.Labels ?? [],