Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Infrastructure/BotSharp.Abstraction/Rules/IRuleTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ public interface IRuleTrigger
/// Explain the purpose of rule trigger (display purpose)
/// </summary>
string Statement => string.Empty;

/// <summary>
/// Optional list of agent IDs this trigger is associated with.
/// Used for display/filtering in UI only (not used in execution logic).
/// </summary>
string[]? AgentIds => null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ namespace BotSharp.OpenAPI.Controllers;

public partial class AgentController
{
[HttpGet("/rule/triggers/{agentId}")]
public IEnumerable<AgentRuleViewModel> GetRuleTriggers(string agentId)
{
var triggers = _services.GetServices<IRuleTrigger>();
triggers = triggers.Where(x => x.AgentIds == null || !x.AgentIds.Any() || x.AgentIds.Contains(agentId));
Comment on lines +11 to +12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. agentids.contains is case-sensitive 📘 Rule violation ≡ Correctness

The new filtering endpoint uses x.AgentIds.Contains(agentId) which performs a case-sensitive
identifier comparison by default. This can cause incorrect trigger matching for identifier-like
strings and violates the requirement to use ordinal, case-insensitive comparisons.
Agent Prompt
## Issue description
The new endpoint filters triggers using `x.AgentIds.Contains(agentId)` which is case-sensitive by default. Identifier-like matches must use ordinal, case-insensitive comparisons.

## Issue Context
Route parameter `agentId` is an identifier and should match regardless of casing.

## Fix Focus Areas
- src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent/AgentController.Rule.cs[11-12]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should remove || !x.AgentIds.Any()

return triggers.Select(x => new AgentRuleViewModel
{
TriggerName = x.Name,
Channel = x.Channel,
Statement = x.Statement,
OutputArgs = x.OutputArgs
}).OrderBy(x => x.TriggerName);
}

[HttpGet("/rule/triggers")]
public IEnumerable<AgentRuleViewModel> GetRuleTriggers()
{
Expand Down
Loading