open-webui/backend/open_webui/utils
Classic298 d8ceb45baa fix: stop replaying encrypted reasoning_details to a different model after a mid-chat model switch
Switching models mid-chat after a reasoning model responded breaks the chat permanently: stored reasoning_details of type reasoning.encrypted (or carrying a signature) are cryptographically bound to the model that produced them, and the new model's provider rejects every subsequent request, including retries and forks.

Each assistant message already records which model produced it. On request build, when that model differs from the current target, the bound entries are now dropped from its reasoning_details while plain text and summary entries are kept, so the new model still sees what the previous one was thinking. Same-model requests are untouched, since Anthropic-family models require their signed reasoning blocks back and replaying reasoning saves tokens.

The filter sits in process_messages_with_output, the single point every outbound message list passes through, so persisted chats, continue-generation and temporary chats are all covered. Filtering at request time rather than stripping at save keeps the stored data intact: switching back to the original model replays its reasoning again. Messages saved before this change have no model recorded and are left as-is.

Fixes #28240
2026-08-07 12:57:10 +02:00
..
access_control refac: share one folder write-access check across chat folder_id paths (#28366) 2026-08-10 19:17:18 -06:00
images perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
mcp refac 2026-06-29 11:56:00 -05:00
telemetry refac(telemetry): drop deprecated semconv SpanAttributes subclass (#25784) 2026-06-29 02:05:34 -05:00
actions.py fix: enforce action availability and model access on the chat action route (#27243) 2026-07-23 12:23:05 -04:00
anthropic.py refac 2026-07-31 17:41:14 -04:00
asgi_middleware.py fix: report sub-second timings in the X-Process-Time header (#27368) 2026-07-23 18:09:23 -05:00
audit.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
auth.py refac 2026-08-10 22:36:42 -06:00
automations.py refac 2026-08-05 10:37:38 -05:00
calendar.py refac 2026-07-31 17:30:47 -04:00
channels.py refac 2026-03-17 17:58:01 -05:00
chat.py perf: build info log messages lazily so raising the log level actually saves work (#27837) 2026-08-02 15:39:10 -05:00
chat_fork.py refac 2026-07-23 02:54:56 -04:00
chat_id.py refac 2026-07-26 21:12:14 -04:00
chat_variables.py refac 2026-07-31 17:41:14 -04:00
code_interpreter.py refac 2026-07-31 17:41:14 -04:00
context_compaction.py refac 2026-08-11 01:15:05 -06:00
embeddings.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
files.py refac 2026-07-23 21:29:33 -04:00
filter.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
groups.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
headers.py chore: format 2026-07-27 00:12:47 -04:00
json_codec.py perf: take the orjson fast path for ensure_ascii=False callers (#27841) 2026-07-31 20:39:10 -05:00
json_response.py perf: optional orjson JSON codec behind ENABLE_ORJSON (#27583) 2026-07-27 03:45:37 -04:00
logger.py perf: stop formatting every exported log record twice under OTEL log export (#27840) 2026-08-10 23:13:52 -06:00
memory.py refac 2026-08-10 19:28:21 -06:00
middleware.py fix: stop replaying encrypted reasoning_details to a different model after a mid-chat model switch 2026-08-07 12:57:10 +02:00
misc.py refactor: walk chat message history by map key (#28034) 2026-08-10 23:24:41 -06:00
model_ids.py refac 2026-07-26 23:09:22 -04:00
models.py refac 2026-08-10 20:30:56 -06:00
notifications.py refac 2026-07-27 19:39:36 -04:00
oauth.py refac 2026-08-10 23:13:10 -06:00
payload.py refac 2026-08-11 01:17:19 -06:00
pdf_generator.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
plugin.py perf: build info log messages lazily so raising the log level actually saves work (#27837) 2026-08-02 15:39:10 -05:00
rate_limit.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
redis.py fix: Set default Redis socket timeout to None (#27104) 2026-07-27 00:30:00 -04:00
response.py refac 2026-07-31 17:41:14 -04:00
sanitize.py refac 2026-03-17 17:58:01 -05:00
security_headers.py perf: stop recomputing static work in per-response ASGI middlewares (#27229) 2026-07-23 12:29:01 -04:00
session_pool.py refac 2026-07-27 04:17:00 -04:00
subagents.py refac 2026-08-10 20:13:03 -06:00
task.py refac 2026-06-19 00:16:06 +02:00
terminals.py refac 2026-08-08 15:47:10 -06:00
timers.py refac 2026-07-31 17:41:14 -04:00
tools.py refac 2026-08-10 19:44:56 -06:00
validate.py refac 2026-07-27 19:39:36 -04:00
valves.py refac 2026-07-31 17:41:14 -04:00
webhook.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00