You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
guardian(opencode): fall back to prompt-only JSON when the gateway rejects response_format #781
Found while re-running the chunked review of #777 after #780 landed.
Problem
All chunk finder calls returned HTTP 400 with this body (now visible thanks to #780):
{"error":{"param":null,"type":"invalid_request_error","code":"invalid_request_error",
"message":"Upstream request failed: [invalid_request_error] This response_format type is unavailable now (request_id: ...)"}}
The gateway does not accept response_format (the json_schema structured-output request) on the upstream route it picked at that moment. It is not the transient inference_failed handled in #780 — retrying invalid_request_error unchanged is not the answer, and the provider correctly does not retry it. A single-pass request minutes earlier got a 200, so structured output is available only sometimes.
The finder relies on generate_structured, so every call fails and the chunked review degrades to "⚠ finder call failed".
Fix
Add OpenCodeStructuredOutputUnavailable, raised when a 400 body marks response_format as unavailable.
In generate_structured: when that error is raised, drop response_format from the payload and send the request again. The prompt already asks for the same JSON, and the caller parses defensively — this is the prompt-only mode OpenRouter already relies on when a model ignores the parameter, so it is a real answer rather than a failed review.
Keep the inference_failed retry and the first-attempt failure for every other 4xx unchanged.
Move the response_format payload construction to one helper on OpenAICompatibleProvider, so the base and the fallback build it identically.
Done when
a response_format-unavailable 400 causes exactly one retry withoutresponse_format, and a successful reply is returned;
if the fallback also fails, the error surfaces with its body (never an empty verdict);
tests cover fallback success (second body has no response_format), fallback failure, and that other 400s are still not retried;
Activity
refactor(guardian): drop the response_format key in place on fallback (…
fix(guardian): fall back to prompt-only JSON when response_format is …