Skip to content

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

Open
v1-100-lab wants to merge 1 commit intoNousResearch:mainfrom
v1-100-lab:fix/model-command-handler
Open

fix(cli): restore /model command handler#3548
v1-100-lab wants to merge 1 commit intoNousResearch: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>
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