Extract duplicate custom engine step handling into shared helper functions#1804
Merged
Extract duplicate custom engine step handling into shared helper functions#1804
Conversation
- Created pkg/workflow/engine_shared_helpers.go with two shared functions: - InjectCustomEngineSteps() for custom step injection (Pattern 1) - HandleCustomMCPToolInSwitch() for custom MCP tool handling (Pattern 2) - Updated copilot_engine.go, codex_engine.go, claude_engine.go to use shared functions - Updated custom_engine.go to use HandleCustomMCPToolInSwitch() - Added comprehensive unit tests in engine_shared_helpers_test.go - All existing tests pass without modification Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor custom engine step handling to eliminate duplication
Extract duplicate custom engine step handling into shared helper functions
Oct 16, 2025
pelikhan
approved these changes
Oct 16, 2025
Contributor
|
Agentic Changeset Generator triggered by this pull request |
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.
Problem
Multiple workflow engine implementations contained duplicate code for handling custom steps and custom MCP tool configurations. The duplication existed across 4 engine files (
copilot_engine.go,codex_engine.go,claude_engine.go,custom_engine.go) and created maintenance overhead:These duplicate blocks had to be kept in sync manually, increasing the risk of inconsistent fixes and making future changes more error-prone.
Solution
Created two shared helper functions in
pkg/workflow/engine_shared_helpers.go:1.
InjectCustomEngineSteps()Extracts the common pattern for processing custom steps from engine configuration:
2.
HandleCustomMCPToolInSwitch()Extracts the common pattern for handling custom MCP tools in switch statement default cases:
Impact
Testing
make agent-finish- all 64 workflows compile correctlyFixes #123
Original prompt
Fixes #1800
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.