Clean up prompt optimization flow: remove double init, fix DI, deduplicate DTO#489
Draft
Copilot wants to merge 2 commits intoDeveloper-KnowledgeBasefrom
Draft
Clean up prompt optimization flow: remove double init, fix DI, deduplicate DTO#489Copilot wants to merge 2 commits intoDeveloper-KnowledgeBasefrom
Copilot wants to merge 2 commits intoDeveloper-KnowledgeBasefrom
Conversation
- Remove redundant EnsureInitializedAsync() call in PromptOptimizationController (OptimizePromptAsync already calls it internally) - Refactor PromptOptimizationPlugin to use constructor DI injection instead of Service Locator anti-pattern for PromptItemService, PromptRangeService, PromptResultService - Refactor PromptCatalyzerPlugin to use constructor DI injection instead of Service Locator for PromptOptimizationService - Remove duplicate PromptOptimizationRequestDto from controller; use shared definition from OHS.Local.AppService namespace Co-authored-by: JeffreySu <2281927+JeffreySu@users.noreply.github.com> Agent-Logs-Url: https://github.com/NeuCharFramework/NcfPackageSources/sessions/753ef2d6-0af5-40fb-82e6-98bf4896bf73
Copilot
AI
changed the title
[WIP] Review and organize the current optimization workflow
Clean up prompt optimization flow: remove double init, fix DI, deduplicate DTO
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The prompt optimization flow had three structural issues: redundant initialization on every request, Service Locator anti-pattern in plugins, and a duplicated DTO class across two files.
Changes
Double
EnsureInitializedAsync()removed fromPromptOptimizationControllerOptimizePromptAsync()already calls it internally — the controller was triggering it twice per request.PromptOptimizationPluginconstructor injectionPromptItemService,PromptRangeService,PromptResultServicewere resolved viaSenparcDI.GetServiceProvider().GetRequiredService<T>(). Now injected through constructor parameters.PromptCatalyzerPluginconstructor injectionSame fix —
PromptOptimizationServicenow injected instead of resolved via Service Locator.Duplicate
PromptOptimizationRequestDtoremoved from controllerIdentical class was defined in both
PromptOptimizationController.csandPromptOptimizationAppService.cs. Controller now imports the shared definition fromOHS.Local.AppService.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.