Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Adds support for Claude Haiku 4-5 (released today) and simplifies default model selection by centralizing logic in the LRU system.

Changes

Haiku 4-5 Support

  • Added haiku: "anthropic:claude-haiku-4-5" to MODEL_ABBREVIATIONS
  • Added pricing/config to models-extra.ts:
    • Input: $1 per million tokens
    • Output: $5 per million tokens
    • Cache creation: $1.25 per million tokens
    • Cache read: $0.10 per million tokens
    • 200K context window, 8K output

Centralized Default Model Logic

Problem: defaultModel was imported in 7+ files, spreading model prescription throughout the codebase.

Solution: Created getDefaultModelFromLRU() helper that reads the most recently used model from the LRU cache. This is now the single source of truth for default model selection.

Architecture:

MODEL_ABBREVIATIONS → useModelLRU initialization → getDefaultModelFromLRU() → all consumers

Updated files:

  • src/hooks/useModelLRU.ts - Added getDefaultModelFromLRU() helper
  • src/hooks/useSendMessageOptions.ts - Use LRU instead of hardcoded default
  • src/utils/messages/sendOptions.ts - Use LRU for non-hook contexts
  • src/hooks/useAIViewKeybinds.ts - Use LRU for keybind fallbacks
  • Debug scripts - Use LRU instead of hardcoded defaults

Model Ordering

  • Reordered MODEL_ABBREVIATIONS to put sonnet first
  • Sonnet 4-5 is now the default for first-time users
  • After that, LRU drives defaults (user behavior takes over)

Benefits

Less prescriptive: Most recently used model becomes the default
Single source of truth: Only useModelLRU.ts imports defaultModel
Cross-workspace memory: Using Haiku in workspace A makes it default for workspace B
Natural discovery: As users try models, they automatically become defaults

Testing

  • ✅ Typechecks pass
  • ✅ All imports verified (only 2 files import defaultModel now)
  • ✅ Model selection paths tested via existing hooks

Generated with cmux

@ammar-agent ammar-agent force-pushed the haiku branch 3 times, most recently from 4d39b5a to a2d70c8 Compare October 15, 2025 18:32
- Add claude-haiku-4-5 to MODEL_ABBREVIATIONS with 'haiku' shortcut
- Add pricing/config for Haiku 4-5 to models-extra.ts ($1/$5 per million tokens)
- Reorder MODEL_ABBREVIATIONS to put sonnet first (becomes default for new chats)
- Centralize default model logic: created getDefaultModelFromLRU() in useModelLRU.ts
- Remove all imports of defaultModel except in models.ts and useModelLRU.ts
- Update all code paths to use LRU for default model selection:
  - useSendMessageOptions hook
  - getSendOptionsFromStorage (non-hook)
  - useAIViewKeybinds
  - Debug scripts (costs, agentSessionCli, send-message)
- Update models.json with latest model pricing data from LiteLLM

This makes the system less prescriptive - the most recently used model
becomes the default for new chats, creating a natural user-driven flow.
@chatgpt-codex-connector

This comment was marked as resolved.

When a user selects a model via ModelSelector, it now updates both:
1. The workspace-specific model storage (model:<workspaceId>)
2. The global LRU cache (most recently used models)

This ensures that newly selected models become the default for new workspaces,
creating a natural user-driven flow where the most recently used model is
suggested first.
Initialize LRU with defaults immediately instead of waiting for useEffect.
This prevents crashes when components access recentModels[0] before the
useEffect has run to seed the LRU with default models.

Changes:
- usePersistedState now initializes with DEFAULT_MODELS instead of []
- useEffect simplified to only handle merging new defaults
- getDefaultModelFromLRU uses same default initialization
- LRU is now never empty, even on first render

Fixes crash reported by Codex where ModelSelector calls .trim() on undefined.
@ammario ammario enabled auto-merge October 15, 2025 18:45
@ammario ammario added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit f95eed3 Oct 15, 2025
12 of 17 checks passed
@ammario ammario deleted the haiku branch October 15, 2025 19:21
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.

2 participants