Skip to content

feat: dual model support for cost optimization #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

aryasaatvik
Copy link
Contributor

@aryasaatvik aryasaatvik commented Jun 20, 2025

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

  • Dual Model Configuration: Added lightweight_model configuration field that accepts any provider/model combination
  • Smart Cost-Based Selection: Automatically selects models with cost.output <= 4 as lightweight options when not explicitly configured
  • Cross-Provider Support: Users can mix providers (e.g., Anthropic for main model, OpenAI for lightweight tasks)
  • Two-Pane Model Selector: Completely redesigned model selection UI with separate panes for main and lightweight models
  • Visual Indicators: Lightning emoji (⚡) marks lightweight models in the UI
  • State Persistence: Both model selections are saved and restored between sessions

Implementation Details

Configuration Layer

  • Added lightweight_model field to config schema as optional string
  • Supports format: provider/model (e.g., openai/gpt-4o-mini)

Provider Layer

  • New getLightweightModel() function with intelligent fallback logic:
    1. First checks user configuration
    2. Falls back to cheapest model meeting cost threshold (cost.output <= 4)
    3. Returns null if no suitable model found

TUI Layer

  • two pane model selection dialog:
    • Two independent panes for main and lightweight model selection
    • Tab key switches between panes
    • Arrow keys navigate within each pane
    • Separate scroll state for each pane
    • Shows provider name in header for clarity
  • updated state management to track four values:
    • MainProvider / MainModel
    • LightProvider / LightModel
  • model info display below textarea shows both models

Impact on Related PRs

This PR provides the foundation for cost-optimized model selection that will benefit:

Both 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

  • Provider-specific smart defaults (planned but not implemented)
  • Make cost threshold configurable (currently hardcoded to 4)
  • Add metrics to track lightweight vs main model usage

Demo

CleanShot.2025-06-21.at.15.36.20.mp4

@aryasaatvik aryasaatvik force-pushed the feat/lightweight-model-configuration branch from 2ca1cae to 4e500a3 Compare June 21, 2025 10:05
@aryasaatvik aryasaatvik marked this pull request as ready for review June 21, 2025 12:15
@aryasaatvik aryasaatvik changed the title feat: lightweight model configuration feat: dual model support with lightweight model configuration for cost optimization Jun 21, 2025
@aryasaatvik aryasaatvik changed the title feat: dual model support with lightweight model configuration for cost optimization feat: dual model support for cost optimization Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant