feat: dual model support for cost optimization #279
+724
−164
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.
Summary
This PR implements dual model support in open, allowing users to configure separate main and lightweight models for different tasks. The lightweight model is intended for quick, low-cost operations like window title generation and status verb generation.
Key Features
lightweight_model
configuration field that accepts any provider/model combinationcost.output <= 4
as lightweight options when not explicitly configuredImplementation Details
Configuration Layer
lightweight_model
field to config schema as optional stringprovider/model
(e.g.,openai/gpt-4o-mini
)Provider Layer
getLightweightModel()
function with intelligent fallback logic:cost.output <= 4
)TUI Layer
MainProvider
/MainModel
LightProvider
/LightModel
Impact on Related PRs
This PR provides the foundation for cost-optimized model selection that will benefit:
getLightweightModel()
instead of hardcoded modelsgetLightweightModel()
instead of hardcoded modelsBoth PRs currently hardcode specific models (haiku for Anthropic, 4o-mini for OpenAI). With this change, they can dynamically use the configured lightweight model, providing better flexibility and cost optimization.
Breaking Changes
None. The feature is fully backward compatible - if no lightweight model is configured, the system continues to use the main model for all operations.
Future Enhancements
Demo
CleanShot.2025-06-21.at.15.36.20.mp4