mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 06:03:26 -05:00
[GH-ISSUE #24930] issue: DEFAULT_MODEL_PARAMS (admin "Default Parameters") not applied to outbound payloads — only OWUI-internal flags inherit, sampling params like max_tokens are silently dropped #123745
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ryan-pip on GitHub (May 20, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24930
Check Existing Issues
Searched terms include
DEFAULT_MODEL_PARAMS,default parameters max_tokens,default model params,max_tokens not applied,default sampling params,apply_model_params_to_body,model_info_params,global default ignored. Closest existing reports are not duplicates:DEFAULT_MODEL_PARAMSignored when set via env var withENABLE_PERSISTENT_CONFIG=false(env-parse path, different code path; in this report the value IS persisted and visible via/api/v1/configs/export).Installation Method
Docker
Open WebUI Version
main(verified against current HEADd47c88f, 2026-05-20). The bug is also present in the latest release v0.9.5.Ollama Version (if applicable)
Not applicable — bug is server-side and reproducible against any OpenAI-compatible upstream that honours
max_tokens. The Ollama router has the same shape and is likely affected (see "Logs & Code references" below).Operating System
Not OS-dependent — bug is in
backend/open_webuiPython code.Browser (if applicable)
Not applicable — bug is server-side. Outbound chat-completion request payload is wrong regardless of client.
Confirmation
README.md.Relevant configuration:
DEFAULT_MODEL_PARAMSset via the admin UI ("Settings → Models → Default Parameters"), persisted to the config table (visible via/api/v1/configs/exportasmodels.default_params.*). No env-var overrides forDEFAULT_MODEL_PARAMS. The active model's storedinfo.paramsJSON does NOT contain amax_tokenskey (only e.g.function_calling,custom_params). Provider is an OpenAI-compatible endpoint (also reproduces against Amazon Bedrock via the bedrock-access-gateway, which simply forwardsmax_tokens).Expected Behavior
Setting
Default Parameters → max_tokensin the admin UI should apply that value to outbound chat-completion requests for any model whose ownparamsobject does not specifymax_tokens. The intuitive precedence (which the admin UI implies) is:This should hold for all provider sampling parameters:
max_tokens,temperature,top_p,top_k,frequency_penalty,presence_penalty,seed,stop, etc.Actual Behavior
The global default is persisted correctly and even merged into an in-memory
model_info_paramsdict inmain.py, but the merged dict is then only consulted for four Open WebUI-internal flags (stream_response,stream_delta_chunk_size,reasoning_tags,function_calling). Every provider sampling parameter — includingmax_tokens— is dropped on the floor because the OpenAI router (and the Ollama router) readsmodel_info.paramsdirectly instead of the merged dict.Net effect: the admin "Default Parameters" form looks like it works (the value is persisted, the export endpoint confirms it, the UI shows it), but for
max_tokens/temperature/etc. it is dead code on the OpenAI path. Outbound requests go out with Open WebUI's hardcoded fallback (max_tokens: 2048viaapply_model_params_to_body_openai) unless the per-modelinfo.paramsor per-chat controls explicitly set the field.The user-visible symptom: long responses are truncated mid-stream (e.g. mid-tool-call when emitting large structured outputs) because the model only generates 2048 tokens, despite the admin having set
max_tokens: 128000globally.Steps to Reproduce
main(or v0.9.5) backed by any OpenAI-compatible provider that honoursmax_tokens(OpenAI itself, Azure OpenAI, Bedrock via bedrock-access-gateway, vLLM, LM Studio, etc.). No special config required — defaults.max_tokensto a recognisable value, e.g.99999. Save.curl -H "Authorization: Bearer $TOKEN" https://<host>/api/v1/configs/export | jq '.models.default_params.max_tokens'→ returns99999. (The config IS saved correctly; this rules out persistence bugs like #21837.)max_tokensin itsparamsJSON (the default for any model that hasn't been edited). Optionally inspect viaGET /api/v1/models/<id>.apply_model_params_to_body_openai/ beforeaiohttp_client_session.post(...)inrouters/openai.py. Observe"max_tokens": 2048in the JSON payload (Open WebUI's hardcoded default), NOT99999.max_tokensto50000for the chat. Send another prompt. Observe"max_tokens": 50000in the outbound request — confirming the per-chat override path works fine and isolating the bug to the global default fallback.max_tokens: 77777to itsparams. Start a new chat (no chat-control override). Observe"max_tokens": 77777— confirming the per-model path also works.The bug is specifically: per-chat override works, per-model
paramsworks, but the globalDEFAULT_MODEL_PARAMSfallback for sampling params does NOT work on the OpenAI path. Same trace on the Ollama path.Logs & Screenshots
Code trace against
mainat commitd47c88f(2026-05-20):1.
backend/open_webui/main.py:1709-1713— the merge IS built with the correct precedence:2.
backend/open_webui/main.py:1738-1791— butmodel_info_paramsis then ONLY consulted for four keys:stream_response,stream_delta_chunk_size,reasoning_tags,function_calling. Provider sampling params (max_tokens,temperature,top_p, etc.) are never read off the merged dict; the merged dict is dropped after this block.3.
backend/open_webui/routers/openai.py:1115— the outbound payload builder readsmodel_info.paramsdirectly (NOT the merged dict from step 1):So the global default fallback computed in
main.pynever reaches the OpenAI payload builder.4.
backend/open_webui/routers/ollama.py—params = model_info.params.model_dump()appears at lines 1123, 1216, 1279 with the same shape. The Ollama path almost certainly has the same bug. (Not verified end-to-end against a live Ollama instance, but the source pattern is identical.)5.
backend/open_webui/utils/payload.py::apply_model_params_to_body_openaiconfirms there's no internal fallback to a global default either — it just copies the provided dict's keys into form_data, falling back to Open WebUI's own hardcoded defaults (e.g.max_tokens: 2048) when a key is absent.Browser console logs and Docker container logs are not informative for this bug — it's a server-side payload-construction bug, evidenced entirely by inspecting the outbound request body sent to the upstream provider.
Additional Information
Proposed fix: change
routers/openai.py:1115(and the three analogous sites inrouters/ollama.py) to consume the mergedmodel_info_paramsalready computed inmain.pyrather than re-deriving from rawmodel_info.params. Either:payload['metadata'](already used to pass other per-request context) and use it in the router; orrequest.app.state.config.DEFAULT_MODEL_PARAMSbefore the call toapply_model_params_to_body_openaiand merging it underneath the per-model dict; orapply_model_params_to_body_openaiaccept adefault_params: dict | Noneargument and apply it as a base layer before the per-model overrides.Whichever shape is preferred, the contract should be that
DEFAULT_MODEL_PARAMSis a true base layer for every provider sampling param, not just the four Open WebUI-internal flags currently consulted inmain.py. That matches what the admin UI implies and what users reasonably expect from a "Default Parameters" form. Happy to send a PR if a maintainer can confirm a preferred shape.@owui-terminator[bot] commented on GitHub (May 20, 2026):
🔍 Related Issues Found
I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:
🟣 #19214 issue: default model params take precedence over user-specified model params
This is closely related because it concerns the same
DEFAULT_MODEL_PARAMS/admin default parameter path and the same precedence/merge logic around model parameters. The exact symptom differs, but it shows that default model params are involved in request construction and payload precedence bugs.by Simon-Stone ·
bug🟣 #18618 issue: Root-level max_tokens dropped instead of converted to num_predict (Regression from Feb 2025)
This issue is about
max_tokensbeing dropped during backend payload conversion, which is very similar to the reported silent dropping of global default sampling params likemax_tokens. It also covers the same general request-building path where token-limit parameters are lost before reaching the provider.by elazar ·
bug🟣 #22524 issue: Newer OpenAI model max_tokens parameter bug
This is another
max_tokens-related OpenAI backend bug where the parameter is mishandled in outbound requests. While the root cause is different, it is relevant because it shows the OpenAI request path has recent regressions around token-limit parameter handling.by Art-1313 ·
bug🟣 #22557 issue: User configured "Advanced Paramters" for Ollama models are sent to Open AI models
This issue is about model parameters leaking across provider paths and being sent in the wrong outbound payload. It is not the same bug, but it is related to the same code area where Open WebUI builds and forwards request parameters to OpenAI-compatible providers.
by derek-assurity ·
bug💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.
This comment was generated automatically. React with 👍 if helpful, 👎 if not.