Skip to content

fix(xai): forward image_gen.model kwarg to _resolve_model in generate() - #55893

Closed
srojk34 wants to merge 1 commit into
NousResearch:mainfrom
srojk34:fix/xai-image-gen-model-kwarg
Closed

fix(xai): forward image_gen.model kwarg to _resolve_model in generate()#55893
srojk34 wants to merge 1 commit into
NousResearch:mainfrom
srojk34:fix/xai-image-gen-model-kwarg

Conversation

@srojk34

@srojk34 srojk34 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • XAIImageGenProvider.generate() accepts **kwargs but calls _resolve_model() with no arguments, silently discarding any model the caller passes.
  • tools/image_generation_tool.py puts kwargs["model"] = configured_model (from image_gen.model in config.yaml) into every provider.generate() call. For the xAI provider, this meant a user selecting grok-imagine-image-quality via hermes tools always got the default grok-imagine-image with no error or log.
  • Mirrors the fix applied to the OpenRouter provider in PR fix(image-gen): honor image_gen.model for Nous/OpenRouter provider #55672, which already threads kwargs.get("model") into its own resolver.

Fix

Add an optional caller_model parameter to _resolve_model() at the highest priority (above XAI_IMAGE_MODEL env and config), and pass kwargs.get("model") from generate(). An unrecognised model name falls through to the existing priority chain unchanged.

Test plan

  • test_caller_model_overrides_env — caller model wins over XAI_IMAGE_MODEL env
  • test_unknown_caller_model_falls_back_to_env — invalid name falls through safely
  • test_model_kwarg_forwarded_to_generate — end-to-end: generate(model="grok-imagine-image-quality") uses the quality model in the POST payload and result

pytest tests/plugins/image_gen/test_xai_provider.py → 32 passed, 0 failed

generate() accepted **kwargs but called _resolve_model() with no
arguments, silently discarding any model the caller supplied.
tools/image_generation_tool.py passes kwargs["model"] = configured_model
sourced from image_gen.model in config.yaml into provider.generate().
For the xAI provider this meant a user selecting grok-imagine-image-quality
via hermes tools always got the default grok-imagine-image instead, with
no error or log. Mirrors the fix PR NousResearch#55672 applied to the openrouter
provider, which already threads kwargs.get("model") into its resolver.

Add caller_model parameter to _resolve_model() at the highest priority
(before env override), and pass kwargs.get("model") from generate().
An unrecognised model name falls through to the existing priority chain.
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins tool/vision Vision analysis and image generation provider/xai xAI (Grok) P3 Low — cosmetic, nice to have labels Jun 30, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused fix. The premise remains valid on current main: tools/image_generation_tool.py:1299-1349 reads top-level image_gen.model and forwards it to provider.generate(**kwargs), while plugins/image_gen/xai/__init__.py:242 still calls _resolve_model() without that value. The proposed forwarding matches current OpenRouter behavior at plugins/image_gen/openrouter/__init__.py:315 and Krea behavior at plugins/image_gen/krea/__init__.py:356.

Suggested changes

  • Add one dispatcher-level regression test with a temporary HERMES_HOME: configure xAI plus image_gen.model, dispatch through the image-generation tool, and assert the outbound xAI payload uses the selected model. The added direct-provider test covers the resolver but not the config propagation path that regressed.

Automated hermes-sweeper review.

@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

@GottZ GottZ left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This was generated by AI during triage.

Summary

Two open PRs address the same xAI model-selection bug: both forward the dispatcher-provided model kwarg into _resolve_model() so the configured top-level image_gen.model is no longer silently dropped. #55893 directly fixes the reported propagation failure and tests the generation payload, while #55927 also adds a redundant direct top-level config fallback but does not test its changed generation path.

Related pull requests

  • #55893 related — (+54/-3) — preferred fix: forwards kwargs.get("model") at highest precedence and verifies that generate(model=...) sends and reports the selected xAI model; before merge, the contributor-requested dispatcher-level HERMES_HOME regression test should be added to cover the full config propagation path.
  • #55927 duplicate — (+65/-3) — duplicate of #55893: implements the same forwarding fix and additionally reads top-level image_gen.model inside the provider, but its tests stop at _resolve_model() and do not verify the changed generate() call or outbound payload. Despite the keep_open review on #55927, the complete diff shows that earlier #55893 covers the same root-cause fix with stronger generation-path coverage, and the review itself identifies #55893 as having the missing test shape.

Duplicates

#55893 and #55927 implement essentially the same xAI model-kwarg forwarding change; #55927 is the later duplicate of #55893.

Suggested consolidation

Merge #55893 after adding the requested dispatcher-level regression test — it is the earlier, narrower fix and already verifies the outbound xAI payload; close #55927 as a duplicate, since its additional provider-side top-level config read is unnecessary for the documented dispatcher path and does not compensate for its missing generation-path test.

Complex graph

flowchart LR
    classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
    classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d
    classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937
    classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151
    classDef best stroke-width:3px,stroke:#b45309
    classDef target stroke-width:3px,stroke:#4338ca
    subgraph Dup55893 ["PRs duplicating each other"]
        P55893["PR #55893 (open)"]
        P55927["PR #55927 (open)"]
    end
    class P55893 open
    class P55927 open
    class P55893 target
    click P55893 "https://github.com/NousResearch/hermes-agent/pull/55893"
    click P55927 "https://github.com/NousResearch/hermes-agent/pull/55927"
Loading

Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed or no verify verdict yet (state tag in the node label).

Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 9 kB of PR diffs, 5 kB of issue/PR text, 3 kB of discussion (3 comments), 1 verify verdict. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

@andrexibiza

Copy link
Copy Markdown
Contributor

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.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks @srojk34 — your fix is now on main via #89890, cherry-picked with your authorship preserved (commit 72b68e0). You were the earliest submitter of this fix and get first credit.

On top of your change we rebased the resolver onto the new live xAI model catalog (validation now happens against live + static models, so the kwarg works for newly released models like grok-imagine-image-2.0 too) and extended the same forwarding to the image-edit path.

Closing since the work has landed. Appreciated!

@teknium1 teknium1 closed this Aug 19, 2026
euntaek-hong pushed a commit to wrongbutworks/hermes-agent that referenced this pull request Aug 19, 2026
…t model; xAI edits honor dispatched model

- plugins/image_gen/openrouter: list_models() now queries the endpoint's
  /models catalog filtered to output_modalities containing "image"
  (per-backend 5-min cache, 10s timeout, static 2-model chain as offline
  fallback; openrouter/auto* router pseudo-models excluded). Every image
  model OpenRouter serves — including future releases — is selectable in
  `hermes tools` with no code change. Applies to Nous Portal too via the
  shared provider class.
- plugins/image_gen/xai: forward the dispatched model kwarg into
  _resolve_edit_model() so an explicitly selected edit-capable model is
  honored on /images/edits (extends the salvaged NousResearch#55893 fix to the edit
  path; text-only models still fall back to quality).
- Tests: OpenRouter live-catalog filtering/exclusions/order, offline
  fallback, cache single-fetch; xAI edit-kwarg forwarding incl. the
  text-only-hijack negative case.

Live-verified against openrouter.ai: 9 image-output models returned and
rendered, matching the public models?output_modalities=image listing.
lisajlau pushed a commit to lisajlau/hermes-agent that referenced this pull request Aug 20, 2026
…t model; xAI edits honor dispatched model

- plugins/image_gen/openrouter: list_models() now queries the endpoint's
  /models catalog filtered to output_modalities containing "image"
  (per-backend 5-min cache, 10s timeout, static 2-model chain as offline
  fallback; openrouter/auto* router pseudo-models excluded). Every image
  model OpenRouter serves — including future releases — is selectable in
  `hermes tools` with no code change. Applies to Nous Portal too via the
  shared provider class.
- plugins/image_gen/xai: forward the dispatched model kwarg into
  _resolve_edit_model() so an explicitly selected edit-capable model is
  honored on /images/edits (extends the salvaged NousResearch#55893 fix to the edit
  path; text-only models still fall back to quality).
- Tests: OpenRouter live-catalog filtering/exclusions/order, offline
  fallback, cache single-fetch; xAI edit-kwarg forwarding incl. the
  text-only-hijack negative case.

Live-verified against openrouter.ai: 9 image-output models returned and
rendered, matching the public models?output_modalities=image listing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have provider/xai xAI (Grok) 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 tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants