Repository navigation
Fix Deep Research JSON output on MLX and Transformers - #10611
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Confirmed this hits the path in studio/backend/core/research_runs.py where json_mode always sends response_format and the non-GGUF route in routes/inference.py rejects it with a 400, so Research cannot start on MLX or Transformers. Will get this reviewed. |
The fallback keyed on code=unsupported_parameter plus param=response_format alone. routes.inference sends that same pair from three places: the non-GGUF branch that has no grammar engine, the GGUF audio branch, and Unsloth's tool loop. Only the first is answerable by re-sending the same prompt without the contract; the other two refuse again, and an audio model that does support speech synthesizes the planner prompt instead of reporting. Require the grammar-engine message as well, and skip the retry when the local backend serving the run is an audio model, since the non-GGUF branch refuses the format before it reaches its own audio routing. Both probes are the ones routes.inference itself branches on, and an unprobeable backend keeps the existing behaviour. The refusal fixture now carries the message the route actually sends, with the audio and tool-loop messages added as negative cases. The wall-clock test moves from 0.4s/0.25s to 1.6s/1.0s: same semantics, 600ms of scheduling slack instead of 150ms, which is what it has to survive under -n 4 on a loaded runner.
|
Reviewed and tested this. The bug is real, the fix works, and I pushed one commit to the branch narrowing the refusal it negotiates on. Before and afterBefore: After: that one refusal is negotiated away once per call and the run proceeds on prompt-only JSON, which the phases already ask for and already validate. I proved the regression rather than taking it on trust. Merge base is The 12 Does it break anythingNo. CI-shaped full backend run (
The failing and erroring node id sets are byte-identical across all three (643 unique ids each, empty symmetric difference). Those are pre-existing environment gaps on this host, untouched by the PR. The passed delta is exactly the new test file. Blast radius is genuinely small: the diff touches On hardware: this is not a new hardware path. The route's discriminator is What I changedThe predicate matched
I drove all three through the real route. The tool-loop one is unreachable for Research (it sits behind So the commit does two things:
Plus tests: your I also ran a separate simulation suite outside the tree, 27 cases: chunked and mid-read-failing refusal bodies, a 200KB unicode body, malformed error envelopes, Follow-ups, not blockers
LimitationEverything above is scripted backends and the real FastAPI route on Linux. No real MLX weights and no Apple Silicon inference, same caveat you gave. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
With scripted non-GGUF model output, Deep Research now reaches plan review after the local API refuses JSON grammar support. The same installed Studio scenario fails with HTTP 400 on the merge base; the head retries once, makes one generation call, and displays the plan. Reload preserved the plan, Stop research cancelled it, and invalid JSON still failed validation. The model-switch fix keeps Research requests text-only across retries. Focused backend and audio regressions passed. Model generation was scripted; native MLX and complete report generation were not tested. Pre-commit passed; 40 Actions jobs were cancelled and provide no validation result. Before |
Not every caller of this route hands it a request with headers. The durable-run producer builds its own, routes/preview.py passes one through, and the audio monitor tests stand one in without them, which is why the UI-events header is already read through a getattr-guarded helper rather than off request.headers. The new opt-out read headers directly, so every audio reply on those callers raised AttributeError instead: three existing monitor tests went red. Give it a named constant and the same guarded reader, and pin the header-less shape on both the GGUF and non-GGUF audio branches so it cannot regress.
|
Heads up on Not every caller of this route hands it a request that has headers. Every audio reply on such a caller raised instead of answering. Red on my full backend run at
On the fix itself: I had written the same server-side reorder before I saw your commit, then dropped it, since yours is strictly better. The header covers the case a route-side check alone cannot, a switch to audio landing after the refusal and before the re-send. I drove that interleaving end to end against the real route rather than reasoning about it: statuses The 40 red checks on the previous head were not yours. Every run for |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Comment lines this branch adds go from 28 to 10, licence header included. Delete what the code already says, collapse the rest to one line where the indentation leaves room. Every surviving line carries a fact the code does not state: which refusals share the code and param, why the retry is negotiated after routing, why the opt-out is per request rather than per model, and what the wall-clock test's margin is protecting against.
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Etherll
left a comment
There was a problem hiding this comment.
Tested Locally + In colab waiting for CI

Problem
Deep Research sends
response_format: {"type": "json_object"}for planning, decisions and synthesis audits. Studio's MLX and Transformers routes reject this guided-decoding parameter, so research fails before generation with “Local model request failed with HTTP 400.”Change
Retry a local Research call once without
response_formatonly when the API returns HTTP 400 withcode=unsupported_parameterandparam=response_format. Keep the JSON prompts and existing output validation. Recheck cancellation and lease ownership before retrying within the original timeout and transport retry budget.Supported local backends and external providers retain their format contract. Direct API requests still receive the unsupported-format error; unrelated errors and repeated refusals propagate. Tool opt-outs remain intact, including when server tools are forced on.
Validation
4b6bc280a9and passes with the fix.Limitations
The live validation scripts model generation and search responses. Actual MLX weights, Apple Silicon inference and the exact reported desktop build have not been tested. The fallback adds one refused HTTP request per JSON phase. JSON quality remains model-dependent: existing validation rejects invalid plans, can fall back to an approved search for invalid decisions, and can proceed without an invalid audit.