Skip to content

fix(moa): parse JSON string reference_models in _normalize_preset - #59497

Closed
wen0531 wants to merge 1 commit into
NousResearch:mainfrom
wen0531:fix/moa-json-string-reference-models
Closed

fix(moa): parse JSON string reference_models in _normalize_preset#59497
wen0531 wants to merge 1 commit into
NousResearch:mainfrom
wen0531:fix/moa-json-string-reference-models

Conversation

@wen0531

@wen0531 wen0531 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Problem

hermes moa list shows hardcoded default models (openai-codex:gpt-5.5, openrouter:deepseek/deepseek-v4-pro) instead of user-configured presets.

Root Cause

hermes moa configure serializes reference_models as a JSON string in config.yaml:

reference_models: '[{"provider":"xiaomi","model":"mimo-v2.5-pro"},{"provider":"minimax","model":"MiniMax-M3"}]'

But _normalize_preset expects a native list — it checks isinstance(raw_refs, list) which fails for strings, then falls back to DEFAULT_MOA_REFERENCE_MODELS.

Fix

Add json.loads() parsing before the type check in _normalize_preset, so both JSON string and native list formats work correctly.

Verification

Before fix:

$ hermes moa list
* default
  Reference models:
    1. openai-codex:gpt-5.5
    2. openrouter:deepseek/deepseek-v4-pro

After fix:

$ hermes moa list
* default
  Reference models:
    1. xiaomi:mimo-v2.5-pro
    2. minimax:MiniMax-M3
    3. deepseek:deepseek-v4-pro

When reference_models is stored as a JSON string (e.g. from hermes moa
configure or hand-edited config.yaml), _normalize_preset silently
falls back to hardcoded defaults because the string fails both
isinstance(x, list) and isinstance(x, dict) checks.

Add json.loads() parsing before the type checks so both formats work.
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels Jul 6, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused normalization fix. Current main does exhibit the fallback: hermes_cli/moa_config.py:132-141 treats a string reference_models value as invalid and substitutes defaults.

Problems

  • The PR has no regression test. tests/hermes_cli/test_moa_config.py:82-97 covers numeric scalars and bare mappings, but not a valid JSON string containing model slots.
  • The stated hermes moa configure root cause does not match current code: hermes_cli/moa_cmd.py:100-117 constructs refs as a native list, assigns it directly, normalizes it, then saves it. The confirmed use case is hand-edited or otherwise pre-existing JSON-string config.

Suggested changes

  • Add a normalization test for a JSON-string list of valid slots, plus malformed JSON fallback behavior.
  • Reframe the PR description around configuration tolerance rather than CLI serialization.

This is an automated hermes-sweeper review.

Comment thread hermes_cli/moa_config.py

raw_refs = raw.get("reference_models")
# reference_models may be a JSON string (hand-edited config.yaml) or a list.
if isinstance(raw_refs, str):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a regression test in tests/hermes_cli/test_moa_config.py covering a valid JSON-string list of reference slots (and malformed JSON fallback), since the existing non-list tests only cover scalar and mapping inputs.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
teknium1 added a commit that referenced this pull request Jul 23, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via cluster PR #70282 (commit 9b868f6) — your commit cherry-picked with authorship preserved, plus regression tests we added for the JSON-string round-trip and malformed-string fallback. Thanks!

@teknium1 teknium1 closed this Jul 24, 2026
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 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 P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants