Skip to content

feat: runtime model switching via /model command#160

Open
Talla wants to merge 2 commits intoRichardAtCT:mainfrom
Talla:feat/model-command
Open

feat: runtime model switching via /model command#160
Talla wants to merge 2 commits intoRichardAtCT:mainfrom
Talla:feat/model-command

Conversation

@Talla
Copy link

@Talla Talla commented Mar 20, 2026

Summary

Adds a /model command that lets users switch between Claude models (Opus, Sonnet, Haiku) and set effort levels at runtime via an inline keyboard UI — no bot restart or config changes needed.

  • Inline keyboard flow: /model → pick model → pick effort level (if supported) → done
  • Model-aware effort levels: Haiku has no effort support, Sonnet supports low/medium/high, Opus adds "max"
  • Session handling: Switching models forces a new session (CLI doesn't support model changes on resumed sessions). Users are warned upfront before selecting.
  • Per-user override: Stored in context.user_data (in-memory). Resets on bot restart — server default (CLAUDE_MODEL env var) is used until the user overrides.

Implements the feature requested in #138.

Changes

File What
command.py /model command, model_callback, _handle_model_selection shared logic, model/effort constants
callback.py Route model: and effort: callbacks in classic mode
orchestrator.py Register command + callback in both modes, add to bot menu, thread overrides to run_command
message.py Thread model_override + effort_override through all 4 classic run_command call sites
facade.py Accept and forward model_override + effort_override params
sdk_integration.py Apply model_override and effort to ClaudeAgentOptions
test_model_command.py 17 new tests (keyboard, selection, labels, effort config)
test_orchestrator.py Updated handler count assertions

Test plan

  • All 529 tests pass (512 existing + 17 new)
  • Manual: /model shows keyboard with Opus/Sonnet/Haiku + Reset
  • Manual: Selecting Haiku skips effort selection
  • Manual: Selecting Sonnet shows Low/Medium/High (no Max)
  • Manual: Selecting Opus shows Low/Medium/High/Max
  • Manual: After switching, next message uses the new model
  • Manual: "Reset to default" clears override

Closes #138

🤖 Generated with Claude Code

Talla added 2 commits March 20, 2026 18:25
Add /model command with inline keyboard UI for switching between
Opus/Sonnet/Haiku models and effort levels (low/medium/high/max)
at runtime. Model changes force a new session since the CLI doesn't
support model switching on resumed sessions.

- Effort levels are model-aware: Haiku has none, Sonnet excludes
  "max", Opus supports all including "max"
- Override is per-user via context.user_data (in-memory, resets on
  bot restart)
- Threaded through all run_command call sites (orchestrator, classic
  message handler) into the SDK layer
- Registered in both agentic and classic handler modes
- Added to bot command menu and /help text
- 17 new tests covering keyboard display, model/effort selection,
  label formatting, and effort-per-model configuration

Closes RichardAtCT#138
Instead of just "Default", show "Default (claude-sonnet-4-6)" or
"Default (CLI default)" so users can verify what model is active
after resetting.
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.

feat: runtime model switching via /model command

1 participant