fix(providers): fall back to chat completions on serde body rejections

DeepSeek's new Responses endpoint (deepseek-v4-flash) intermittently rejects valid request bodies with serde deserialization errors such as 'input: invalid type: string ..., expected a sequence'. These were not classified as compatibility errors, so affected conversations died instead of falling back to Chat Completions.

The wire format is correct (input serializes as a list), so this is a server-side Responses compatibility issue; Chat Completions is strictly more permissive, making fallback safe. Extend the fallback classifier to recognize serde body-parsing markers. Repeated failures still trip the existing circuit breaker.
This commit is contained in:
arcdrake22
2026-08-03 18:06:45 +08:00
committed by chengyongru
parent 2b63715282
commit fb2688fd37
2 changed files with 62 additions and 0 deletions
@@ -1082,6 +1082,16 @@ class OpenAICompatProvider(LLMProvider):
"not supported",
"unknown parameter",
"unrecognized request argument",
# Serde-style body rejection: the endpoint could not parse the
# Responses wire format (e.g. DeepSeek's Responses gateway
# rejecting an input item shape with "Failed to deserialize the
# JSON body ... expected a sequence"). These are compatibility
# failures: fall back to Chat Completions for the same model.
"failed to deserialize",
"invalid type",
"expected a sequence",
"expected a struct",
"unknown field",
)
return any(marker in body_text for marker in compatibility_markers)