Skip to content

Commit 217e1fc

Browse files
committed
test(retry): lock in-place image fallback behavior
Add a focused regression test for the successful no-image retry path so the original message history stays stripped after fallback and the repeated retry loop cannot silently return. Made-with: Cursor
1 parent b261201 commit 217e1fc

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tests/providers/test_provider_retry.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ async def test_non_transient_error_with_images_retries_without_images() -> None:
165165
assert any("[image: /media/test.png]" in (b.get("text") or "") for b in content)
166166

167167

168+
@pytest.mark.asyncio
169+
async def test_successful_image_retry_mutates_original_messages_in_place() -> None:
170+
"""Successful no-image retry should update the caller's message history."""
171+
provider = ScriptedProvider([
172+
LLMResponse(content="model does not support images", finish_reason="error"),
173+
LLMResponse(content="ok, no image"),
174+
])
175+
messages = copy.deepcopy(_IMAGE_MSG)
176+
177+
response = await provider.chat_with_retry(messages=messages)
178+
179+
assert response.content == "ok, no image"
180+
content = messages[0]["content"]
181+
assert isinstance(content, list)
182+
assert all(block.get("type") != "image_url" for block in content)
183+
assert any("[image: /media/test.png]" in (block.get("text") or "") for block in content)
184+
185+
168186
@pytest.mark.asyncio
169187
async def test_non_transient_error_without_images_no_retry() -> None:
170188
"""Non-transient errors without image content are returned immediately."""

0 commit comments

Comments
 (0)