-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed as not planned
Closed as not planned
Copy link
Labels
EnhancementNew feature or requestNew feature or requestIssue - In ProgressSomeone is actively working on this. Should link to a PR soon.Someone is actively working on this. Should link to a PR soon.
Description
Summary
Refactor the Gemini and Vertex model provider handlers to be fully independent, eliminating shared logic and inheritance. This improves code maintainability, reduces coupling, and ensures each handler operates with provider-specific logic.
Problem
Currently, the VertexHandler inherits from GeminiHandler, which creates several issues:
- Mixed vertex and gemini logic in both handlers
- Vertex-specific parameters polluting the Gemini constructor
- Shared inheritance making debugging and maintenance difficult
- Model selection confusion between providers
Solution
- Complete Independence: Make VertexHandler a standalone class that doesn't inherit from GeminiHandler
- Clean Separation: Remove all vertex-related logic from GeminiHandler
- Provider-Specific Models: Ensure each handler uses only its own model set and defaults
- Enhanced Debugging: Add comprehensive debug output to trace model selection
Changes Made
GeminiHandler (src/api/providers/gemini.ts)
- Removed all vertex-related constructor parameters (
isVertex, vertex credentials) - Removed vertex-specific logic and model handling
- Now uses only
geminiApiKeyandgeminiModels - Clean, gemini-only implementation
VertexHandler (src/api/providers/vertex.ts)
- Complete standalone implementation (no inheritance)
- Uses only vertex-specific credentials and configuration
- Implements all required methods independently
- Enhanced debug output in
getModel()method for troubleshooting - Uses
vertexModelsandvertexDefaultModelIdexclusively
Tests Updated
- Updated vertex test expectations to use correct default model (
claude-sonnet-4@20250514) - Fixed error message expectations after refactoring
- All tests passing (11 vertex tests, 15 gemini tests)
Benefits
- Cleaner Architecture: Each handler is responsible only for its provider
- Easier Debugging: Clear separation makes issues easier to trace
- Better Maintainability: Changes to one provider don't affect the other
- Reduced Coupling: No shared state or inheritance dependencies
- Provider-Specific Optimization: Each handler can be optimized for its specific use case
Testing
- ✅ All existing gemini tests pass (15/15)
- ✅ All vertex tests updated and passing (11/11)
- ✅ No breaking changes to public API
- ✅ Model selection and fallback logic verified
- ✅ Debug output added for troubleshooting apiModelId flow
Files Changed
src/api/providers/gemini.ts- Refactored to pure Gemini implementationsrc/api/providers/vertex.ts- Standalone Vertex implementation with enhanced debuggingsrc/api/providers/__tests__/vertex.test.ts- Updated test expectations
Type of Change
- Refactor (code change that improves structure without changing functionality)
- Enhancement (improvement to existing feature)
- Test updates (updating existing tests)
This refactoring improves code quality while maintaining full backward compatibility and makes future maintenance much easier.
dosubot
Metadata
Metadata
Assignees
Labels
EnhancementNew feature or requestNew feature or requestIssue - In ProgressSomeone is actively working on this. Should link to a PR soon.Someone is actively working on this. Should link to a PR soon.
Type
Projects
Status
Done