Refactor CodingAgentEngine using Interface Segregation Principle#11607
Merged
Refactor CodingAgentEngine using Interface Segregation Principle#11607
Conversation
…ciple - Define 6 focused interfaces: Engine, CapabilityProvider, WorkflowExecutor, MCPConfigProvider, LogParser, SecurityProvider - CodingAgentEngine remains as composite interface for backward compatibility - BaseEngine provides default implementations for all methods - All existing engines (Copilot, Claude, Codex, Custom) work without changes - Add comprehensive tests validating interface segregation - Fix custom engine to return empty slice instead of nil for secrets - Add detailed architecture documentation with usage patterns Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Remove redundant type assertions - Use require.NoError for critical error checks - All interface segregation tests pass Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor CodingAgentEngine interface for better modularity
Refactor CodingAgentEngine using Interface Segregation Principle
Jan 24, 2026
This was referenced Jan 24, 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
CodingAgentEngineinterface contained 18 methods mixing unrelated concerns (identity, capabilities, workflow execution, MCP configuration, logging, security), forcing all implementations to inherit the entire surface area.Changes
Interface Segregation
Engine: Core identity (4 methods)CapabilityProvider: Feature detection (6 methods)WorkflowExecutor: Workflow compilation (3 methods)MCPConfigProvider: MCP configuration (1 method)LogParser: Log analysis (3 methods)SecurityProvider: Security features (2 methods)CodingAgentEngineremains as composite interface (backward compatible)Usage Pattern
Implementation
BaseEnginewhich provides default implementationsBug Fix
CustomEngine.GetRequiredSecretNames()now returns empty slice instead of nilTesting
Original prompt
This section details on the original issue you should resolve
<issue_title>[Code Quality] Refactor CodingAgentEngine interface using Interface Segregation Principle</issue_title>
<issue_description>## Description
The
CodingAgentEngineinterface contains 18 methods that mix multiple unrelated concerns (metadata, capabilities, workflow, rendering, parsing, security), violating the Interface Segregation Principle and Single Responsibility Principle. This forces all implementations to implement or inherit all methods, making testing difficult and adding new engine types harder.Background
Identified during Sergo analysis on 2026-01-23 (discussion #11477). The interface has grown from 16 methods to 18 methods (+12.5%) in just 5 days, indicating continued bloat.
Current state: Single monolithic interface with 18 methods
Trend: Growing worse (16 methods on 2026-01-18 → 18 methods on 2026-01-23)
Impact: Tight coupling, difficult testing, hard to add new engines
Files Affected
pkg/workflow/agentic_engine.go:19-81- Interface definitionpkg/workflow/claude_engine.go:14-16- ClaudeEngine implementationpkg/workflow/copilot_engine.go:25-27- CopilotEngine implementationpkg/workflow/custom_engine.go- CustomEngine implementationpkg/workflow/codex_engine.go- CodexEngine implementationSuggested Changes
Split into focused interfaces using composition:
Implementation Steps
Success Criteria
make agent-finishpassesPriority
High - Architectural improvement that prevents further bloat
Estimated effort: Large (4-6 hours, affects 90+ files)
Source
Extracted from Sergo Interface Segregation analysis discussion githubnext/gh-aw#11477
Analysis quote:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.