Repository navigation
Studio: allow max output overrides for custom providers - #8512
danielhanchen merged 7 commits into
Conversation
fd61a3c to
576fe0d
Compare
|
Thanks for your contribution! Unfortunately, this isn’t a complete long-term fix. Inferring the limit would require special configuration for every model and may also depend on the provider serving it. |
|
Thanks, that makes sense. Inferring limits from model IDs is too brittle, especially for aliases and provider-specific deployments. I'll revise this PR to keep the 32K default for Custom providers and add an explicit user override with a warning for unsupported values. |
576fe0d to
6d4a9ff
Compare
Thanks for the direction. I've revised the PR to use an explicit per-connection Max Tokens override for generic Custom providers instead of inferring limits from model IDs. The 32,768 fallback remains the default when no override is configured, and Studio warns that unsupported values may be rejected by the upstream provider. I also added persistence, runtime clamping, preset handling, regression coverage, and manual Studio verification. The previous model-family inference has been removed completely. |
|
Thanks for reworking this, the explicit per-connection override is the right shape. I built Studio twice, once at this PR's merge base Settings, Connections, the Custom connection Chat, run settings, Max Tokens pushed to its ceiling Numbers read from the same servers that were photographed:
The feature works as described. Two things I would like fixed before this lands. 1. Blocking: every save of a connection Studio shows as Custom, but stores as
|
|
I pushed two commits fixing the two items above, plus a third issue that only appears in one browser engine. Details are in the PR description now, so this is the evidence behind them. Firefox silently wiped a saved override. The field was an
With a text input, all three engines reject every bad case with a reason and leave the stored value alone: 0 silent wipes out of 7 inputs ( Upgrade and downgrade, 37/37 checks. A home built and populated by the pre-PR build, upgraded in place to this code: boots, the existing password still authenticates, the Both regressions, before and after. On this branch before the fixes, opening a connection stored as Tests. 61 backend and 2019 frontend passing, typecheck and build clean. I also updated |
|
Thanks for the fixes and the thorough verification. I've synced the two commits locally as well. I also see the new Codex note about preset clamping before the active provider resolves; I'll hold off on further changes unless you'd like me to address it. |
…edits
Three problems found while driving the override end to end against isolated
Studio builds.
1. Every save of a connection Studio DISPLAYS as Custom but STORES as `openai`
returned 400. `resolveUiProviderTypeFromConfig` maps a row saved as `openai`
with a custom display name or base URL back to UI type `custom`, so the new
Max Tokens limit row rendered for it, and `parseMaxOutputTokens("")` returns
null rather than undefined, so the key was still sent and the backend, which
keys the contract on the STORED type, rejected it. A plain rename, a model
change or a key rotation all failed with an error about a field the user
never touched. The backend now accepts an explicit null on any provider type
(clearing an override that cannot exist is a no-op) and the dialog decides
from the stored type, carried on `ExternalProviderConfig.backendProviderType`.
2. The new clamping effect could silently lower and PERSIST a configured Max
Tokens. `isExternalModel` comes from the checkpoint string while the cap comes
from the resolved provider, and the two disagree whenever the provider is
momentarily unavailable: connections toggled off, a cold browser where
settings hydrate before the provider sync lands, or a connection disabled
while selected. The cap then collapsed to the 32,768 fallback and the effect
wrote it through, permanently, which defeats the feature it belongs to. It now
waits for `settingsHydrated` and a resolved provider: no provider means the cap
is unknown, not 32,768.
3. The Max Tokens limit field is a text input rather than `type="number"`. The
HTML value sanitization algorithm replaces anything the engine does not read
as a valid floating-point number with the empty string, and empty means "no
override" here, so a grouped entry like "131,072" left the box looking filled
and silently cleared the saved override. Observed in Firefox, where a stray
character reported "" and the save reported success; Chromium and WebKit kept
the digits. The raw string now reaches the existing validator, which rejects
it with a reason. This matches NumericValueInput in the run-settings panel.
The two decisions are pure functions, `supportsCustomMaxOutputTokens` and
`resolveExternalMaxTokensClamp`, so they can be tested without a DOM.
…aths Backend: an existing studio.db written before this column exists, opened by this build and then opened AGAIN by a build that has never heard of the column, which is what reverting to the previous release does; migration idempotence, since ALTER TABLE has no IF NOT EXISTS; the route contract per provider type, where an explicit null has to be accepted everywhere and a real override still refused outside generic Custom; the set, preserve and clear lifecycle asserted against the stored row; exact round-tripping at the top of the accepted range; and the metadata rollback when a credential write fails. `test_credential_routes.py`: the test that pinned "reject the field on any non-custom provider" now pins "reject only a non-null value", plus two tests asserting an explicit null is accepted on create and on update. Frontend: the stored-versus-displayed provider type truth table including the unknown-type fallback, normalization of anything an older localStorage entry could hold, a golden slice of the capability table proving no named provider's cap moved, the clamp guards, and a pre-feature entry loading without gaining a cap. Verified against three isolated installs (merge base, this branch before these fixes, and after) on Linux with chromium, firefox and webkit, which covers Chrome, Edge, Firefox and Safari's engine. An old home upgraded in place keeps its connections, migrates its schema and reads the 32,768 fallback; the same home opened again by the previous build still lists, edits and creates.
0f5982e to
67efd37
Compare
…ider Two more places applied a cap derived from provider data that may not be there yet, and both only ever lower, so a blink in the provider list cost the user their configured value permanently. `applyPresetParamsWithinCurrentLimits` was gated on `isExternalModel` alone, so applying or falling back to a preset while the connection was unresolved wrote the 32,768 fallback into the live params. `setCheckpoint` looked the provider up and clamped whether or not it found one, so a checkpoint restored or selected before the provider store hydrated read the fallback instead of the connection's cap. That path predates this feature, but the override is what gives it something to destroy: without one, a Custom connection could never exceed 32,768 and the clamp was a no-op. Both now take the rule the settings-panel effect already uses: no provider means the cap is unknown, not 32,768.
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
|
Re-shot the before/after evidence at the current head after this round's fixes, so the pair matches what is actually on the branch now rather than the state I first photographed. Merge base Same numbers as before, read from the photographed servers: Cross-platform staging CI on this head: ubuntu-latest, macos-14 and windows-latest all green, plus the studio-live Playwright job across chromium, firefox and webkit. Two failures on the sibling staging branch are unrelated to this change and pass on the branch that carries the same code: a process-kill timing test in |
`max_output_tokens: int | None | object = _UNSET` is the module's first PEP 604 annotation, and annotations evaluate at def time, so the module stopped importing on 3.9 while pyproject still declares >=3.9. tests/test_python39_compatibility.py enforces this with a debt counter and caught it at 36 files, up from 35.
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |




Summary
Fixes #8509
Custom OpenAI-compatible providers currently use Studio's conservative
32,768-token max-output fallback, with no way to configure a higher limit
for a specific Custom connection.
This PR adds an explicit per-connection Max Tokens override for generic
Custom providers.
Changes
the saved preset itself.
Backward compatibility
Existing Custom connections have no override stored, so they continue using
the existing 32,768-token fallback.
The override applies only to the generic
customprovider type.An existing
studio.dbgains the column throughALTER TABLE, so an installthat upgrades in place keeps its connections and reads the 32,768 fallback
until an override is set. A home written by this build stays readable and
writable by the previous release.
Testing
npm run typechecknpm run buildgit diff --checkdeepseek-v4-flashManual verification
Verified with a Custom OpenAI-compatible connection:
Maintainer follow-up (danielhanchen)
Two commits on top of the above, from driving the feature end to end against
three isolated Studio builds: this PR's merge base, its head, and the head plus
these fixes.
1. Unrelated edits of a legacy Custom connection returned 400.
resolveUiProviderTypeFromConfigreports UI typecustomfor a row STORED asopenaiwith a custom display name or base URL, so the new field rendered forthose, and a blank field serialises as null rather than as an omission. The
backend keys the contract on the stored type, so it rejected the null and every
save failed, including a plain rename. The backend now accepts an explicit null
on any provider type, and the dialog decides from the stored type, carried on
ExternalProviderConfig.backendProviderType.2. The clamping effect could silently lower and persist a configured value.
isExternalModelcomes from the checkpoint string while the cap comes from theresolved provider, and the two disagree whenever the provider is momentarily
unavailable: connections toggled off, a cold browser where settings hydrate
before the sync lands, a connection disabled while selected. The cap collapsed
to 32,768 and the effect wrote it through permanently. It now waits for
settingsHydratedand a resolved provider.3. The Max Tokens limit field is a text input, not
type="number". The HTMLvalue sanitization algorithm hands JavaScript an empty string for anything the
engine does not read as a valid floating-point number, and empty means "no
override" here. Measured in Firefox: typing a stray character wiped the saved
override and reported success. Chromium and WebKit kept the digits. The raw
string now reaches the existing validator.
Verified on Linux with chromium, firefox and webkit, covering Chrome, Edge,
Firefox and Safari's engine. Not covered: Safari and Edge as shipped products,
Windows and macOS hosts, real upstream inference.
Two things left open deliberately, both needing a maintainer decision rather
than a patch here:
MAX_SAFE_INTEGERupper bound makes the slider unusable at the top of itsrange: at 2**53-1 one pixel is about 40 trillion tokens and an arrow press
moves the thumb 0.0px. The number input still works. A rendered ceiling near
1,048,576, with the input still accepting the full range, would be kinder.
stores/chat-runtime-store.tssetCheckpointclamps and persistsmaxTokenswith no hydration or provider-availability guard, so an unfound provider
yields 32,768. Same hazard as item 2, but it predates this PR.