fix(xai-image): drop unreachable editing code path

The agent-facing image_generate tool only passes prompt + aspect_ratio to
provider.generate() (see tools/image_generation_tool.py:953). The editing
block (reference_images / edit_image kwargs) could never fire from the
tool surface, and the xAI edits endpoint is /images/edits with a
different payload shape anyway — not /images/generations as submitted.

- Remove reference_images / edit_image kwargs handling from generate()
- Remove matching test_with_reference_images case
- Update docstring + plugin.yaml description to text-to-image only
- Surface resolution in the success extras

Follow-up to PR #14547. Tests: 18/18 pass.
This commit is contained in:
teknium1 2026-04-23 15:12:05 -07:00 committed by Teknium
parent a5e4a86ebe
commit 9599271180
3 changed files with 6 additions and 41 deletions

View file

@ -5,7 +5,6 @@ Exposes xAI's ``grok-imagine-image`` model as an
Features:
- Text-to-image generation
- Image editing with reference images
- Multiple aspect ratios (1:1, 16:9, 9:16, etc.)
- Multiple resolutions (1K, 2K)
- Base64 output saved to cache
@ -46,7 +45,7 @@ _MODELS: Dict[str, Dict[str, Any]] = {
"grok-imagine-image": {
"display": "Grok Imagine Image",
"speed": "~5-10s",
"strengths": "Fast, high-quality, supports editing",
"strengths": "Fast, high-quality",
},
}
@ -180,10 +179,6 @@ class XAIImageGenProvider(ImageGenProvider):
resolution = _resolve_resolution()
xai_res = _XAI_RESOLUTIONS.get(resolution, "1024")
# Check for editing mode (reference images)
reference_images = kwargs.get("reference_images", [])
edit_image = kwargs.get("edit_image")
payload: Dict[str, Any] = {
"model": API_MODEL,
"prompt": prompt,
@ -191,12 +186,6 @@ class XAIImageGenProvider(ImageGenProvider):
"resolution": xai_res,
}
# Add editing parameters if present
if reference_images:
payload["reference_images"] = reference_images[:5]
if edit_image:
payload["image_url"] = edit_image
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
@ -300,9 +289,9 @@ class XAIImageGenProvider(ImageGenProvider):
aspect_ratio=aspect,
)
extra: Dict[str, Any] = {}
if reference_images:
extra["reference_images"] = len(reference_images)
extra: Dict[str, Any] = {
"resolution": xai_res,
}
return success_response(
image=image_ref,
@ -310,7 +299,7 @@ class XAIImageGenProvider(ImageGenProvider):
prompt=prompt,
aspect_ratio=aspect,
provider="xai",
extra=extra if extra else None,
extra=extra,
)

View file

@ -1,6 +1,6 @@
name: xai
version: 1.0.0
description: "xAI image generation backend (grok-imagine-image). Supports text-to-image and editing."
description: "xAI image generation backend (grok-imagine-image). Text-to-image."
author: Julien Talbot
kind: backend
requires_env:

View file

@ -199,30 +199,6 @@ class TestGenerate:
assert result["success"] is False
assert result["error_type"] == "empty_response"
def test_with_reference_images(self):
from plugins.image_gen.xai import XAIImageGenProvider
mock_resp = MagicMock()
mock_resp.status_code = 200
mock_resp.raise_for_status = MagicMock()
mock_resp.json.return_value = {
"data": [{"url": "https://xai.image/edited.png"}],
}
with patch("plugins.image_gen.xai.requests.post", return_value=mock_resp) as mock_post:
provider = XAIImageGenProvider()
result = provider.generate(
prompt="Edit this image",
reference_images=["https://example.com/ref1.png", "https://example.com/ref2.png"],
)
assert result["success"] is True
# Check that reference_images was passed in payload
call_args = mock_post.call_args
payload = call_args.kwargs.get("json") or call_args[1].get("json")
assert "reference_images" in payload
assert len(payload["reference_images"]) == 2
def test_auth_header(self):
from plugins.image_gen.xai import XAIImageGenProvider