fix(providers): tighten tool calls and compatibility fallbacks

Require structured tool calls and explicit unsupported-feature errors.
Preserve supported SDK compaction requests and add compatibility coverage.

Co-authored-by: Xubin Ren <52506698+Re-bin@users.noreply.github.com>
This commit is contained in:
chengyongruandXubin Ren authored and Xubin Ren committed 2026-10-31 11:55:13 +08:00
1 parent 3e40684112
commit 8b37976d36
16 files changed
+406 -168

No files matched your search

@@ -201,11 +201,22 @@ def test_serde_deserialize_error_does_not_trigger_fallback():
assert OpenAICompatProvider._should_fallback_from_responses_error(err) is False
def test_legacy_compatibility_markers_still_trigger_fallback():
def test_explicit_unsupported_responses_parameter_allows_fallback():
err = _FakeAPIError(400, "parameter `instructions` is unsupported")
assert OpenAICompatProvider._should_fallback_from_responses_error(err) is True
@pytest.mark.parametrize(("status", "body", "expected"), [
(400, {"code": "unsupported_parameter", "param": "instructions"}, True),
(400, {"code": "unsupported_value", "param": "instructions", "message": "Invalid instructions"}, False),
(404, {"message": "Previous response with id 'resp_missing' not found"}, False),
(422, {"message": "Unsupported value for max_output_tokens: must be at most 64"}, False),
])
def test_responses_errors_distinguish_unsupported_parameters_from_invalid_requests(status, body, expected):
err = _FakeAPIError(status, body)
assert OpenAICompatProvider._should_fallback_from_responses_error(err) is expected
# DeepSeek Responses wire shape (PR #5214 root cause)