diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentMode.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentMode.cs
new file mode 100644
index 00000000..4e2cd60c
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentMode.cs
@@ -0,0 +1,7 @@
+namespace BotSharp.Abstraction.Agents.Enums;
+
+public class AgentMode
+{
+ public const string Eager = "eager";
+ public const string Lazy = "lazy";
+}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
index 1ba644e8..4562f16a 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
@@ -17,7 +17,7 @@ public class Agent
///
/// Routing Mode: lazy or eager
///
- public string Mode { get; set; } = "eager";
+ public string Mode { get; set; } = AgentMode.Eager;
public DateTime CreatedDateTime { get; set; }
public DateTime UpdatedDateTime { get; set; }
@@ -277,7 +277,7 @@ public class Agent
return this;
}
- public Agent SetAgentType(string type)
+ public Agent SetType(string type)
{
Type = type;
return this;
@@ -288,7 +288,7 @@ public class Agent
///
///
///
- public Agent SetAgentMode(string mode)
+ public Agent SetMode(string mode)
{
Mode = mode;
return this;
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs
index 25f7d2d5..9603d1e5 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.RefreshAgents.cs
@@ -67,7 +67,7 @@ public partial class AgentService
}
catch (Exception ex)
{
- _logger.LogError($"Failed to migrate agent in file directory: {dir}\r\nError: {ex.Message}");
+ _logger.LogError(ex, $"Failed to migrate agent in file directory: {dir}\r\nError: {ex.Message}");
}
}
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
index f2fb4ff7..50dbcad4 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
@@ -94,12 +94,12 @@ public partial class AgentService
{
clonedAgent.SetId(foundAgent.Id)
.SetName(foundAgent.Name)
- .SetDescription(foundAgent.Description)
+ .SetType(foundAgent.Type)
+ .SetMode(foundAgent.Mode)
.SetIsPublic(foundAgent.IsPublic)
.SetDisabled(foundAgent.Disabled)
+ .SetDescription(foundAgent.Description)
.SetMergeUtility(foundAgent.MergeUtility)
- .SetAgentType(foundAgent.Type)
- .SetAgentMode(foundAgent.Mode)
.SetProfiles(foundAgent.Profiles)
.SetLabels(foundAgent.Labels)
.SetRoutingRules(foundAgent.RoutingRules)
diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
index 1227d3dc..42e0de2c 100644
--- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
+++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
@@ -83,10 +83,10 @@ public partial class ConversationService
{
// Check the routing mode
var states = _services.GetRequiredService();
- var routingMode = states.GetState(StateConst.ROUTING_MODE, "eager");
+ var routingMode = states.GetState(StateConst.ROUTING_MODE, AgentMode.Eager);
routing.Context.Push(agent.Id, reason: "request started", updateLazyRouting: false);
- if (routingMode == "lazy")
+ if (routingMode == AgentMode.Lazy)
{
message.CurrentAgentId = states.GetState(StateConst.LAZY_ROUTING_AGENT_ID, message.CurrentAgentId);
routing.Context.Push(message.CurrentAgentId, reason: "lazy routing", updateLazyRouting: false);
diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
index 930eb13d..5494f972 100644
--- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
+++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
@@ -383,11 +383,12 @@ namespace BotSharp.Core.Repository
if (agent == null) return;
agent.Name = inputAgent.Name;
- agent.Description = inputAgent.Description;
+ agent.Type = inputAgent.Type;
+ agent.Mode = inputAgent.Mode;
agent.IsPublic = inputAgent.IsPublic;
agent.Disabled = inputAgent.Disabled;
+ agent.Description = inputAgent.Description;
agent.MergeUtility = inputAgent.MergeUtility;
- agent.Type = inputAgent.Type;
agent.Profiles = inputAgent.Profiles;
agent.Labels = inputAgent.Labels;
agent.Utilities = inputAgent.Utilities;
diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs
index b422a423..5a5a02da 100644
--- a/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs
+++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingContext.cs
@@ -290,8 +290,8 @@ public class RoutingContext : IRoutingContext
// Set next handling agent for lazy routing mode
var states = _services.GetRequiredService();
- var routingMode = states.GetState(StateConst.ROUTING_MODE, "eager");
- if (routingMode == "lazy")
+ var routingMode = states.GetState(StateConst.ROUTING_MODE, AgentMode.Eager);
+ if (routingMode == AgentMode.Lazy)
{
var agentId = GetCurrentAgentId();
if (agentId != BuiltInAgentId.Fallback)
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs
index 8265ebe4..2fd2c429 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentCreationModel.cs
@@ -8,6 +8,7 @@ public class AgentCreationModel
public string Name { get; set; }
public string Description { get; set; }
public string Type { get; set; } = AgentType.Task;
+ public string Mode { get; set; } = AgentMode.Eager;
///
/// LLM default system instructions
@@ -66,6 +67,10 @@ public class AgentCreationModel
return new Agent
{
Name = Name,
+ Type = Type,
+ Mode = Mode,
+ Disabled = Disabled,
+ IsPublic = IsPublic,
Description = Description,
Instruction = Instruction,
ChannelInstructions = ChannelInstructions,
@@ -75,9 +80,6 @@ public class AgentCreationModel
Samples = Samples,
Utilities = Utilities,
McpTools = McpTools,
- IsPublic = IsPublic,
- Type = Type,
- Disabled = Disabled,
MergeUtility = MergeUtility,
MaxMessageCount = MaxMessageCount,
Profiles = Profiles,
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs
index b11a9db0..da0c8b3a 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs
@@ -9,6 +9,8 @@ public class AgentUpdateModel
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string Type { get; set; } = AgentType.Task;
+ public string Mode { get; set; } = AgentMode.Eager;
+
///
/// Instruction
///
@@ -93,12 +95,13 @@ public class AgentUpdateModel
var agent = new Agent()
{
Name = Name ?? string.Empty,
- Description = Description ?? string.Empty,
+ Type = Type,
+ Mode = Mode,
IsPublic = IsPublic,
Disabled = Disabled,
+ Description = Description ?? string.Empty,
MergeUtility = MergeUtility,
MaxMessageCount = MaxMessageCount,
- Type = Type,
Profiles = Profiles ?? [],
Labels = Labels ?? [],
RoutingRules = RoutingRules?.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?.ToList() ?? [],