Conversation
Review Summary by QodoAdd template LLM configuration support with inheritance
WalkthroughsDescription• Add template LLM configuration support with response format settings • Implement agent template detail retrieval with LLM config inheritance • Use template-specific LLM config in instruct mode execution • Refactor template config loading and persistence in file repository Diagramflowchart LR
A["Agent Template"] -->|"inherits from"| B["AgentTemplateConfig"]
B -->|"contains"| C["LlmConfig"]
C -->|"extends"| D["LlmConfigBase"]
E["InstructService"] -->|"retrieves"| F["Template Detail"]
F -->|"uses LLM config"| G["Chat Completion"]
H["FileRepository"] -->|"loads/saves"| I["template_configs.json"]
I -->|"provides"| C
File Changes1. src/Infrastructure/BotSharp.Abstraction/Agents/IAgentService.cs
|
Code Review by Qodo
|
| var fileName = file.Split(Path.DirectorySeparatorChar).Last(); | ||
| var splitIdx = fileName.LastIndexOf("."); | ||
| var name = fileName.Substring(0, splitIdx); | ||
| var extension = fileName.Substring(splitIdx + 1); | ||
| if (name.IsEqualTo(templateName) && extension.IsEqualTo(_agentSettings.TemplateFormat)) |
There was a problem hiding this comment.
1. No guard for splitidx 📘 Rule violation ☼ Reliability
GetAgentTemplateDetail uses LastIndexOf(".") and then calls Substring without guarding for
-1, which can throw at the storage boundary when files don't match the expected naming format.
This violates the requirement to add explicit null/empty/invalid guards at provider boundaries and
return safe fallbacks.
Agent Prompt
## Issue description
Filename parsing assumes every file name contains a `.` and uses `Substring` with an unchecked index, which can throw and break reads at the repository boundary.
## Issue Context
This code runs against files in a directory and must tolerate unexpected/invalid file names.
## Fix Focus Areas
- src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs[746-750]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| { | ||
| var template = agent?.Templates?.FirstOrDefault(x => x.Name == options.TemplateName)?.Content ?? string.Empty; | ||
| instruction = BuildInstruction(template, options?.Data ?? []); | ||
| var template = agent?.Templates?.FirstOrDefault(x => x.Name == options.TemplateName); |
There was a problem hiding this comment.
2. Case-sensitive templatename match 📘 Rule violation ≡ Correctness
Template selection compares identifier-like names with ==, which is case-sensitive and can behave inconsistently for identifier matching. This violates the requirement to use ordinal, case-insensitive comparisons for identifiers.
Agent Prompt
## Issue description
Template lookup uses a case-sensitive equality operator for an identifier-like string (`TemplateName`), risking mismatches.
## Issue Context
Identifier comparisons must be culture-invariant and case-insensitive.
## Fix Focus Areas
- src/Infrastructure/BotSharp.Core/Instructs/Services/InstructService.Instruct.cs[69-69]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| public async Task<bool> PatchAgentTemplate(string agentId, AgentTemplate template) | ||
| { | ||
| if (string.IsNullOrEmpty(agentId) || template == null) |
There was a problem hiding this comment.
3. Mongo patch drops config 🐞 Bug ≡ Correctness
MongoRepository.PatchAgentTemplate updates only Content, so template ResponseFormat/LlmConfig
changes sent via /agent/{agentId}/templates are silently lost when Mongo storage is used.
Agent Prompt
### Issue description
MongoRepository.PatchAgentTemplate persists only `Content`, dropping new per-template fields (`ResponseFormat`, `LlmConfig`) when templates are patched.
### Issue Context
`/agent/{agentId}/templates` uses `AgentTemplate` as request payload, so clients can submit `responseFormat`/`llmConfig` but Mongo storage will ignore them.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs[574-597]
### Implementation notes
Update the found template element to include:
- `foundTemplate.ResponseFormat = template.ResponseFormat;`
- `foundTemplate.LlmConfig = AgentTemplateLlmConfigMongoModel.ToMongoModel(template.LlmConfig);`
(or replace the element in the list with `AgentTemplateMongoElement.ToMongoElement(template)`), then persist the updated templates array.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.