Uh oh!
There was an error while loading. Please reload this page.
rename to criteria config - #1397
Conversation
Uh oh!
There was an error while loading. Please reload this page.
PR Summary by QodoRename rule criteria field to criteria_config across rule pipeline
AI Description
Diagram
High-Level Assessment
Files changed (4) |
Code Review by Qodo
1. Legacy JSON criteria ignored |
| [JsonPropertyName("criteria_config")] | ||
| [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
| public RuleCriteria? Criteria { get; set; } | ||
| public RuleCriteriaConfig? CriteriaConfig { get; set; } |
There was a problem hiding this comment.
1. Legacy json criteria ignored 🐞 Bug≡ Correctness
AgentRule/Mongo rule persistence renamed the criteria field from criteria/Criteria to criteria_config/CriteriaConfig without a compatibility path, so legacy agent JSON, API payloads, and previously stored Mongo documents deserialize with CriteriaConfig == null. As a result, a rule’s saved criteria/mode can be silently dropped during domain conversion and evaluation.
Agent Prompt
## Issue description
The rule criteria field was renamed from `criteria`/`Criteria` to `criteria_config`/`CriteriaConfig` in both JSON and Mongo persistence, but deserialization currently accepts only the new name. This breaks backward compatibility for existing agent JSON in the file repository, API clients still sending `criteria`, and existing Mongo documents still storing `Criteria`, resulting in `CriteriaConfig == null` and silently dropping rule criteria/mode during domain conversion and evaluation.
## Issue Context
Agents are deserialized from JSON in the file repository (`JsonSerializer.Deserialize<Agent>`), and rules are also bound from OpenAPI request models containing `List<AgentRule>`, so legacy payloads using `criteria` will be ignored. In Mongo, `AgentDocument.Rules` stores `List<AgentRuleMongoElement>` which are transformed into domain `AgentRule` objects used by the rule engine, but the renamed property lacks BSON aliasing/migration so previously stored `Criteria` fields are ignored on read.
## Fix Focus Areas
- src/Infrastructure/BotSharp.Abstraction/Agents/Models/AgentRule.cs[3-20]
- src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.cs[298-306]
- src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/Request/AgentUpdateModel.cs[94-99]
- src/Plugins/BotSharp.Plugin.MongoStorage/Models/AgentRuleMongoElement.cs[5-33]
- src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs[24-29]
- src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs[753-781]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.