Skip to content

Conversation

iceljc
Copy link
Collaborator

@iceljc iceljc commented Oct 9, 2025

PR Type

Enhancement


Description

  • Extract image handling functionality into dedicated plugin

  • Migrate image-related settings and configurations

  • Update agent references from UtilityAssistant to FileAssistant

  • Remove image dependencies from FileHandler plugin


Diagram Walkthrough

flowchart LR
  FileHandler["FileHandler Plugin"] -- "extract" --> ImageHandler["ImageHandler Plugin"]
  ImageHandler -- "contains" --> ImageFunctions["Image Functions"]
  ImageHandler -- "contains" --> ImageSettings["Image Settings"]
  ImageFunctions --> ReadImage["Read Image"]
  ImageFunctions --> GenerateImage["Generate Image"]
  ImageFunctions --> EditImage["Edit Image"]
Loading

File Walkthrough

Relevant files
Enhancement
17 files
FileInstructService.SelectFile.cs
Update agent reference to FileAssistant                                   
+2/-2     
UtilityName.cs
Remove image-related utility constants                                     
+0/-3     
FileHandlerPlugin.cs
Remove image converter and update description                       
+2/-5     
FileHandlerUtilityHook.cs
Remove image utility registrations                                             
+0/-39   
FileHandlerSettings.cs
Remove image settings configuration                                           
+0/-25   
ImageHandlerImageConverter.cs
Migrate image converter to ImageHandler                                   
+6/-6     
UtilityName.cs
Add image utility constants                                                           
+8/-0     
EditImageFn.cs
Migrate image editing function                                                     
+10/-10 
GenerateImageFn.cs
Migrate image generation function                                               
+9/-9     
ReadImageFn.cs
Migrate image reading function                                                     
+10/-11 
AiResponseHelper.cs
Add image response helper utilities                                           
+31/-0   
ImageHandlerUtilityHook.cs
Add image utility hook registration                                           
+53/-0   
ImageHandlerPlugin.cs
Create new ImageHandler plugin                                                     
+26/-0   
LlmContextIn.cs
Add LLM input context model                                                           
+18/-0   
LlmContextOut.cs
Add LLM output context model                                                         
+10/-0   
ImageHandlerSettings.cs
Migrate image settings configuration                                         
+25/-0   
Using.cs
Add global using statements                                                           
+34/-0   
Configuration changes
5 files
BotSharp.sln
Add ImageHandler project to solution                                         
+11/-0   
BotSharp.Plugin.FileHandler.csproj
Remove image-related content and dependencies                       
+0/-28   
BotSharp.Plugin.ImageHandler.csproj
Create ImageHandler project file                                                 
+42/-0   
WebStarter.csproj
Add ImageHandler project reference                                             
+1/-0     
appsettings.json
Migrate image settings to ImageHandler                                     
+20/-18 
Additional files
6 files
util-file-edit_image.json [link]   
util-file-generate_image.json [link]   
util-file-read_image.json [link]   
util-file-edit_image.fn.liquid [link]   
util-file-generate_image.fn.liquid [link]   
util-file-read_image.fn.liquid [link]   

@iceljc iceljc marked this pull request as draft October 9, 2025 22:44
Copy link

qodo-merge-pro bot commented Oct 9, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link

qodo-merge-pro bot commented Oct 9, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect state key for model

In EditImageFn.cs, correct the state key used for retrieving the LLM model from
"image_edit_llm_provider" to "image_edit_llm_model" to fix a bug.

src/Plugins/BotSharp.Plugin.ImageHandler/Functions/EditImageFn.cs [155]

-var model = state.GetState("image_edit_llm_provider");
+var model = state.GetState("image_edit_llm_model");

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a copy-paste bug where the wrong state key is used to retrieve the model name, which would cause runtime failures.

High
Prevent potential null reference exception

In ReadImageFn.cs, add a null-conditional operator (?.) when accessing
_settings.Reading.ImageDetailLevel inside the if block to prevent a potential
NullReferenceException.

src/Plugins/BotSharp.Plugin.ImageHandler/Functions/ReadImageFn.cs [168-171]

 if (string.IsNullOrWhiteSpace(level) && !string.IsNullOrWhiteSpace(_settings.Reading?.ImageDetailLevel))
 {
-    state.SetState(key, _settings.Reading.ImageDetailLevel);
+    state.SetState(key, _settings.Reading?.ImageDetailLevel);
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential NullReferenceException due to accessing _settings.Reading without a null check, even though the condition implies it could be null.

Medium
Learned
best practice
Initialize safe LLM defaults

Provide a non-null default for LLM provider and model when fromAgent?.LlmConfig
is null to avoid downstream null access. Initialize LlmConfig with safe
defaults.

src/Plugins/BotSharp.Plugin.ImageHandler/Functions/ReadImageFn.cs [43-49]

 var agent = new Agent
 {
     Id = fromAgent?.Id ?? BuiltInAgentId.FileAssistant,
     Name = fromAgent?.Name ?? "File Assistant",
     Instruction = fromAgent?.Instruction ?? args?.UserRequest ?? "Please describe the image(s).",
-    LlmConfig = fromAgent?.LlmConfig ?? new()
+    LlmConfig = fromAgent?.LlmConfig ?? new AgentLlmConfig
+    {
+        Provider = "openai",
+        Model = "gpt-4o-mini"
+    }
 };
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Ensure null-safety on optional inputs and object properties, returning safe defaults to avoid NullReferenceExceptions.

Low
  • More

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant