fix(image-gen): honor top-level image_gen.model and dispatch model kwarg in the xAI provider - #55927
Conversation
…arg in the xAI provider `hermes tools` persists the selected image model to the top-level `image_gen.model`, and the image_generate dispatcher forwards it as a `model` kwarg to `provider.generate()`. 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 — 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 key, so xAI was the lone holdout. Mirror the established precedence (explicit dispatch `model` kwarg → `XAI_IMAGE_MODEL` env → scoped `image_gen.xai.model` → top-level `image_gen.model` → `DEFAULT_MODEL`) by adding an `explicit` parameter and a top-level fallthrough to `_resolve_model`, and passing the dispatched kwarg from `generate()`. The scoped config reader (`_load_xai_config`) and the resolution lookup are left untouched. Adds top-level / scoped / explicit-kwarg coverage to tests/plugins/image_gen/test_xai_provider.py::TestConfig.
Duplicate of #55893 -- both make |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing the configuration path. The fix matches the current dispatcher contract: tools/image_generation_tool.py:1336-1349 forwards top-level image_gen.model, while current xAI code drops it at plugins/image_gen/xai/__init__.py:242 by calling _resolve_model() without arguments.
Problems
- The new resolver tests do not exercise the changed
generate()forwarding call.tests/plugins/image_gen/test_xai_provider.py:139-157already mocks a successful generation, but it does not passmodel=or assert the outbound JSON payload. This leaves the exact dispatch behavior changed atplugins/image_gen/xai/__init__.py:259unverified.
Suggested changes
- Add a generation-path regression test passing
model="grok-imagine-image-quality"and asserting both the returned model andrequests.postJSON payload use that ID. The earlier duplicate #55893 includes this shape of coverage.
Automated hermes-sweeper review.
| @@ -234,7 +259,7 @@ def generate( | |||
| aspect_ratio=aspect_ratio, | |||
There was a problem hiding this comment.
Please add a generation-path regression test for this forwarding call: invoke generate(..., model="grok-imagine-image-quality") and assert the mocked POST JSON contains that model. The new tests currently exercise _resolve_model() directly, not this changed dispatch path.
|
Campaign #80424 collision class — XAI-IMAGE-MODEL This PR is part of a collision class adjudicated under the Grok/xAI campaign rebaseline (2026-08-14). The canonical disposition is recorded on #80424.
Implementation of this class is blocked until Wave 0 (T00-T04) completes classification and the canonical collision/supersession table is agreed. |
|
Thanks @Frowtek — the fix this PR implements is now on Worth noting: your additional top-level Closing as implemented on main. Thanks for the contribution! |
What does this PR do?
Fixes a parity gap in image-gen model resolution.
hermes toolspersists theselected image model to the top-level
image_gen.model, and theimage_generatedispatcher forwards it toprovider.generate()as amodelkwarg. The xAI provider read only the scoped
image_gen.xai.model(plusthe
XAI_IMAGE_MODELenv var) and called_resolve_model()with no arguments— so a user's
hermes toolsselection was silently dropped and xAI always fellback 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 wasthe lone holdout. This brings xAI in line with the rest.
Related Issue
N/A
Type of Change
Changes Made
plugins/image_gen/xai/__init__.py_load_image_gen_config()— reads the top-levelimage_gensection._resolve_model(explicit=None)now follows the same precedence as theother providers: explicit dispatch
modelkwarg →XAI_IMAGE_MODELenv →scoped
image_gen.xai.model→ top-levelimage_gen.model→DEFAULT_MODEL.generate()forwards the dispatched kwarg:_resolve_model(kwargs.get("model"))._load_xai_configand_resolve_resolutionare 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(whathermes toolswrites) without a scopedimage_gen.xai.model, then resolve thexAI model.
plugins.image_gen.xai._resolve_model()returnsgrok-imagine-image(the default) — the selection is ignored.
explicit dispatched
modelkwarg wins over config.Tests run and results:
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
fix(image-gen): …)image_gen.modelis already documented and honored by the other providers)