Skip to content

feat(cli): add /fast to toggle between main and cheap model#200

Merged
emal-avala merged 1 commit intomainfrom
feat/fast-toggle
Apr 23, 2026
Merged

feat(cli): add /fast to toggle between main and cheap model#200
emal-avala merged 1 commit intomainfrom
feat/fast-toggle

Conversation

@emal-avala
Copy link
Copy Markdown
Member

@emal-avala emal-avala commented Apr 23, 2026

Summary

Cost control without leaving the REPL. /fast swaps api.model with a configured api.fast_model (or a provider-aware default) for the rest of the session; /fast again reverts.

> /fast
Fast mode enabled. Model: 'your-preferred-model' → 'your-fast-model'.
Run /fast again to revert.

> /fast
Fast mode disabled. Model restored to 'your-preferred-model'.

New config field

[api]
model      = "your-preferred-model"
fast_model = "your-fast-model"      # optional — overrides default

When fast_model is not configured, default_fast_model() picks a provider-aware fallback:

Main model contains Fallback fast model
opus, sonnet your-fast-model
gpt-5 gpt-5-mini
gpt-4 gpt-4-mini
gemini gemini-flash
grok grok-mini
(other) haiku (prompts user to configure explicitly)

Implementation

  • ApiConfig gains fast_model: Option<String>, default None
  • AppState gains pre_fast_model: Option<String> — session-local, Some ⇔ currently in fast mode
  • /fast swap logic: save current, replace with fast_model; on second toggle, restore from pre_fast_model
  • No-op guard when fast_model == current_model (prevents silent loss of the restore target)
  • Noted in help panel's "Current session" block via the existing model field (no additional plumbing needed; users see the swapped model there)

Test plan

  • cargo fmt --all — clean
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test -p agent-code --bin agent default_fast_model — 5/5 pass (provider fallbacks, case insensitivity, unknown provider)
  • cargo test -p agent-code-lib --lib state — 10/10 pass (new pre_fast_model: None default assertion)

Cost control without leaving the REPL. `/fast` swaps `api.model` with
a configured `api.fast_model` (or a provider-aware default) for the
rest of the session; `/fast` again reverts.

  > /fast
  Fast mode enabled. Model: 'claude-opus-4-7' → 'claude-haiku-4-5'.
  Run /fast again to revert.

  > /fast
  Fast mode disabled. Model restored to 'claude-opus-4-7'.

New config field:

  [api]
  model      = "claude-opus-4-7"
  fast_model = "claude-haiku-4-5"      # explicit — overrides default

When `fast_model` is not configured, `default_fast_model()` picks a
provider-aware fallback:

  opus / sonnet → claude-haiku-4-5
  gpt-5         → gpt-5-mini
  gpt-4         → gpt-4-mini
  gemini        → gemini-flash
  grok          → grok-mini
  (other)       → "haiku" (forces user to configure explicitly)

Implementation: AppState gains `pre_fast_model: Option<String>`
(session-local, not persisted). `Some` ⇔ currently in fast mode;
the pre-swap model is restored on the next toggle. No-op guard when
the fast model equals the current model (prevents silent loss of
the restore target).

Tests: 5 unit tests covering provider fallbacks and case insensitivity
in `default_fast_model`, plus `test_new_state` verifies the new
`pre_fast_model: None` default.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit 8768cce into main Apr 23, 2026
14 checks passed
@emal-avala emal-avala deleted the feat/fast-toggle branch April 23, 2026 06:16
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