Repository navigation
Studio: make the Min P and Repetition Penalty sliders work - #10456
danielhanchen merged 7 commits into
Conversation
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
|
Confirmed the body built in studio/backend/core/inference/external_provider.py never carried top_k, min_p or repetition_penalty, so those sliders were inert on vLLM, llama.cpp and OpenRouter, and the repeat_penalty rename matches what llama-server reads. Will get this reviewed. |
The two test files here read source rather than running the flow. The backend one hands the client an httpx.MockTransport, and the route half is checked by AST-parsing routes/inference.py and comparing the names passed to dict(...) against the strings _top_k_explicit and friends. That proves the source says the right words. It cannot fail on the runtime hazard those words exist to prevent: pydantic v2 records every setattr in model_fields_set, so a write to the payload before those three reads turns an omission into an explicit request for the schema default. Adds test_external_provider_sampling_over_the_wire.py, which drives _proxy_to_external_provider itself and a real http.server on loopback records the bytes. Stdlib only, port 0, no external network, so it runs the same on the Linux, macOS and Windows legs. Against the merge base 11 of its 13 cases fail; they pass here. Also corrects two comments. The note above the model_fields_set reads implied _fill_recommended_sampling_openai runs on this path; it does not, the external branch returns well before its call site, so the note now says what the ordering rule actually is and what enforces it. And the sampling test docstring still described custom as offering all three, which this PR is what makes false.
|
Ran this end to end against the merge base. The bug is real, the fix works, and the sliders that disappear are the ones that were never going anywhere. Details and evidence below. What changes, before and afterBase 1. The sliders that get hidden
Ollama connection: Custom connection: vLLM connection, the control: Rows read out of the DOM rather than counted by eye, so "gone" means gone and not scrolled out of view:
The vLLM pair is byte-identical, which is the control doing its job, so that run needed 2. The request bodyA real
On the base, even an explicit The explicit-versus-default handling matches how OpenRouter documents its own behaviour, which is that an absent parameter is left out so the provider applies its default, while a parameter explicitly sent at its conventional default is still forwarded and can differ from omitting it. That distinction is exactly what Test results
One commit pushed
Both test files here read source instead of running the flow. The backend one hands the client an So the commit adds It also corrects two comments. The note above the Two things worth calling out, neither a blockerExisting vLLM, llama.cpp and OpenRouter connections will sample differently after upgrading. The panel spreads these fields whenever the capability flag is true, and the store's defaults are A vLLM server saved under the Custom preset cannot be migrated without losing its threads. The description suggests moving to the vLLM or llama.cpp preset to keep the extra sliders, but Nothing else stood out. The |
Opening comment-reduction pass. Added comment lines across the PR go from 74 to 28, and the six that remain untouched are the SPDX and copyright headers. Cuts are deletions where a test name or the code already carried the fact, and the survivors are the ones neither states: that llama-server reads repeat_penalty, that Ollama's /v1 silently drops these three, that 0 means disabled so a truthiness gate would restore the server default, that the schema defaults are non-None so only model_fields_set separates an omission from a request for the default, and the Ollama compatibility citation. No code touched.
|
@codex review |
|
@codex security review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d90a11ab61
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| if top_k is not None: | ||
| body["top_k"] = top_k |
There was a problem hiding this comment.
Strip extension sampling fields for custom providers
When provider_type="custom", this now forwards top_k (and the adjacent new extensions) even though the capability map deliberately treats Custom as a strict OpenAI-compatible endpoint. In particular, a cached pre-deploy frontend still classifies Custom as ALL_SUPPORTED and includes top_k on every request, so after only the backend updates, strict custom gateways can start returning 400s where the same requests previously worked. Direct API callers can trigger the same regression. Add these fields to Custom's server-side body_omit, as done for Ollama, while users needing them can select the vLLM or llama.cpp provider type.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and reachable without a raw API caller. Fixed in a933d60.
Reproduced the exact path: the pre-PR bundle classifies custom as ALL_SUPPORTED and the body spreads top_k on every request, so the wire body for an untouched Custom connection carries top_k 20. index.html is served no-cache and the assets are content-hashed, so a reload does pick up the new bundle, but a tab left open across a Studio upgrade keeps running the old one and never re-fetches index.html. Against a gateway that validates its input, that identical body returns 200 on the merge base 6133092 (top_k dropped) and 400 on this branch (top_k forwarded), and a strict endpoint rejects the whole turn rather than ignoring the key, which is the documented behaviour for an unrecognized top-level argument.
custom now carries the same body_omit as ollama. Servers that do want these stay reachable through the vllm and llama_cpp presets, which take any base URL. test_the_sliders_reach_the_server dropped its custom parametrization since it asserted the behaviour this changes, and the ollama strip test became one parametrized guard over both providers; a new over-the-wire case replays the stale-bundle body against a validating gateway. Both fail without the registry entry.
The capability map now treats Custom as a strict OpenAI-compatible endpoint, but the backend still forwarded top_k, min_p and repetition_penalty for it, so the panel and the request disagreed in the one direction this PR exists to close. That is reachable without a raw API caller. The pre-PR bundle classified custom as ALL_SUPPORTED and spread top_k on every request, and a browser tab left open across an upgrade keeps running it: index.html is served no-cache, but a loaded SPA does not re-fetch it until someone reloads. Measured against a gateway that validates its input, the identical body goes 200 on the merge base and 400 on this branch, because the merge base dropped top_k and this branch forwards it. A strict endpoint rejects the whole turn rather than ignoring the key. Adds body_omit to the custom preset, the same guard ollama already carries here, so neither can leak a field its endpoint cannot take. Servers that do want these are reachable through the vllm and llama_cpp presets, which accept any base URL. test_the_sliders_reach_the_server dropped its custom parametrization because it asserted the behaviour this changes, and the ollama strip test is now one parametrized guard over both. Both new cases fail without the registry entry.
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
Final comment-reduction pass. The stale-tab rationale was written out three times, once at the registry entry and once in each test. It belongs at the registry entry that exists because of it; the tests name the behaviour they check, not the history. Twelve lines become five, and the PR's added comment lines land at 33 against 74 on the original branch. No code touched.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04db26cf9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| if top_k is not None: | ||
| body["top_k"] = top_k | ||
| if min_p is not None: | ||
| body["min_p"] = min_p | ||
| if repetition_penalty is not None: |
There was a problem hiding this comment.
Restrict sampling extensions to supported providers
When a direct /v1/chat/completions caller explicitly supplies one of these fields for an OpenAI-compatible hosted provider whose capability row disables it, such as Kimi or DeepSeek, this unconditional insertion now forwards the unsupported extension upstream. The registry only strips these fields for Custom and Ollama (Kimi's body_omit covers only temperature and top_p), so requests that previously succeeded while ignoring the extension can now be rejected by the provider. Gate forwarding server-side to vLLM, OpenRouter, and llama.cpp, or add matching omission rules for unsupported providers; frontend capability checks do not protect public API callers.
Useful? React with 👍 / 👎.



On OpenRouter, vLLM and llama.cpp connections the chat settings panel shows Min P and Repetition Penalty sliders and remembers their values per model and per thread. The request never carried either one, so moving the sliders had no effect on the output.
Top K had a second problem in the same area. The value was passed all the way through to the client and then never written into the request body, even though the code comment said it was forwarded.
All three are now sent, and only when a value was actually set, so a request that does not mention them still sends nothing. For llama.cpp the field is renamed to repeat_penalty, which is the name that server reads. Sending repetition_penalty to it is accepted and then ignored, so the slider looked broken. The in process llama.cpp client in this repo already uses the correct name.
Ollama does not accept any of the three on its OpenAI compatible endpoint. They belong to its own API instead, and unknown fields there are dropped without an error. Those sliders are now hidden for Ollama, and the fields are also stripped on the server side, since that endpoint can be called directly and not only from the app.
Custom connections stay on the standard OpenAI fields. An unknown server behind a custom base URL may reject fields it does not know, and the vLLM and llama.cpp presets accept any base URL if you want the extra sliders.
Hosted providers are unchanged. They already report these sliders as unsupported, so nothing new appears in their requests.