LibreChat/client
Danny Avila 50324a0baa
🔐 fix: Skip Reasoning Labels for Encrypted Reasoning (#17100)
* 🔐 fix: Skip Reasoning Labels for Encrypted Reasoning

OpenAI models on Bedrock (and Claude's redacted thinking on Bedrock) return
reasoning as encrypted `redactedContent` bytes. The current agents SDK
base64-encodes those bytes into the reasoning stream, so they arrive as THINK
text: the reasoning-label wiring summarized the blob ("Inspecting an encoded
data snapshot"), activity and phase labels quoted it as reasoning evidence, and
the UI rendered it as thinking.

Add a shared `stripOpaqueReasoning` / `isOpaqueReasoning` predicate in
data-provider that recognizes long unbroken base64/base64url runs (Bedrock
redactedContent, Anthropic redacted_thinking data, OpenAI encrypted_content,
Gemini thought signatures) and keep them out of every label path:

- reasoning labels drop encoded deltas, ignore persisted payloads on resume,
  and re-check the accumulated text before a billed label call
- activity-label and phase-summary evidence carries readable excerpts only;
  phase anchoring still uses the raw excerpt
- the THINK renderer, grouped reasoning rows and the live header show a
  neutral "Reasoning (encrypted)" marker instead of the payload, and ignore
  labels previously generated from it

Readable reasoning on every provider, including readable text mixed with an
encoded payload in the same step, is still labeled.

* fix: Classify streamed and persisted payloads by readable content

- isOpaqueReasoning / stripOpaqueReasoning ignore the persisted `<think>`
  wrapper, so stored encrypted reasoning renders as the encrypted marker and
  never reaches label evidence as tags-only "text"
- add advanceOpaqueReasoning, a streaming cursor that holds a trailing
  payload-alphabet run until it settles as a word or grows into a payload,
  so a payload split across sub-threshold deltas is dropped as it streams
- reasoning labels count only settled readable characters plus a word-sized
  pending tail, so ciphertext fragments never advance the minChars or
  updateChars gates or trigger extra billed label calls

* fix: Show readable reasoning around payloads and settle words before counting

- the reasoning disclosures, grouped rows, live header and conversation
  export render and copy the readable text of a THINK part with encoded
  payloads removed; the encrypted marker stays for parts with nothing readable
- reasoning labels count and send only settled readable text: an undecided
  trailing run never advances minChars/updateChars or reaches the prompt,
  whatever the configured thresholds, and a short final word settles when the
  step closes

* fix: Classify reasoning before every bound and across resume

- once a run is classified as a payload, it continues through the next
  non-payload character even when that arrives in the same delta as readable
  text, so no tail fragment of the payload is released as readable
- add sliceReasoningTail: the activity-phase rolling reasoning window (and its
  snapshot/restore bounds) never starts inside an unbroken run, so a payload cut
  by the window cannot leave a fragment too short to classify; the window stays
  a substring of the raw THINK text, so phase anchoring is unchanged
- a resumed reasoning step replays its persisted text through the stream
  filter and keeps the resulting cursor, so a payload prefix that was still
  undecided at the snapshot is dropped once the continuation classifies it

* fix: Classify phase evidence while it streams and mask payloads while pending

- activity phases classify each reasoning delta with the stream cursor and keep
  a readable rolling window beside the raw anchor window; tracked activities
  carry readableExcerpts as prompt evidence, so a window cut into a payload can
  never forward a fragment (older snapshots fall back to stripping); the
  cursor-free sliceReasoningTail is removed
- add readableReasoning / flushOpaqueReasoning: while reasoning streams, the
  disclosures and live header hold back a trailing run that could still grow
  into a payload instead of showing its first characters
- the message editor offers no field for payload-only reasoning and shows only
  the readable text of mixed reasoning; an unchanged part is never written, so
  its stored payload stays intact

* fix: Replay legacy phase snapshots through the reasoning stream filter

A pending-reasoning lane restored from a snapshot without a readable window
or cursor is replayed through advanceOpaqueReasoning instead of stripped, so a
payload prefix that was still undecided at the snapshot stays in the cursor
and is dropped once the continuation classifies it.

* fix: Drop the cut leading run of a full legacy phase window

A legacy pending-reasoning window that filled the 600-char bound may have been
cut inside a payload, so its leading payload-alphabet run is dropped before the
replay; a shorter window is the whole lane and is replayed as is.

* fix: Keep payload-bearing reasoning read-only and drop payload-derived titles on resume

- reasoning that carries an encoded payload is not offered in the message
  editor: the edit endpoint replaces the whole value and the payload cannot be
  positioned in an edited draft, so editing would silently delete it
- a resumed reasoning step whose persisted text has no readable reasoning
  drops its existing title (which could only describe the payload) instead of
  carrying it forward where a short readable continuation would revive it

* fix: Reset a resumed payload-derived title on the client, only for payload-only steps

- a resumed step drops its title only when its persisted reasoning is entirely
  an encoded payload, so a short readable token (still undecided for the
  stream cursor) keeps a valid title
- dropping it emits a same-step on_reasoning_label reset, which the client
  already applies, so a resumed client clears the snapshot title too
2026-10-16 06:58:09 -04:00
..
public
src 🔐 fix: Skip Reasoning Labels for Encrypted Reasoning (#17100) 2026-10-16 06:58:09 -04:00
sw
test 🧹 refactor: Remove Dead Client Hooks, Store Modules and Utilities (#17111) 2026-10-15 12:22:13 +02:00
babel.config.cjs
check_updates.sh
index.html 🎨 feat: Paint the Operator Theme on a First-Ever Visit (#16962) 2026-10-14 13:16:44 +02:00
jest.config.cjs 🚰 refactor: Move the Pure Stream Code into the @librechat/chat Core (#16979) 2026-10-11 23:04:47 +02:00
jest.resolver.cjs
nginx.conf
package.json 🧹 refactor: Remove Dead Client Hooks, Store Modules and Utilities (#17111) 2026-10-15 12:22:13 +02:00
postcss.config.cjs
tailwind.config.cjs 📦 feat: Scaffold the @librechat/chat Package (#16964) 2026-10-10 21:00:10 +02:00
tsconfig.json 🥟 ci: Type-Check Workspaces with bun check (#17009) 2026-10-12 06:40:07 -04:00
vite.config.ts 🎨 feat: Paint the Operator Theme on a First-Ever Visit (#16962) 2026-10-14 13:16:44 +02:00