Skip to content

fix(image-gen): honor top-level image_gen.model and dispatch model kwarg in the xAI provider - #37

Open
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-55927
Open

fix(image-gen): honor top-level image_gen.model and dispatch model kwarg in the xAI provider#37
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-55927

Conversation

@hashbender

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes a parity gap in image-gen model resolution. hermes tools persists the
selected image model to the top-level image_gen.model, and the
image_generate dispatcher forwards it to provider.generate() as a model
kwarg. The xAI provider read only the scoped image_gen.xai.model (plus
the XAI_IMAGE_MODEL env var) and called _resolve_model() with no arguments
— so a user's hermes tools selection was silently dropped and xAI always fell
back to its default grok-imagine-image.

This is the same gap recently fixed for the OpenRouter/Nous provider; openai,
openai-codex and krea already honor the top-level image_gen.model, so xAI was
the lone holdout. This brings xAI in line with the rest.

Related Issue

N/A

Type of Change

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

Changes Made

  • plugins/image_gen/xai/__init__.py
    • Add _load_image_gen_config() — reads the top-level image_gen section.
    • _resolve_model(explicit=None) now follows the same precedence as the
      other providers: explicit dispatch model kwarg → XAI_IMAGE_MODEL env →
      scoped image_gen.xai.model → top-level image_gen.modelDEFAULT_MODEL.
    • generate() forwards the dispatched kwarg: _resolve_model(kwargs.get("model")).
    • The scoped reader _load_xai_config and _resolve_resolution are left untouched.
  • tests/plugins/image_gen/test_xai_provider.py — add scoped / top-level /
    explicit-kwarg model-resolution coverage.

How to Test

Reproduction: set the image model in the top-level image_gen.model (what
hermes tools writes) without a scoped image_gen.xai.model, then resolve the
xAI model.

  • Before: plugins.image_gen.xai._resolve_model() returns grok-imagine-image
    (the default) — the selection is ignored.
  • After: it returns the selected model. The scoped key still works, and an
    explicit dispatched model kwarg wins over config.

Tests run and results:

pytest tests/plugins/image_gen/test_xai_provider.py::TestConfig -v

  TestConfig::test_default_model ........................... PASSED
  TestConfig::test_default_resolution ...................... PASSED
  TestConfig::test_custom_model ............................ PASSED
  TestConfig::test_scoped_config_model            (new) .... PASSED
  TestConfig::test_top_level_config_model         (new) .... PASSED
  TestConfig::test_explicit_model_kwarg_wins_over_config (new)  PASSED
  => 6 passed

The change is isolated to xAI model resolution; verified against an unmodified
baseline that it introduces no new failures in the full
tests/plugins/image_gen/ suite (it adds the 3 passing tests above).

Checklist

  • Read the Contributing Guide; commit follows Conventional Commits (fix(image-gen): …)
  • Searched existing PRs/issues to avoid a duplicate
  • PR contains only changes related to this fix
  • Ran the tests for the affected area — pass (results above)
  • Added tests for the change
  • Documentation / config / tool-schema — N/A (no new config keys; image_gen.model is already documented and honored by the other providers)

Mirror-of: NousResearch#55927
NousResearch#55927

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