hermes - ✅(Solved) Fix [Feature]: Make `smart_model_routing` complex keywords configurable in `config.yaml` [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11814Fetched 2026-04-18 05:58:43
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×1renamed ×1

Error Message

smart_model_routing: enabled: true max_simple_chars: 160 max_simple_words: 28 cheap_model: provider: openrouter model: google/gemini-2.5-flash

complex_keywords: - debug - error - traceback - implement - refactor - analyze - compare - review - test - docker - terminal - plan - błąd - analiza - wdrożenie - napraw

Root Cause

Option 3 seems best because it preserves current behavior while allowing language- and workflow-specific tuning.

Fix Action

Fix / Workaround

  • the keyword list is English-only
  • it does not work well for users who primarily interact with Hermes in other languages
  • some teams may want stricter routing, while others may want more aggressive cost savings
  • changing the behavior currently requires patching Hermes source code instead of just editing configuration

This would be especially valuable for self-hosters and multilingual users who want predictable cost/quality tradeoffs without maintaining local source patches.

PR fix notes

PR #11993: feat(agent): make smart_model_routing complex keywords configurable

Description (problem / solution / changelog)

What & why

smart_model_routing routes short/simple turns to a cheap model, but skips that route when the message contains any word from a hardcoded English set (debug, error, refactor, docker, …). The English-only list fails open for non-English users: e.g. a Polish request saying "napraw ten błąd" (fix this error) never trips the guard, so complex debugging work silently routes to the cheap model even when the user expects primary-model quality.

Per #11814, let self-hosters tune the list via config.yaml without patching source.

Change

Two optional keys under smart_model_routing:

smart_model_routing:
  enabled: true
  cheap_model: {provider: openrouter, model: google/gemini-2.5-flash}
  # Extend the built-in list (keeps English defaults + adds entries):
  complex_keywords_extra:
    - błąd
    - napraw
  # OR replace the built-in list entirely:
  # complex_keywords:
  #   - debug
  #   - error

Semantics (matches issue author's recommended Option 3):

  • complex_keywordsfull override — replaces the built-in set.
  • complex_keywords_extraextend — union with the built-in set.
  • When both are set, full override wins (predictability for self-hosters who write an explicit list).
  • Malformed values (non-list, non-string entries) degrade silently to built-ins.
  • Entries are lowercased + stripped.
  • Default behavior unchanged — both keys absent means the built-in list is used as before.

How to test

pytest tests/agent/test_smart_model_routing.py -v

11 passed. 5 new test cases cover:

  • test_complex_keywords_extra_extends_builtin — Polish trigger word routes correctly once added.
  • test_complex_keywords_full_override_replaces_builtin — built-in debug stops triggering when overridden.
  • test_complex_keywords_override_beats_extra — precedence rule when both keys are set.
  • test_complex_keywords_normalize_case_and_whitespace — `" BŁĄD "` normalizes to błąd.
  • test_complex_keywords_ignore_invalid_types — malformed values fall back to built-ins rather than crashing.

Commented example in hermes_cli/config.py updated to document both keys (two sections kept in sync).

Platforms tested

  • macOS (Darwin 25.3.0), Python 3.11.13. Change is platform-agnostic.

Related

Closes #11814

Changed files

  • agent/smart_model_routing.py (modified, +45/-1)
  • hermes_cli/config.py (modified, +26/-0)
  • tests/agent/test_smart_model_routing.py (modified, +57/-0)

PR #12003: feat: make smart_model_routing complex keywords configurable via config

Description (problem / solution / changelog)

Closes #11814

Summary

Makes the hardcoded _COMPLEX_KEYWORDS list in smart_model_routing.py configurable through config.yaml.

Changes

  • agent/smart_model_routing.py: Renamed _COMPLEX_KEYWORDS_DEFAULT_COMPLEX_KEYWORDS, added _resolve_complex_keywords(cfg) that reads config
  • cli.py: Added complex_keywords_extra and complex_keywords_override to config schema
  • tests/agent/test_smart_model_routing.py: 4 new tests covering extra, override, combined, and default behavior

Config keys (under smart_model_routing)

  • complex_keywords_extra: list of additional keywords merged with defaults
  • complex_keywords_override: optional full replacement list (replaces defaults entirely)

All 10 routing tests pass.

Changed files

  • agent/smart_model_routing.py (modified, +22/-2)
  • cli.py (modified, +2/-0)
  • tests/agent/test_smart_model_routing.py (modified, +37/-1)

Code Example

smart_model_routing:
  enabled: true
  max_simple_chars: 160
  max_simple_words: 28
  cheap_model:
    provider: openrouter
    model: google/gemini-2.5-flash

  complex_keywords:
    - debug
    - error
    - traceback
    - implement
    - refactor
    - analyze
    - compare
    - review
    - test
    - docker
    - terminal
    - plan
    - błąd
    - analiza
    - wdrożenie
    - napraw

---

smart_model_routing:
  enabled: true
  complex_keywords_extra:
    - błąd
    - analiza
    - napraw

---
RAW_BUFFERClick to expand / collapse

Problem or Use Case

Feature Description

Please make the smart_model_routing complex-keyword list configurable via config.yaml, instead of keeping it hardcoded in agent/smart_model_routing.py.

Right now, Hermes decides whether a user message is eligible for the cheap model using a fixed _COMPLEX_KEYWORDS set in code. This makes the routing behavior difficult to adapt to different languages, workflows, and user preferences.

Motivation

The current implementation works reasonably well for short English prompts, but it has important limitations:

  • the keyword list is English-only
  • it does not work well for users who primarily interact with Hermes in other languages
  • some teams may want stricter routing, while others may want more aggressive cost savings
  • changing the behavior currently requires patching Hermes source code instead of just editing configuration

A concrete example: when chatting in Polish, many obviously “complex” messages will not match the hardcoded English keywords, so they may still be routed to the cheap model even when that is not desirable.

Making the keyword list configurable would improve:

  • multilingual support
  • transparency of routing behavior
  • user control
  • maintainability for self-hosters

Proposed Solution

Proposed Solution

Add optional config keys under smart_model_routing to override or extend the built-in keyword list.

For example:

smart_model_routing:
  enabled: true
  max_simple_chars: 160
  max_simple_words: 28
  cheap_model:
    provider: openrouter
    model: google/gemini-2.5-flash

  complex_keywords:
    - debug
    - error
    - traceback
    - implement
    - refactor
    - analyze
    - compare
    - review
    - test
    - docker
    - terminal
    - plan
    - błąd
    - analiza
    - wdrożenie
    - napraw

Suggested behavior

A few implementation options could work:

  1. Full override

    • if complex_keywords is set, use only the configured list
  2. Extend built-ins

    • keep the current built-in list as default
    • allow adding extra terms via something like complex_keywords_extra
  3. Most flexible

    • support both:
      • complex_keywords for full override
      • complex_keywords_extra for extension

Example:

smart_model_routing:
  enabled: true
  complex_keywords_extra:
    - błąd
    - analiza
    - napraw

Option 3 seems best because it preserves current behavior while allowing language- and workflow-specific tuning.

Alternatives Considered

Alternatives Considered

  • Keep the list hardcoded

    • simple to maintain, but not flexible enough for multilingual users or custom workflows
  • Auto-detect language and maintain per-language built-in lists

    • useful long-term, but more complex and still less flexible than a config-based solution
  • Use an LLM classifier instead of heuristics

    • potentially smarter, but more expensive, slower, and less predictable than a simple configurable ruleset

Scope / Effort Estimate

Small / Medium — this seems fairly localized to the smart model routing logic and config parsing.

Likely areas touched:

  • agent/smart_model_routing.py
  • config schema / docs / example config
  • tests for default behavior and configured behavior

Additional Context

As implemented today, routing already depends on configurable thresholds like:

  • max_simple_chars
  • max_simple_words

So making the keyword list configurable would be a natural extension of the current design.

This would be especially valuable for self-hosters and multilingual users who want predictable cost/quality tradeoffs without maintaining local source patches.

Feature Type

Configuration option

Scope

Small (single file, < 50 lines)

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

extent analysis

TL;DR

Make the smart_model_routing complex-keyword list configurable via config.yaml to improve multilingual support and user control.

Guidance

  • Add an optional complex_keywords config key under smart_model_routing in config.yaml to override the built-in keyword list.
  • Consider implementing an complex_keywords_extra config key to allow extending the built-in list instead of fully overriding it.
  • Update agent/smart_model_routing.py to parse the new config keys and apply the configured keyword list to the routing logic.
  • Add tests to verify the default behavior and the behavior with configured keyword lists.

Example

smart_model_routing:
  enabled: true
  complex_keywords:
    - debug
    - error
    - traceback
    - implement
    - refactor
    - analyze
    - compare
    - review
    - test
    - docker
    - terminal
    - plan
    - błąd
    - analiza
    - wdrożenie
    - napraw

Notes

The implementation should be localized to the agent/smart_model_routing.py file and the config schema, with a small to medium effort estimate.

Recommendation

Apply the workaround by making the smart_model_routing complex-keyword list configurable via config.yaml, as this will improve multilingual support, transparency of routing behavior, and user control.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Feature]: Make `smart_model_routing` complex keywords configurable in `config.yaml` [2 pull requests, 1 participants]