fix(models): route image input by preset capability (#6651)

* fix(providers): preserve images across retries and recovery

Remove destructive text-only retries and validate tool image media at the boundary. Keep image identity across native transport preparation and compaction, and stop incomplete fallback or continuation without replaying tools.

Resolves NAN-442

* fix(models): route image input by preset capability

Replace the expanded image recovery and tool-format changes with an explicit supportsImages preset setting, capability-aware fallback selection, and an Image input switch in model settings. Keep original messages on retry and fail on actual non-transient image errors.

* docs(models): introduce image input settings positively

* test(agent): align image request fixtures with preset routing

Cover successful image requests and direct validation errors when attributing model responses. Configure the image-capability check for the existing text-only provider mocks so governance and override-reuse tests exercise their scripted primary/fallback paths.
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-13 18:16:58 +08:00
1 parent 6a24b17629
commit 3f65a8f86c
36 files changed
+483 -444

No files matched your search

+2 -1
View File
@@ -784,7 +784,7 @@ async def test_chat_callback_error_wins_over_close_error(chat_sdk, cleanup_warni
@pytest.mark.parametrize("close_fails", [False, True])
@pytest.mark.parametrize("error_type", [RuntimeError, ConnectionError])
async def test_chat_callback_error_does_not_retry_without_images(chat_sdk, close_fails, error_type):
async def test_chat_callback_error_preserves_input_without_retry(chat_sdk, close_fails, error_type):
stream = _ControlledChatStream(
[_chat_event({"reasoning_content": "thinking"})],
close_error=httpx.CloseError("connection reset") if close_fails else None,
@@ -803,6 +803,7 @@ async def test_chat_callback_error_does_not_retry_without_images(chat_sdk, close
result = await provider.chat_stream_with_retry(messages, on_thinking_delta=on_thinking)
assert result.finish_reason == "error" and "callback failed" in result.content
assert result.error_kind == "callback" and result.error_should_retry is False
assert len(requests) == 1
assert messages == original
assert stream.closed