Skip to content

fix(cli): restore /model command handler#3548

Closed
v1-100-lab wants to merge 1 commit into
NousResearch:mainfrom
v1-100-lab:fix/model-command-handler
Closed

fix(cli): restore /model command handler#3548
v1-100-lab wants to merge 1 commit into
NousResearch:mainfrom
v1-100-lab:fix/model-command-handler

Conversation

@v1-100-lab

Copy link
Copy Markdown

What does this PR do?

Restores the missing /model command handler in the interactive CLI. The /model command appeared in autocomplete and /help (via COMMAND_REGISTRY) but failed with "Unknown command" because the dispatch handler in process_command() was not restored when PR #3372 re-added the registry entry.

The /model slash command was completely removed in commit 9783c9d (#3080). While the infrastructure (hermes_cli/model_switch.py) remained for ACP and other integrations, the interactive CLI handler was never put back. This PR adds that missing handler, restoring full /model functionality for interactive use.

Related Issue

Fixes the broken /model command introduced by incomplete restoration in #3372

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • hermes_cli/commands.py: /model entry added to COMMAND_REGISTRY (+2 lines) — already present from fix(commands): add missing /model command to COMMAND_REGISTRY #3372, included here for completeness
  • cli.py: Added elif canonical == "model": handler in process_command() (+85 lines) to dispatch to model_switch.switch_model() and switch_to_custom_provider()

How to Test

  1. Run Hermes CLI: hermes
  2. Type /model openai:gpt-4o (or any valid model)
  3. Verify the model switches successfully with proper confirmation message
  4. Test /model custom (auto-detect from endpoint) and /model custom:litellm:moonshotai/kimi-k2-instruct
  5. Run /model without arguments to see the model/providers display
  6. Restart Hermes and verify the model persists if a verified model was used
  7. Check /help shows /model in the Configuration section

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature
  • I've run pytest tests/ -q and all tests pass (would like CI to verify; manual testing performed)
  • I've added tests for my changes (required for bug fix) — would welcome guidance on adding regression tests
  • I've tested on my platform: Fedora 43 Workstation
  • I've updated relevant documentation — (N/A, this restores a hidden feature)
  • I've updated cli-config.yaml.example — (N/A, no config changes)
  • I've updated CONTRIBUTING.md or AGENTS.md — (N/A, no workflow changes)
  • I've considered cross-platform impact — Pure Python, works on all platforms

Screenshots / Logs

(Optional: attach screenshot showing /model working)

The /model command was added to COMMAND_REGISTRY in PR NousResearch#3372 but the
actual handler in process_command() was never restored. This caused
the command to appear in /help and tab completion but fail with
"Unknown command" when used.

Root cause: The /model slash command was completely removed in commit
9783c9d (NousResearch#3080). While the registry entry was correctly re-added in
NousResearch#3372 (since model_switch.py and related infrastructure still exist),
the dispatch branch in ChatConsole.process_command() was overlooked.

Fix: Add the missing `elif canonical == "model":` handler back to
process_command(), using the existing model_switch module. The
implementation is copied from the pre-removal code (9783c9d^) with
no functional changes.

Files changed:
- cli.py: add model command handler (85 lines)
- hermes_cli/commands.py: already had registry entry from NousResearch#3372

Now /model works as expected for interactive model switching with
proper config persistence and custom endpoint support.

Closes NousResearch#3372 (completes the restoration)
crxssrazr93 added a commit to crxssrazr93/hermes-agent that referenced this pull request Mar 29, 2026
Example plugin demonstrating the lifecycle hooks activated in NousResearch#3542.
Auto-manages a local llama-server (or any OpenAI-compatible server) when
the active model matches a locally configured model name.

Features:
- pre_llm_call hook: auto-starts the correct server on first message
  when hermes is configured with a local model name
- on_session_end hook: kills the server on exit
- switch_local_llm tool: mid-session model switching — the agent swaps
  the server when asked ("switch to the code model")
- Declarative YAML config for model definitions (GGUF paths, context
  sizes, KV cache quantization, sampling params) replacing shell scripts

The plugin is self-contained in docs/llm-switch-plugin-example/ with a
README, example config, and full implementation. Users copy it to
~/.hermes/plugins/llm-switch/ to install.

Complements NousResearch#3360 and NousResearch#3548 which restore /model as a slash command —
once merged, /model custom:write would trigger the pre_llm_call hook
to auto-start the right server seamlessly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution! After reviewing current main, the /model command handler is already fully implemented and has been for some time.

Automated hermes-sweeper review — evidence:

  • cli.py:6037elif canonical == "model": dispatches to self._handle_model_switch(cmd_original)
  • cli.py:5264_handle_model_switch() implements no-arg picker modal, --provider, --global persistence, and custom endpoint flows
  • hermes_cli/commands.py:104CommandDef("model", ...) with aliases=("provider",) is already in COMMAND_REGISTRY
  • Commit 4976a8b06 (feat: /model command — models.dev primary database + --provider flag) restored the handler after the 9783c9d5 removal, and 15+ follow-up commits have extended it since (picker modal, context caps, pricing, etc.)

The premise that the handler was never restored after #3080 does not match the current state of main. No changes are needed.

@teknium1 teknium1 closed this Apr 27, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants