Commit graph

2723 commits

Author SHA1 Message Date
lia-by-librechat[bot]
f03a4686ff
🚋 fix: Scope Document Name Traversal to Bedrock Agents (#17627)
* 🚋 fix: Scope Document Name Traversal to Bedrock Agents

* test: Preserve Replay Content Across Token Cache Refreshes

* fix: Include All Bedrock Replay Recipients in Document Naming

* fix: Include Lazy Provider Metadata in Document Naming

* perf: Short-Circuit Reachable Agent Predicates

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-30 13:53:36 +01:00
Marco Beretta
2ad2c1c14b
🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466)
* perf: Serve JWT Bearer User Lookups From the Auth User Cache

* perf: Batch Agent Permission Reads on the File Access Path

* perf: Remember a Loaded Google Service Key Across Endpoint Config Reads

* perf: Run Independent Startup, Tool, Skill and Erasure Reads Concurrently

* fix: Drop JWT User Cache Writes That Race a User Mutation

Confirm each cache write with a second read and evict when the user changed,
so an in-flight lookup cannot repopulate an entry a credential change just
evicted. The cache mode now arrives through the loader dependencies.

* refactor: Move Agent Skill Access Reads Into packages/api

The chat-completions and Responses controllers call loadSkillAccess instead of
orchestrating the three reads in CJS. The preview route spec mocks the batched
file access helper the middleware now calls.

* test: Cover Agent File Access, JWT Bursts and Remote Skill Reads End to End

* fix: Serve a Cached JWT User Only While Its updatedAt Is Current

A cache hit now reads the stored updatedAt and deletion fence instead of the
fence alone, so a document cached from a read that raced a user mutation is
never served, even when the write landed after that mutation's eviction.

* refactor: Move Startup Migration Checks Into packages/api

* refactor: Inject the Startup Migration Checks Instead of Mongoose Models

* fix: Serve Cached OpenID Users Only While Their updatedAt Is Current

Moves the freshness check into getCurrentCachedAuthUserDoc and uses it on the
OpenID bearer path as well as the local JWT one, so a document cached from a
read that raced a credential or role change is never served there either.

Fixes berry-13/LibreChat#432

* fix: Compare Authorization Fields on Every Auth Cache Hit

updatedAt has millisecond resolution, so the freshness read also compares the
token retirement stamps, role, tenant and two-factor state.

* fix: Annotate the Auth Freshness Projection for Isolated Declarations

* perf: Reuse the OpenID Cache Freshness Read for Deletion Admission

A cache hit already proved the deletion fence is clear, so only users read from
the database take the separate fence query.

* refactor: Keep the OpenID Cache Freshness and Fence Decisions in packages/api

* test: Exercise JWT Cache Freshness Against Real User Methods in MongoDB

* fix: Stamp the JWT User Lookup So the Cache Write Fence Applies

* fix: Reload a Google Service Key File When It Changes or Disappears

The availability check remembers a loaded key only while the file's mtime and
size are unchanged, and fetches URL sources every time as before.

* fix: Recheck a Service Key File After a Permission Change
2026-10-30 00:24:08 +01:00
lia-by-librechat[bot]
b3f71196f3
🔚 fix: Bound Abandoned File Deletion Retries (#17640)
* fix: Bound abandoned file deletion retries

* fix: Handle absent request user in code cleanup

* fix: Preserve deferred cleanup wakeups and configured budgets

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-29 23:48:40 +01:00
lia-by-librechat[bot]
3d3edaff01
🐘 fix: Preserve Authored Skills Across Approval Resumes (#17630)
* fix: preserve authored skills across approval resumes

* fix: complete authored skill resume contracts

* fix: keep restored skill identity authoritative across batches

* fix: reject replacement skills during authored recovery

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-29 22:17:03 +01:00
lia-by-librechat[bot]
99fb03cb93
🚤 fix: Keep Host Tool Loading Independent of Worker Status (#17628)
* 🚤 fix: Keep Host Tool Loading Independent of Worker Status

* fix: Classify Workspace Tools at the Agent Boundary

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-29 22:13:10 +01:00
Marco Beretta
7f597b4787
🧊 fix: Fence Auth User Cache Writes After Eviction and Evict Favorite Holders (#17505)
Some checks are pending
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
* fix: Fence Auth User Cache Writes After Eviction and Evict Favorite Holders

An eviction now leaves a per-user fence in the auth user cache that outlives
every document read before it. The reader skips a cached document while its
user is fenced, and a lookup slower than one cache TTL is not cached, so a
request that read the user before a change can no longer repopulate the cache
afterwards, and a document the reverse index lost is hidden as well. Role and
user methods share one bulk eviction helper, and the terms reset only waits
out the TTL when an eviction failed.

Deleting an agent, deleting a user's agents and removing an agent from
favorites now evict the cached auth documents of the users whose favorites
changed.

* fix: Anchor Cached Auth Document Expiry to the Lookup Start

A stalled reverse-index write could land a stale document after the eviction
fence expired, with a fresh TTL. The document now carries an expiry two cache
TTLs after its lookup began; its Redis TTL is computed after the index write
and the reader refuses it past that expiry.

* refactor: Time the Auth User Lookup in the API Package

The lookup start that anchors a cached document's lifetime is now stamped by
timeAuthUserLookup in packages/api, so the OpenID JWT strategy only wires the
lookup through it.

* fix: Wait Out the Full Cached Document Lifetime After Failed Eviction

A document read just before a change can live two cache TTLs from its lookup,
so a credential change or terms reset whose eviction failed now waits that
long before reporting success.

* fix: Recheck Cached Auth Document Expiry After the Fence Read

A fence read that stalls can return after both the fence and the document
expired, so the reader checks the document's expiry again before serving it.
2026-10-29 17:44:51 +01:00
Marco Beretta
5b8bb3c31f
⏱️ fix: Bound Remaining Outbound Calls With Timeout Budgets (#17468)
* fix: Bound outbound HTTP calls that had no timeout

Add timeouts.toolsMs, speechMs and imageGenerationMs to the timeouts block and apply the
existing budgets to the RAG delete paths, built-in tool APIs, TTS/STT providers (TTS also
aborts when the client closes), Stable Diffusion, Firebase reads and Mailgun. Calls made
before app config exists (remote config, RAG health, service key URL, Google refresh) get a
fixed 10 second budget.

* fix: Honor configured budgets for RAG deletes and per-chunk TTS deadlines

* refactor: Share one budget helper between speech and image CJS callers

* test: Cover a stalled RAG delete with a mock scenario

* test: Wait for the RAG embed before stalling the delete

* test: Embed at upload so the stalled delete has a vector to remove

* fix: Close a started TTS response on a late chunk timeout and share the service budget helper

* fix: Fail startup when the remote config fetch times out
2026-10-29 09:55:18 +01:00
Marco Beretta
749c1a3943
📌 fix: Keep the Composer Thinking Level for the Rest of the Conversation (#17497)
* fix: Label Composer Thinking Levels and State the One-Shot Scope

* test: Cover Composer Thinking Labels and One-Shot Scope in E2E

* test: Cover Thinking Focus for Option Lists Without Auto

* test: Wait for the Thinking Popover's Open Focus Before Arrow Keys

* test: Match the High Effort Radio Exactly

* fix: Keep the Composer Thinking Level for the Rest of the Conversation

* fix: Keep a Queued Turn's Picked Level on the Turns Queued After It

* test: Name the Numeric Reasoning Control by Its Thinking Label

* fix: Name the Queued Turn's Level on the Thinking Button

* test: Dismiss the Thinking Tooltip Before Typing on a Phone

* fix: Respect Enforced Specs and Parameters Edits Over the Inherited Thinking Level

* test: Expect the Model Spec Enforcement Flag in Chat Settings

* fix: Keep a Queued Turn Off a Level Its Target No Longer Runs

* fix: Record the Target a Queued Turn's Level Belongs To

* refactor: Inherit the Thinking Level on the Server

* perf: Answer the Branch Level Lookup Without Tree Links When Nothing Was Picked

* fix: Respect the Thinking Switch and Held Queue Rows Over the Inherited Level

* fix: Read the Branch Level Once and Inherit Only on Fresh Turns

* fix: Keep a Parameters Thinking Edit From Turning Thinking On

* fix: Withdraw a Staged Thinking Level When Thinking Is Switched Off

* fix: Scope the Thinking Switch Transition to the Conversation

* test: Drop the One-Shot Thinking Scenario the Conversation Level Replaces
2026-10-28 19:11:07 +01:00
Marco Beretta
7e7f559ea6
🏎️ perf: Parallelize Independent Agent and Schedule Lookups (#17465)
* perf: Parallelize Serial Lookups on Agent Load, Discovery, Skills, and Schedules

* fix: Address Review Findings on Parallel Lookups

Stage same-level discovery results before collecting edges so a shared sibling is initialized once, bound resume snapshot fetches to small chunks so over-budget graphs stop early, and surface the first ordered image failure without waiting on later reads. Update the skill name test for bounded concurrency.

* test: Tag Existing Mock Specs as Acceptance Scenarios for Parallel Lookups

* feat: Make Parallel Lookup Bounds Configurable

Add a concurrency section to librechat.yaml for MCP catalog, skill name, skill file and resume agent lookups. Defaults equal the previous hard-coded values.

* style: Sort Imports for Configurable Lookup Bounds

* test: Match Model Spec Skill Resolution Args With App Config

* test: Close the Builder Drawer Before Chatting on Narrow Viewports

* fix: Surface Fatal Discovery Errors Without Awaiting Later Siblings

* fix: Reject Discovery on the First Fatal Load Regardless of Queue Order

* fix: Keep Image Encoding Fail-Fast With Parallel Reads

* fix: Reject Resume Snapshot Lookups Without Waiting on the Whole Chunk

* feat: Make Connected Agent Discovery Concurrency Configurable
2026-10-28 18:59:16 +01:00
Danny Avila
64f2124cc6
🔐 fix: Keep the Admin OpenID State So PKCE Holds When the IdP Omits S256 (#17478)
openid-client's Passport Strategy replaces the authorization request's state with a random one
when the IdP's discovery metadata does not list S256 in code_challenge_methods_supported and the
request has no nonce. Azure Entra ID omits that field, so the admin callback could not find the
admin panel's PKCE challenge under pkce:<state> and issued an exchange code that any
code_verifier, or none, could redeem.

The admin strategy now adds a nonce in that case, so openid-client keeps the admin route's state
and checks the nonce against the ID token on the callback. The chat OpenID flow is unchanged.
2026-10-28 18:33:12 +01:00
Marco Beretta
0bcb0aaec1
🛟 fix: Promote Reconciled Compaction Snapshots to the Terminal Row (#16553)
* fix: Keep the Snapshot When the Terminal Write Settled for Reconciliation

* fix: Promote a Reconciled Compaction Snapshot to the Terminal Row

* fix: Anchor and Envelope the Reconciled Snapshot by Its Claim

* test: Cover the Abandoned Compaction Settling After Its Run in E2E

* fix: Withhold the Disconnect Snapshot of Any Durably Settled Turn

* fix: Promote Only a Same-Epoch Reconciled Snapshot and Settle Stopped Compactions

* fix: Plan the Disconnect Snapshot in packages/api and Check the Response Row Before Promoting

* fix: Read the Disconnect Snapshot Rows in the Response Conversation

* fix: Check the Anchor-Derived Error Row Before Promoting a Reconciled Snapshot

* fix: Log a Failed Disconnect Snapshot Plan Instead of Rejecting the Listener

* fix: Let a Reconciled Compaction Promote After an Earlier Live Snapshot

* refactor: Decide the Repeat Disconnect Write in the Snapshot Plan

* refactor: Report Failed Snapshot Row Reads Through the Plan

* fix: Stamp a Promoted Disconnect Snapshot and Read Its Rows Together

* fix: Derive the Compaction Error Row ID Through the Shared Helper

* fix: Plan a Saved Live Compaction Snapshot Again Once Its Turn Settles

* refactor: Queue Disconnect Snapshots and Settle Them in packages/api

* fix: Never Count the Compaction Anchor as Its Own Terminal Row

* fix: Settle Disconnect Snapshots Before Terminal Cleanup Releases the Turn
2026-10-28 11:13:50 +01:00
Marco Beretta
c81e244afd
🗂️ perf: Index Hot Lookups and Fix the Message Cursor (#17464)
Some checks are pending
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
* perf: Index Hot Lookups and Make Message Cursor Pagination Stable

Add narrow indexes for session refresh-token deletes, user-only tool call deletes, queued-turn delivery and reconciliation claims, agent code environment references, and updatedAt message pages. Add a TTL index to the KeyvMongo collection. getMessagesByCursor now sorts and pages on a unique (sortField, _id) tiebreaker with a millisecond-precise cursor while still accepting legacy cursors, and GET /api/messages caps pageSize in a TypeScript helper.

* fix: Keep the Message Id for the Cursor Under the Client Projection

* fix: Declare select on the Message Cursor Method Type

* feat: Make the Message Page Size Ceiling Configurable

* fix: Clamp the Default Message Page Size to the Configured Ceiling

* test: Cover Message Cursor Paging and Page Size Cap End to End

* fix: Continue Message Cursors Whose Sort Value Is Empty

* fix: Include Missing Sort Values When Paging Messages Descending

* perf: Resolve the Message Page Ceiling Beside the Ownership Read

* fix: Observe the Ownership Read While the Page Size Resolves

* style: Sort Imports in the Message Page Module

* refactor: Move Page Size Read Observation Into the API Package

* fix: Keep Missing and Empty Sort Values Distinct in the Message Cursor

* fix: Page Past Messages With a Missing Timestamp
2026-10-28 00:55:02 +01:00
Marco Beretta
65d0ba8563
🧯 fix: Return Approved Tool and Generation Error Text Instead of Raw Exceptions (#17508)
* fix: Return approved tool and generation error text instead of raw exceptions

* fix: Redact generation error text without the data-schemas helper

* fix: Redact credentials and emails from shown generation errors

* refactor: Move the Wolfram status policy into packages/api

* test: Fix the Wolfram probe constructor and jest summary match

* test: Match the jest pass count through color codes

* fix: Redact credentials a tool input error echoes from its arguments

* fix: Drop free-text fields from typed generation errors under a content policy

* fix: Keep only the code and numeric fields of typed errors under a content policy
2026-10-28 00:39:01 +01:00
Marco Beretta
a0f063b1c7
🔐 fix: Fence ACL Viewers and Surface Revocation Failures When Removing Shared MCP Servers (#17506)
* fix: Fence ACL Viewers and Surface Revocation Failures When Removing Shared MCP Servers

Account erasure and server deletion now enumerate users the view ACL names
directly or through a group, so viewers without a personal OAuth token are
fenced and disconnected too. Erasure runs the OAuth teardown in strict mode,
which clears local credentials and then fails when the provider refuses a
revocation, keeping the server as the retry anchor, and holds every user's
teardown fence until the server delete commits.

* test: Type the Revocation Failure Cleanup Fixtures

* fix: Renew Retained OAuth Teardown Fences Before Deleting the Server

A teardown lease lasts 15 minutes, so a large erasure could outlive the
first fences it holds. Leases can now be renewed by their owner, and
erasure renews every retained fence right before the delete, failing
without deleting when one lapsed and another writer took it.

* fix: Report Refused MCP Revocations Without Blocking Account Erasure

A provider that refuses revocation, combined with a viewer who signs in
again between attempts, could keep an erasure failing indefinitely. The
strict teardown now throws a coded MCPOAuthRevocationError after clearing
local state and handing over its fence; server removal collects those as
refusals, logs each user and token type whose grant may remain valid, and
proceeds. Local failures (token delete, fence, ACL) still fail closed.

* fix: Annotate the Revocation Error Code for Isolated Declarations
2026-10-28 00:37:07 +01:00
Marco Beretta
7d0e79786f
🪶 fix: Time Out Client Refresh and Trim Lodash Imports (#17467)
* perf: Bound client hygiene paths (lodash imports, timeouts, listener cleanup, upload concurrency)

* feat: Make client request timeouts configurable

* test: Cover the configured refresh deadline end to end

* feat: Rename client timeouts to client limits and expose upload concurrency

* fix: Keep the published refresh deadline for the next page load
2026-10-27 23:30:08 +01:00
Marco Beretta
784582850a
🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462)
* fix: Harden Timer Sweeps, SSE Writes, and Violation Counters

Guard SSE writes against ended or destroyed responses through one helper, catch and single-flight the job store and TTL cache cleanup timers, serialize in-process counter updates, cap the violation log, prune stale OAuth failure records, batch the active-job lookup, and count Redis keys with DBSIZE.

* refactor: Drop the redundant violation log entry copy

* refactor: Log single-flight sweep failures from the API package

* test: Cover active generation listing and client disconnect mid-stream

* refactor: Configure violation log retention and move title timeout into the API package

* feat: Configure OAuth failure retention through mcpSettings

* fix: Prune OAuth failures promptly under short retention
2026-10-27 23:06:58 +01:00
lia-by-librechat[bot]
761bfa8e6a
🪠 fix: Erase Vectors in Their Recorded Namespaces (#17457)
* fix: Delete vectors in every recorded namespace

* test: Assert vector cleanup precedes Azure deletion

* fix: Preserve implicit RAG scope during vector erasure

* fix: Keep failed-upload storage cleanup independent

* test: Correct rollback fixture types and lint

* fix: Require complete embedding ownership before erasure

* test: Mark confirmed Project erasure fixture complete

* fix: Stage vector ownership trust and bound erasure fanout

* fix: Mint RAG credentials when queued requests dispatch

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-26 22:26:11 +01:00
lia-by-librechat[bot]
8e68cab31b
🤺 fix: Prefix MCP Tool Cache Write Fences (#17458)
Some checks are pending
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
* fix: Prefix MCP tool-cache ownership fences

* test: Keep fence-prefix regressions lint clean

* fix: Preserve fence slots for literal Redis prefix braces

* fix: Bridge MCP ownership fences across rolling upgrades

* fix: Isolate deployment ownership in the legacy fence bridge

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-26 17:56:35 +01:00
lia-by-librechat[bot]
0f868baf26
🍘 fix: Separate Runtime Context From User Input (#17454)
* fix(agents): skip the empty-memory notice for agents that cannot use memory

Since #16301 formatMemoryContext('') returns the bare memory instructions sentence, and
prepareRuntimeAgent applied it to the primary agent whenever the user had no saved memories.
An agent with no memory tools and no automatic memory extraction can neither read nor write
memory, so the sentence told the model nothing it could act on, yet it reached the model as
per-turn context. The empty-store notice is now added only when the agent has memory tools or
automatic extraction is on. Saved memories are still injected as before.

* fix(agents): distinguish relocated context from user input

* fix(agents): narrow runtime context types

---------

Co-authored-by: shars <32410570+Shabonasar@users.noreply.github.com>
Co-authored-by: Lia <lia@librechat.ai>
2026-10-26 15:51:16 +01:00
Danny Avila
aa8e5849e0
⬆️ feat: Migrate to Zod v4 (#17442)
* ⬆️ feat: Migrate to Zod v4 (GHSA-mrhx-c7xc-m3w5), openai 6.49, zod-openapi 6

* 🔒 chore: Regenerate bun.lock

* 🐛 fix: Keep omitted fields absent under Zod 4 partial/optional defaults

* fix: Preserve Config Record-Key Diagnostics After Zod 4 Migration

* fix: Require Agents SDK 4.1.1 for Zod 4 Accounting

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-26 14:16:22 +01:00
lia-by-librechat[bot]
e594cff874
🏨 fix: Restore Strict Tenant Startup and Sign-In (#17441)
Some checks are pending
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
* fix: restore strict tenant startup and sign-in

* test: preserve real middleware in auth route fixtures

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-26 01:08:30 +01:00
Danny Avila
080e5f500c
🏘️ fix: Resolve Tenant Profiles in Their Own Partition and Keep Role Operations in the Caller's (#17417)
Some checks failed
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Vote Gate / Gate (push) Waiting to run
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Has been cancelled
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been cancelled
- GET /resolved resolves a group or user profile in the partition its document belongs to, as
  writes judge it: for an admin without a tenant reading a tenant's profile, that tenant's
  librechat.yaml and __base__. GET /catalog resolves such a scope there too, instead of
  answering 404, and GET /effective finds a user by id the way profiles are addressed and
  resolves them in their own tenant: their role, groups and documents there.
- findPartitionUser becomes findPrincipalUser, which also returns the user's tenant.
- Admin role operations address the role of the caller's tenant partition: the role lookup
  (getPartitionRole), listing, creation's name check, the members a rename migrates or a deletion
  reassigns, the members listed and counted, and the ACL entries (deletePrincipalAclEntries) and
  grants a deletion removes. A member added or removed by id must be a user of that partition.
- getRoleByName, which every request's permission checks read, reads the role of the caller's
  partition too: outside a tenant and under the system context the platform-level one, never an
  older tenant role of the same name. updateRoleByName without an id and updateAccessPermissions
  for a role read without its _id write that role, so the legacy permission route changes the
  platform role. The grants route checks a role exists with getPartitionRole.
- runInPartition moves a read into another partition only from outside a tenant, and rejects
  leaving an active one.
- deleteGrantsForPrincipal and findGrantsForPrincipal without a tenantId reach only
  platform-level grants, as moveGrantsToPrincipal does.
- updateRoleByName takes { id } to change one role document; renames, their rollback,
  description updates and updateAccessPermissions write the document they read.
- The exported keyed rename helpers (applyConfigChange rename, renameConfigEntryTombstones)
  refuse a new name no keyed path can address, as the admin routes do.
2026-10-24 18:33:12 +02:00
Danny Avila
4cb359682a
🏤 chore: Upgrade API and Test Dependencies, Refresh Bun Lockfile (#17414)
* chore: Update package dependencies across multiple modules

- Upgraded `@azure/identity` to version 4.14.0 in package.json files.
- Updated `multer` to version 2.5.0 and `nodemailer` to version 10.2.1.
- Incremented `undici` to version 7.30.1.
- Updated `@happy-dom/jest-environment` to version 21.0.4.
- Incremented `qs` to version 6.16.1 and `fast-uri` to version 3.1.9.
- Updated `serialize-javascript` to version 7.1.4.
- Updated `zod` to version 4.6.7 in multiple modules.

These updates ensure compatibility with the latest features and security improvements.

* chore: update bun.lock file
2026-10-24 15:30:39 +02:00
Atef Bellaaj
a2cd772d49
🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272)
PromptService gains importSourceGroup, which finds or creates a source
pointer group, grants the PUBLIC viewer role and rolls the group back if
the grant fails. The Langfuse catalog sync calls it instead of four
storage callbacks and two Mongo error predicates, and the prompt service
is composed once in api/server/services/Prompts.js and passed to the
prompt routes, linked instructions, instructions prompt access and the
Langfuse sync runner.

Co-authored-by: Rebase Probe <probe@example.com>
2026-10-24 13:51:31 +02:00
Atef Bellaaj
6e397c33a2
🎴 feat: Use Langfuse Prompts from Cards and the Slash Command (#17104) 2026-10-24 13:51:01 +02:00
Atef Bellaaj
d481b6b695
🏬 feat: Sync Langfuse Prompts into the Catalog (#17095)
* feat(prompts): sync Langfuse prompts into the catalog

* refactor(prompts): compose the Langfuse prompt sync runner outside the admin handler

Add createLangfusePromptSyncRunner, which binds the lock, the prompt-group
methods, the ACL grant and the Mongo error predicates once and returns a
runner that takes the per-request source, connection-bound listPrompts,
lock lease and page cap. The admin handler receives that runner as one
dependency instead of forwarding its parts, and its config method
signatures return a LangfuseAdminConfig interface in place of Mongoose
document types.

In api, api/cache/distributedLock.js creates the one DistributedLock for
the process and api/server/services/LangfusePromptSync.js composes the
runner once with it; the admin route imports the composed runner.

* fix(prompts): report incomplete Langfuse syncs and gate the sync action

- Refresh the prompt-group and effective-permission queries after a failed
  sync too, because earlier imports can already be committed.
- Return `complete: false` when the page limit stops a sync before the last
  upstream page, and show a warning instead of the success message.
- Show the Sync prompts action only to users with `manage:prompts`, the
  capability the sync route requires. Resolve the Langfuse startup-config
  capabilities in one batched lookup.
- Document that an interrupted import can leave a group without its initial
  PUBLIC grant, and that a page in progress can outlast an expired lease.

---------

Co-authored-by: Rebase Probe <probe@example.com>
2026-10-24 13:48:52 +02:00
Atef Bellaaj
bf0b8a9031
🖐️ feat: Make External Prompt Groups Read-Only (#17008)
Reject edits, deletes, new revisions, promotion and revision deletes on
prompt groups whose source is not native with a read_only service error,
mapped to 403 "Externally managed prompts are read-only". The guard reads
the stored group, so the MANAGE_PROMPTS bypass is covered. Sharing,
usage counts and resolution are unchanged.

The client hides Edit and Delete for external groups, shows a read-only
detail view with a Langfuse notice and keeps Share.
2026-10-24 13:48:26 +02:00
Atef Bellaaj
02613ce212
⛲ feat: Resolve Native and Langfuse Prompts by Source (#16909)
The prompt service dispatches resolvePrompt by group.source. A read-only
Langfuse adapter fetches the text prompt on each use, with no cache, after
a resolver checks the deployment gate, the tenant, prompt sync, the
connection and the stored source identity. GET
/api/prompts/groups/:groupId/resolve returns resolved content for native
and Langfuse groups, with a per-user limit set by rateLimits.promptResolve
(default 60 per minute). Agent-instruction links stay native only.
2026-10-24 13:47:52 +02:00
Atef Bellaaj
bc66654a9c
🏺 feat: Track Prompt Group Source Identity (#16891)
* feat(prompts): add source identity to prompt groups

Add source, sourcePromptName, sourceProjectId and sourceDestination to
PromptGroup. productionId is required only for native groups. A unique
partial index on the source identity covers only groups that have
sourcePromptName, so native groups need no migration.

The create path drops client-supplied source fields, and the native
create upsert does not match langfuse groups. Records map a missing
source to native.

* fix(prompts): centralize sources and restrict native group matching
2026-10-24 13:47:03 +02:00
Atef Bellaaj
202756b37f
🧐 feat: Preview Langfuse Prompts in Settings (#16854)
* feat(langfuse): test prompt listing and resolution from settings

Add a dry-run dialog in Settings > Langfuse that lists Langfuse prompts
and resolves one text prompt (production label or an exact version)
through the tenant's Langfuse connection. Nothing is written. A tenant
user's prompt reads never use the central env keys, even while
TENANT_ISOLATION_STRICT is off.

DevOps makes the feature available with LANGFUSE_PROMPT_SYNC_AVAILABLE
(timeout LANGFUSE_PROMPT_SYNC_TIMEOUT_MS). The tenant admin turns it on
with langfuse.promptSync.enabled.

Related: Linear AI-2271, ClickHouse/ai#4032

* fix(langfuse): isolate prompt credentials and expose prompt settings

Use stored credentials with deployment headers for prompt reads.
Show the settings tab when connection editing or prompt sync is available.
Keep connection controls and trace links under their existing gates.
Audit prompt-sync updates and reuse shared prompt response types.
2026-10-24 13:46:40 +02:00
lia-by-librechat[bot]
5cf87548cd
🩰 fix: Keep Subagent Guidance in Main Chat Order (#17394)
* fix: Keep Applied Subagent Guidance in Main Chat Order

* fix: Preserve Pending Controls and Unmatched Legacy Guidance

* fix: Type Retained Control Read Parameters

* fix: Keep Guidance Receipts Truthful Across Delivery States

* fix: Retain Projected Steering Client Identities

* fix: Retain Ordered Guidance Across Terminal Child States

* style: Keep Public Observation Parsing Flat

* fix: Preserve Usable Legacy Activity During Reprojection

* test: Type the Legacy Recovery View Adapter

* fix: Preserve Shared Progress Identity and Public Reasoning

* fix: Forward Host Steering Through Shared Progress

* fix: Replace Tool Argument Placeholders Before Streaming

* fix: Retain Late Child Calls and Parent Steering Content

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-24 12:12:57 +02:00
Danny Avila
9f617fc4ad
🧬 feat: Re-Derive Azure Groups, Vertex AI, Custom Parameters and Spec Defaults for Config Profiles (#17399)
* 🧬 feat: Re-Derive Azure Groups, Vertex AI, Custom Parameters and Spec Defaults for Config Profiles

AppService derives part of the served config from librechat.yaml at startup, and config
profiles merged into that output without deriving it again. Azure `groups` now merge by `group`
like `endpoints.custom` by `name`: a profile's partial group merges over the group of that
name, groups it does not name stay, indexed writes are refused, change batches take entry ops
on them, and groups that do not resolve over librechat.yaml and Base (or whose written `${VAR}`
is not set) answer `invalid_azure_groups`. Each merged group keeps the key below it unless the
profile supplies one, so the rebinding guard drops a key a partial item moves and a key a lower
layer dropped stays dropped; Azure re-entry compares groups merged the same way.

With `CONFIG_REDERIVE_ENDPOINTS=true` (opt-in for this release), a profile's Azure `groups`
resolve into what the Azure clients read (unconditional before, now behind the switch so stored
group overrides do not go live on upgrade), a profile's `endpoints.anthropic.vertex` derives
`vertexConfig` and the Anthropic models it serves where librechat.yaml configures Vertex AI, and
the Azure Assistants endpoint follows a profile's `assistants`. Startup logs the documents that
hold such overrides, the groups that would not resolve over librechat.yaml and Base, and the
Vertex AI overrides that never apply. Always on: Vertex AI's key file and region are base-only,
a profile may turn Vertex AI on only where librechat.yaml configures it, its settings may
reference only librechat.yaml's own Vertex AI variables (reads return them resolved), a
profile's `vertexConfig` is never applied and writes skip it (`derived_path`,
`rules.derivedPaths`), a model's own `deploymentName` resolves its `${VAR}` like the default one,
the region, project ID and the deployment name each model's requests send (the model name where
the client sends it as written) must stay in their URL host label or path segment, a `${VAR}`
there is a whole `${NAME}` reference only, the Anthropic client refuses any other deployment name
before building a request, and an invalid setup answers `invalid_vertex_config`. The rebinding
guard no longer binds the derived Vertex AI region, which is librechat.yaml's.

Custom endpoint `customParams` are expanded by `expandCustomEndpoint` into the served copy, so
`appConfig.config` stays librechat.yaml as written, and each endpoint a profile writes is
expanded again from its merged form (a changed `defaultParamsEndpoint`, OpenRouter defaults
for a profile's own endpoint); invalid definitions answer `invalid_param_definitions`. After
tenant scoping, `getAppConfig` derives `modelSelect`, `parameters` and `presets` again for the
specs a principal is served where nothing sets them, the agents `memory` capability follows
the merged memory config, and a model spec naming an unconfigured endpoint answers
`unknown_spec_endpoint`. Meta flags: `azureGroupMergeKey`, `customParamsExpansion`,
`specInterfaceRederive` and `endpointRederive`.

* 🪜 fix: Judge Re-Derived Config on What Every Profile Layer Leaves

Two re-derivations decided whether a profile had set a field from whether any layer ever set
it, so a lower profile's value tombstoned by a higher one still counted as set.

- Vertex AI (CONFIG_REDERIVE_ENDPOINTS=true): the marker that keeps a profile's
  `endpoints.anthropic.models` over Vertex AI's is cleared by a later tombstone of those
  models (or of `endpoints.anthropic` or `endpoints`), and such a tombstone derives Vertex AI
  again, so the Anthropic endpoint serves Vertex AI's models instead of none. A tombstone of
  librechat.yaml's own models does the same.
- Spec-dependent controls: `modelSelect`, `parameters` and `presets` are derived again where
  their served value differs from the base config's, not only where the librechat.yaml-shaped
  value does, so a control one profile sets and a higher one tombstones, or a tombstone of one
  librechat.yaml leaves unset, follows the specs served instead of being dropped.

The memory capability, Azure Assistants, Azure groups and custom parameters already derive
from the merged result; tests now cover each set in one layer and tombstoned in a higher one,
and the reverse.

* 🧮 fix: Derive Each Config Part From What the Layers Leave

A tombstone of an object above a derived part's inputs, alone or followed by a layer that
recreates part of that object, left the part without what startup derives it to:

- An Azure endpoint recreated after a tombstone of `endpoints.azureOpenAI` or `endpoints` had
  no groupMap, modelGroupMap or model lists, so its model lists fell back to the environment's
  default Azure models, which requests could not map to a group. It now serves no group, with or
  without CONFIG_REDERIVE_ENDPOINTS (completeAzureResolution).
- A tombstone of the whole `interface` left modelSelect, parameters and presets out, which the
  client reads as off. They are derived from the specs served into a new interface.
- A tombstone of `endpoints.agents` or `endpoints` left no agents endpoint, while a tombstone of
  its capabilities served the defaults. The agents endpoint startup derives is served there.
- A tombstone of a Vertex AI setting that leaves the setup unable to load kept the vertexConfig
  derived below it. Vertex AI is off there, with a warning.

A table in service.spec.ts runs every derived part against every way a layer changes its inputs
(set, unset, a tombstone of the path and of each object above it, a layer recreating after such
a tombstone, Base on either side, tenant scoping, the switch off) through getAppConfig, and
compares each cell with what startup derives from the librechat.yaml the layers leave.

* 🧭 fix: Serve Only Model Specs Whose Endpoint the Layers Leave

A tombstone of `endpoints.custom` or `endpoints` in a higher profile (or the Base profile)
left the model specs of the custom endpoints it removes served, librechat.yaml's or a lower
profile's: the spec list pointed at endpoints /api/endpoints no longer offers, with the model
selector, parameters and presets still off for them. The write check only ran when the write
held `modelSpecs.list`, and the merge served stored specs as they were.

After the last layer, the merge now serves only the specs whose endpoint is a built-in endpoint
or a custom endpoint the YAML-shaped config the layers leave defines, the rule startup skips
librechat.yaml's specs by (deriveServedSpecs). A removed endpoint hides its specs until a layer
defines it again; where no spec is left, none is served (as with a tenant-hidden endpoint) and
the spec-dependent controls come back on. Tombstones of a built-in endpoint's settings keep its
specs, as startup does, and `addedEndpoints` stays as merged. A stored spec for an endpoint that
is not configured is left out on its own instead of being served; writes of one still answer
400 unknown_spec_endpoint.

The derived-part table in service.spec.ts gains the model specs served (with addedEndpoints and
the controls they decide) against tombstones of `endpoints.custom`, `endpoints`, and each of
`endpoints.openAI`, `azureOpenAI` and `anthropic`: by a profile, by Base under a profile, a lower
profile under a higher one, recreated above or by the same layer, with no spec left, and with
the switch off.

* 🧩 fix: Reconcile Re-Derived Config With Dev's Keyed Tombstones, Write Report and Read APIs

- Keyed tombstones of Azure groups (endpoints.azureOpenAI.groups["g"], now merged by key)
  resolve the groups left again where the merge resolves them, and stay inert without
  CONFIG_REDERIVE_ENDPOINTS.
- Keyed tombstones count as touching endpoints.custom, so served specs and custom parameters
  are derived again after one.
- The served-spec derivation keeps modelSpecs while added endpoints remain, as the hidden
  endpoint scoping does; hidden endpoint names leave addedEndpoints.
- Derived paths join the held paths every write skips, built on first use.
- Tests follow the merged behaviour: Azure groups merge by group, the agents endpoint is
  derived again below a tombstone.
2026-10-24 11:46:01 +02:00
lia-by-librechat[bot]
b69adddcd4
🎣 fix: Bound Attachment Preview Matching Work (#17384)
* 🎣 fix: Bound Attachment Preview Matching Work

* test: Type the Scope Iterator and Check Concurrent Requests

* fix: Keep Attachment Candidate Selection Lint-Clean

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-24 11:44:47 +02:00
Danny Avila
0716094734
🏷️ feat: Hide and Rename Custom Endpoints by Name in Config Profiles (#17396)
* 🏷️ feat: Hide and Rename Custom Endpoints by Name in Config Profiles

Config profiles merge `endpoints.custom` over librechat.yaml entry by entry on `name`, but
could not take one entry away. A tombstone that named one, such as `endpoints.custom["Name"]`,
passed every check, was stored with a 200 and did nothing, because the merge removes object
paths only and stops at arrays; a tombstone at a position (`endpoints.custom.0.headers`) was
stored and did nothing either. Renaming a profile's own endpoint through PUT or PATCH lost its
stored key, since the `renames` hint covered MCP servers only.

POST `/fields/tombstone`, DELETE `/fields` and the `tombstone` and `unset` ops of a change
batch now take a keyed path, `endpoints.custom["<name>"]` or
`endpoints.custom["<name>"].<path>`, whose name is a JSON string compared as the merge folds
it. A tombstone hides the inherited endpoint, or one of its fields or record keys, for the
profile's principals and removes the profile's own entry or path; hiding an endpoint also hides
the model specs that select it, whether librechat.yaml or a lower profile defines it. An unset
resets the profile's own entry or path with the keyed tombstones at or below it, and writing an
entry clears the tombstone that hides it whole. Malformed keyed paths, keyed paths after arrays
not merged by key, the entry's name, its key, preview or destination fingerprint, keyed writes
and positional tombstones answer 400, and the store's keyed mutations refuse a location whose
stored tombstone would name another path. A `segments` target names keys as written on every
route, so a segment such as `custom["Name"]` never reaches an entry past these guards: a write
by it stores a key of that spelling and clears none of the entry's tombstones. A stored
tombstone reads as keyed only after an array merged by key, so an older one such as
`mcpServers.a["b"]` keeps hiding that server.

PUT and PATCH `renames` also take `{ path: 'endpoints.custom', previousName, name }`: the
renamed entry gets the stored ciphertext and preview, and the keyed tombstones of the old name
move to the new one, as they do for a batch `rename`. The carried key stays bound to its
destination (400 `CONFIG_SECRET_REENTRY_REQUIRED` when the renamed entry sends it elsewhere)
and keeps the destination fingerprint it was entered with; a hint that cannot apply answers 400
`CONFIG_RENAME_INVALID` with a reason. Removing the destination of a profile's own keyed entry
beside its stored key needs the key again, and removing an inherited one drops the inherited
key at merge and lists it in `ignored`.

The merge-key registry moves to its own module so mutations can match entries by identity
without an import cycle. Meta reports `keyedTombstones` and `renameHints`,
`rules.renameHintPaths` and `limits.maxEntryKeyLength`, and `docs/endpoint-overrides.md`
documents the contract.

* 🙈 fix: Scope Hidden Endpoint Allow-Lists and Refuse Duplicate Rename Sources

- A hidden custom endpoint leaves endpoints.agents.allowedProviders as it
  leaves modelSpecs; scopeHiddenEndpointSpecs becomes
  scopeHiddenEndpointReferences.
- modelSpecs collapses only when no spec and no added endpoint remain, so
  unrelated addedEndpoints survive when the hidden endpoint owned every spec
  (tenant scoping shares the helper).
- An addedEndpoints or allowedProviders list that names only hidden endpoints
  is kept whole: an empty list allows every endpoint.
- Two endpoints.custom rename hints from one previousName answer
  CONFIG_RENAME_INVALID duplicate_source; MCP hints may still duplicate a
  server.

* 🔀 fix: Keep Keyed Tombstones Whole Across Dev's Patch Steps, Write Report and Resolved API

- PATCH resets (dev's request-ordered steps) still move a renamed entry's
  keyed tombstones, in validation and in the stored state; lifted
  tombstones come from one data-schemas helper for both paths.
- The write report of POST /fields/tombstone and DELETE /fields names a
  keyed location by its keyed path, collection, key and entryPath, as a
  change ref does, instead of the bare collection.
- resolveConfigLayers scopes the model specs and allow-lists of hidden
  endpoints as getAppConfig does, so the resolved API keeps its parity.
- GET /meta reports maxEntryKeyLength beside dev's catalogModelsTtlMs.
2026-10-24 10:44:57 +02:00
lia-by-librechat[bot]
f18b16baed
🚿 fix: Bound Chat Message IDs and Remove Backtracking (#17388)
Some checks are pending
Docker Dev Images Build / publish (push) Waiting to run
Sync Helm Chart Tags / Ignore non-main push (push) Waiting to run
Sync Helm Chart Tags / Sync chart tags (push) Waiting to run
* 🚿 fix: Bound Chat Message IDs and Remove Backtracking

* fix: Reserve the Preliminary Response ID Suffix Budget

* fix: Annotate Message ID Limit Exports for Declaration Builds

* fix: Accept Preliminary Response IDs as Compaction Anchors

* fix: Keep Derived Compaction Error IDs Within the Response Bound

* fix: Bound Regeneration Placeholders Across Client and API

* test: Complete Turn Protocol Regression Fixture Contracts

* fix: Validate Effective Turn IDs and Align Queued Parent Bounds

* test: Preserve Shared Constants in OAuth Controller Mocks

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-24 10:16:25 +02:00
lia-by-librechat[bot]
39ecd5563c
✒️ fix: Bind Assistant Avatar Updates to Authorized Owners (#17391)
* ✒️ fix: Bind Assistant Avatar Updates to Authorized Owners

* test: Keep Avatar Regression Checks Lintable and Typed

* fix: Preserve Provider-Only Assistant Avatar References

* fix: Preserve Assistant Identity and Avatar Access Across Legacy References

* test: Align Legacy Avatar Authorization Projection

* fix: Initialize Managed Assistant References With the Provider Author

* fix: Require Verified Ownership Before Initializing Private Avatars

* fix: Commit Assistant Avatar Identity Before Owner-Aware Cleanup

* test: Seed Indexed Avatar Users With Unique Emails

* fix: Serialize Assistant Avatar Publication and Cleanup

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-24 10:16:16 +02:00
Danny Avila
babf6f908b
🧾 feat: Admin Config Write Report, Structured Issues and Deployment-Only Paths (#17395)
* 🧾 feat: Admin Config Write Report, Structured Issues and Deployment-Only Paths

Admin config writes dropped what the API never stores (base-only sections, interface
permissions, dedicated sections) with a 200 and no word of it, stored values nothing reads
(boot-time and operator-only settings, overrides of MCP servers librechat.yaml runs as local
processes, tombstones inside arrays), answered most 4xx without a stable code, returned
validation issues without the bound or option that failed, and refused every admin write
once the terms-acceptance modal was on for an admin who had not accepted it, including the
write that turns it off.

PUT, PATCH /fields, POST /fields/tombstone and DELETE /fields now answer with `applied` and
`skipped` (with a reason per location); a whole `interface` PATCH keeps its UI fields;
base-only paths are skipped on every route. A new DEPLOYMENT_ONLY_CONFIG_PATHS list (rate
limits, CloudFront, permission leases, OpenAPI, skill deletion, the tool filters, the agents
and MCP boot settings, `cache`) is skipped on write, kept at librechat.yaml's value by the merge
and published in GET /meta. Writes and tombstones inside a librechat.yaml stdio MCP server
answer 400 PROCESS_MCP_SERVER_OVERRIDE, and a whole-section value leaves those servers out.
GET of a document lists what the merge leaves out of it (`ignored`, `ignoredBasis`).
Validation issues carry allowlisted `params`; each refused allowedAddresses entry is one issue
with a `reason`; agent recursion limits must be whole numbers of at least 1, and the runtime
ignores any other value. The config handlers' 4xx carry a `code`, the capability middleware adds
AUTH_REQUIRED/FORBIDDEN, and the admin config router opts out of the terms gate. PATCH checks a
section manager on every section it names, skipped entries included, as /changes does. New meta
flags: writeReport, issueParams, adminTermsExempt.

* 🧪 test: Expect Issue Params in the Whole-Document Override Validation Scenario

Validation issues now carry `params` (here the expected and received types), so the scenario that
asserts the exact issue list for a rejected PUT expects them too.

* 🧪 test: Cover Merged Read Codes, Tenant-Scoped Read Reports and Deployment-Only Resolution
2026-10-24 10:01:13 +02:00
lia-by-librechat[bot]
ba78cf5f5f
🫢 fix: Keep OAuth Credentials Out of Logs (#17409)
* 🫢 fix: Keep OAuth Credentials Out of Logs

* test: Match MCP OAuth SDK Fixture Types

* fix: Sanitize OAuth Failures Across Callback and Refresh Boundaries

* fix: Close OAuth Initiation Log Leaks and Preserve Vendor Recovery

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-24 09:43:06 +02:00
Danny Avila
f05f50460a
🔭 feat: Admin Config Read APIs (Resolved and Effective Config, Scope Catalog, Env Status) (#17383)
* 🔭 feat: Admin Config Read APIs (Resolved and Effective Config, Scope Catalog, Env Status)

Admin clients could read one config document at a time, or the deployment's merged config,
but nothing showed what a profile or a user resolves to: a client had to re-implement the
merge (Base-first precedence, merge keys, tombstones, the interface permission filter,
base-only fields, runtime stops, secret rebinding, the env allowlist) to preview it, and had
no way to see why part of a profile is ignored. Endpoint, model and tool pickers came from the
end-user routes, called as the signed-in admin, so they showed the admin's own scope and keys
and needed a browser User-Agent.

The admin config API now has four read routes. GET /resolved/:principalType/:principalId and
GET /effective?userId= return librechat.yaml, the documents that merge over it in merge order,
each with the parts the merge does not apply and why, and the result, in librechat.yaml shape.
They come from resolveConfigLayers, which tracks the same fold the served merge runs and is
pinned to it by parity tests, and from the stored documents rather than the override cache.
GET /catalog lists the endpoints (with the reason one is not served), models (served,
configured and defaults), MCP servers and tools a scope serves, resolved for the scope rather
than the caller and never with a user's stored key; GET /env-status reports whether each env
name the config uses is set, never its value. Every read is filtered to the sections the caller
can read, redacted as reads redact, and scoped to the caller's tenant. The admin Langfuse routes
now say why a deployment offers no connection settings. Meta reports resolvedApi, catalogApi,
envStatus and limits.catalogModelsTtlMs.

* 🪞 fix: Report Duplicate Custom Endpoints from the Served Definition

When librechat.yaml defines a custom endpoint name twice, or both `Ollama` and `ollama`, the
catalog kept the first definition for a name's env names, reason and models, while
`loadCustomEndpointsConfig` serves the last servable one. An entry could pair the served config
of one definition with the env names of another.

`resolveServedCustomEndpoints` now holds the runtime rule (the last definition with a name, key,
base URL and models wins under its served name), and `loadCustomEndpointsConfig`,
`loadConfigModels` and the catalog all use it. A name with no servable definition is reported
from its last one.

* ⏱️ feat: Make the Admin Catalog Model-List Lifetime Configurable

`GET /api/admin/config/catalog` reused a scope's model lists for a fixed two minutes. The new
librechat.yaml field `endpoints.catalogModelsTtlMs` sets that lifetime (milliseconds, `0` to one
hour, two minutes by default); `0` resolves the lists on every read. It is a base-only path, so a
profile cannot change it and `GET /meta` reports one value, now read from the deployment's config
on each request as `limits.catalogModelsTtlMs`.
2026-10-24 09:23:22 +02:00
lia-by-librechat[bot]
5a472bfef2
🙅 fix: Deny HTTP Access to System MCP OAuth Flows (#17408)
Co-authored-by: Lia <lia@librechat.ai>
2026-10-24 09:01:02 +02:00
lia-by-librechat[bot]
532214c022
🐡 fix: Bound Tool Approval Admission Work (#17387)
* 🐡 fix: Bound Tool Approval Admission Work

* style: Normalize HTTP Regression Formatting

* fix: Validate Persisted Options Before Runtime Alias Expansion

* fix: Preserve Option Limits Across Reset and Initialization

* fix: Keep Legacy Approval Options Readable in Management Responses

* fix: Retain Option Limit Provenance Through Runtime Normalization

* test: Use a Typed MCP Configuration Fixture

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-24 08:58:17 +02:00
Danny Avila
4d061fdd46
🔄 fix: Judge Tenant Profiles on Their Own Base, Clear Config Caches on Principal Deletion, and Add a Config Reload Route (#17397)
Profile writes are judged in the tenant partition the profile merges in. For a role, or a
caller inside a tenant, that is the caller's partition. For a group or user profile written by
an admin without a tenant, it is the stored document's tenant: PUT, PATCH and POST …/changes
validate on librechat.yaml as that tenant resolves it with that tenant's __base__ over it, use
the same Base for the recheck after commit and for key binding, tombstones and field deletes
judge re-entry on that tenant's librechat.yaml, and every route reports `ignored` over that
tenant's Base. Each attempt reads the document in that partition only, and a document that
moved partition while the write ran answers 409 CONFIG_VERSION_CONFLICT. The config store's
partition rules are unchanged; another tenant's Base is read in that tenant's context.

Deleting a group, role or user clears the config caches when it removes or restores the
principal's profile (`invalidatingConfigStore`), awaited before the response and broadcast with
Redis as config writes do; a call that rejects clears too, since it may have committed.

POST …/changes lets `unset` remove any part of a top-level section configSchema does not
define; the section's own `unknown_section` issue is no longer blamed on the removal, and every
other op there still answers 400 UNKNOWN_SECTION.

POST /api/admin/config/reload, for an admin without a tenant holding broad manage:configs (a
tenant admin gets 403, since the reload reaches every tenant), runs the config cache clear without
a write, loads librechat.yaml again on the answering instance, and once it loaded publishes the
clear over Redis so every other instance loads the file on its next read. It uses
ConfigCacheInvalidation.reload, which reports the clear, the load and the publish instead of only
logging a failure (writes keep `invalidate`, which leaves the load to the next read). It answers
200 `{ success: true, broadcast }`, `broadcast` false without Redis; 422 CONFIG_RELOAD_INVALID
with each schema issue's location when the loader refuses the file, keeping the last good config
and publishing nothing; 500 CONFIG_RELOAD_FAILED when a clear fails or the config cannot be built
from the file; and 503 CONFIG_RELOAD_BROADCAST_FAILED when this instance reloaded but the publish
failed, since an instance that misses the broadcast keeps its cached librechat.yaml, which never
expires. Every reload that runs is audited as `config.reloaded`, a failed one with outcome
`failure` and its code. The meta reports `features.reloadRoute`. Writes still reload the file.
The e2e content-filter helper uses the route instead of a sentinel profile.

docs/mcp-overrides.md describes the current timing: the awaited clear, the Redis broadcast, what
still waits for a TTL, that a process the clear misses keeps its old librechat.yaml, and hiding
as an access boundary at checkout.
2026-10-24 08:45:54 +02:00
lia-by-librechat[bot]
68826ec343
🛼 fix: Bound Document Name Collision Processing (#17386)
Co-authored-by: Lia <lia@librechat.ai>
2026-10-23 15:44:18 +02:00
lia-by-librechat[bot]
cba770daa8
⏪ fix: Normalize Preview Numbers in Linear Time (#17385)
Co-authored-by: Lia <lia@librechat.ai>
2026-10-23 15:43:11 +02:00
Danny Avila
94ae8a4198
🪷 chore: Upgrade DOMPurify and ip-address (#17379)
Some checks failed
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (shard 1/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 10/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 2/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 3/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 4/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 5/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 6/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 7/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 8/10) (push) Waiting to run
Codegraph E2E Votes / vote (shard 9/10) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/chat (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Publish `@librechat/client` to NPM / pack (push) Has been cancelled
Docker Dev Images Build / publish (push) Has been cancelled
Sync Helm Chart Tags / Ignore non-main push (push) Has been cancelled
Sync Helm Chart Tags / Sync chart tags (push) Has been cancelled
Publish `@librechat/client` to NPM / publish-npm (push) Has been cancelled
* chore: Update dompurify to version 3.4.17 across all package files

- Bumped dompurify version from 3.4.16 to 3.4.17 in package.json, package-lock.json, and relevant sub-packages.
- Ensured consistency in dependency versions across the project.

* chore: Update ip-address package to version 10.7.4 in package.json and package-lock.json

- Bumped ip-address version from 10.5.1 to 10.7.4 in package.json.
- Updated package-lock.json to reflect the new version and integrity hash.
2026-10-23 07:48:26 +02:00
Danny Avila
5e90cc45e4
📎 feat: Copy Chat Attachments into Attached Workspaces (#17376)
* 📎 feat: Copy Chat Attachments into Attached Workspaces

A chat on an attached workspace now copies the user's own attachments into
.librechat/attachments/ before the model runs, through the worker's
import_file operation, and tells the model where they are. A worker without
the operation, a deny file-write policy, or a copy that fails or runs past
its bound leaves a plain note saying the file is not on this machine and why.

* 🧭 fix: Scope Attachment Records by Tenant and Prime Late Subagents

Match the tenant when recording a workspace copy, require write_file so the
folder can always ignore itself, key copies by the live Code API route and
worker, keep a digest when a copy fails so it is not hashed again, stop
waiting on bookkeeping at the deadline, refuse to start on a cancelled turn,
prime lazily initialized subagents through one per-turn primer, and make the
budget configurable as endpoints.agents.workspaceAttachments.timeoutMs.

* 🙈 fix: Copy Attachments Only Where the Folder Ignores Itself

Gate every copy on .librechat/attachments/.gitignore ignoring the whole
folder: create it with *, and accept an existing one only when it already
ignores everything, otherwise report the file as unavailable with how to fix
it. Prime a lazily routed subagent against its own tool context with a
provisioning callback bound to it, and check for a cancelled turn before
arming the deadline timer.

* 🪢 fix: Recheck the Attachment Ignore Rule Each Turn and Share One Request Cap

Drop the process-wide ignore cache and check the folder once per turn, shared
by every agent, rejecting a truncated read. Cap workspace requests per turn
across agents (workspaceAttachments.concurrency, default 3), name converted
images for their stored type, log only safe error metadata, and keep the
bookkeeping write from advancing updatedAt.

* 🔀 chore: Take dev's File Methods Ahead of Merging dev

dev and this branch both add to the same lines of the file methods module.
Take dev's version here so the merge of dev that follows is clean; the next
commit adds recordFileWorkspaceImport back beside dev's new methods.

* 🧩 fix: Ignore Workspace Operations a Newer Worker Advertises

Bring recordFileWorkspaceImport back beside dev's new file methods after the
merge. Drop well-formed operation names this build does not know from a
worker's capabilities, globally and per workspace, instead of rejecting the
whole status, so workers can turn on new operations such as import_file by
default. Known names keep their strict checks, malformed lists are still
refused, and a worker offering only unknown operations offers no workspace
tools rather than failing.
2026-10-23 07:37:50 +02:00
lia-by-librechat[bot]
a51c45bbf3
🌳 fix: Preserve Primary Files Until Secondary Cleanup Succeeds (#17228)
* fix: Preserve primary files until secondary cleanup succeeds

* test: Use a flat deletion-strategy lookup

* fix: Preserve erasure retries and reconcile removed embeddings

* test: Match deletion regression formatting

* fix: Preserve search intent after vector cleanup

* fix: Repair retained project search files before tool execution

* fix: Normalize Retained Project File Runtime Types

* test: Use the Storage Source Enum in Project Repair Coverage

* fix: Confirm Secondary Cleanup and Preserve Repair Policy

* test: Correct Repair Fixture Types and Cleanup Retry Assertions

* fix: Reconcile Code Copies Compatibly and Charge Shared File Budgets

* fix: Reserve Admitted File Budgets Before Deferred Screening

* fix: Retain Concurrent File Copies and Scope Cleanup by Tenant

* fix: Bound Erasure File Checks and Correct Cleanup Fixtures

* fix: Preserve Provider-Only Assistant File Deletion

* fix: Reconcile Primary Vector Deletions Before Finalization

* fix: Finalize Successful Files in Mixed Cleanup Batches

* test: Load Real File Finalizer in Cleanup Integration Tests

* fix: Preserve Project Routing MIME and Fence File Storage Operations

* fix: Validate Provisioning Principal and Type Project Repair Fixtures

* fix: Recover Provisioning Claims and Retain Uncertain Storage Outcomes

* fix: Normalize File Recovery Results and Reconcile Transport Attempts

* test: Preserve Deployment Routes in Host Provisioning Fixtures

* fix: Recover Deletion Claims and Fence Generated Output Writes

* fix: Preserve Generated Output Commit Snapshots

* test: Use Persisted Owner Type in Generated File Fixture

* test: Type Generated Output Fixture with Its Commit Contract

* fix: Preserve Publication Error Handling and Cleanup Test Boundaries

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-10-23 07:00:20 +02:00
Danny Avila
db225c0919
🔐 feat: Admin Config Secrets v2 (MCP and Azure Credentials, Re-entry, Env Allowlist, Rebinding) (#17353)
* 🔐 feat: Admin Config Secrets v2 (MCP and Azure Credentials, Re-entry, Env Allowlist, Rebinding)

The admin config API stored MCP server credentials and Azure group keys in plaintext, returned
them to config readers, let an admin who cannot read a stored credential send it to a host of
their choosing, and let override values reference any environment variable. MCP credentials
and Azure keys, in `groups` and in the `groupMap` the Azure clients read, are now encrypted
with masked previews, hidden from every read and decrypted once after the merge. A write that
keeps a stored MCP credential or web search key while changing where it is sent must enter it
again, judged by the value the written document holds. `${VAR}` references in overrides are
limited to an allowlist, named where a change batch leaves them, and the merge drops a
credential a layer moves to a new destination without entering it, listing it in write
responses only for sections the caller can read. A custom endpoint's key is bound to its base
URL, its provider and the destination options in addParams and dropParams (such as the
anthropicApiUrl the native Anthropic client sends to), matched across layers under the name the
merge folds (ollama is Ollama). A restated `${VAR}` counts as entered, so allowlisted names
are not bound to a destination. Azure's `${INSTANCE_NAME}` and `${DEPLOYMENT_NAME}` stay
templates in a group's `baseURL`, and a scheduled job's MCP consent no longer depends on the
masked previews that change when an admin rotates the key in place.

* ♻️ refactor: Move the MCP Key Re-entry Guard Out of the Binding Helpers to Break an Import Cycle

With #17351's OpenID provisioning on dev, the app config service reached itself through the
rebinding guard: app/service -> app/overrides -> app/rebinding -> mcp/registry/binding ->
mcp/errors (and mcp/types) -> mcp/oauth/obo -> utils/identity -> auth/openid -> auth/provision
-> app/resolve -> app/service. The binding helpers are pure diffs; only
requireApiKeyReentryForRebinding needs the MCP error class, so it moves to
mcp/registry/reentry.ts, and the helpers take MCPOptions from librechat-data-provider as
mcp/headers.ts does. No behaviour changes.

* 🧪 test: Drop a Base-Held Endpoint Key That a Lower-Priority Profile Moves

Base merges first since #17352, so a profile below Base's priority still
lands over it. The rebinding guard drops the key Base stores for a custom
endpoint whose baseURL the profile changes, and the PATCH response lists
it in `ignored`.

* 🔐 fix: Serve Admin Azure Group Keys and Keep Deployment Keys at Their Own Destinations

Azure groups a profile writes now take effect: the merge resolves a layer's
`endpoints.azureOpenAI.groups` as AppService resolves librechat.yaml's
(`resolveAzureGroups`, shared with `azureConfigSetup`) into the `groupMap`,
`modelGroupMap`, model list and assistant models the Azure clients read. A
layer's groups replace the groups below whole, as its array does; groups that
do not resolve stay unread with a warning. The rebinding guard judges the
resolved groups like any `groupMap` entry, and an Azure group's destination now
also covers a deployment name its base URL takes its host from and the
destination options of its `addParams`/`dropParams`.

A write that keeps a stored Azure group key (in `groups` or `groupMap`) while
changing where the group sends it answers 400 `CONFIG_SECRET_REENTRY_REQUIRED`
on PUT, PATCH, field deletes, tombstones and change batches, judged as the
document resolves over librechat.yaml and on each `groups` item as written.

OCR fills an empty key from `OCR_API_KEY` only for its default destination (no
base URL, or `${OCR_BASEURL}`), so a key the guard dropped for an override's
`${VAR}` base URL is not replaced by the deployment's. The env reference policy
includes the `${OCR_API_KEY}` loading fills in for an `ocr` section without a
key, so a client can write back what GET `/base` returned.

The custom endpoint guard no longer needs the layer's overrides to name an
entry: an entry changed some other way is judged as inherited (positional
tombstones inside the list are not applied by the merge, so none reached one).

A web search URL a layer points at a `${VAR}` other than librechat.yaml's
without entering its key is set back: web search sends the deployment's key,
or its client's environment default, to any `${VAR}` URL.

* 🔐 fix: Keep Azure Assistants Served, Opaque Keys as Entered and Batch Env Checks on the End State

Azure assistants: a profile's `groups` replace the groups below whole, so
groups with no model that supports assistants under librechat.yaml's
`assistants: true` left `assistants` on with an empty `assistantModels`, and
the Azure Assistants initializer picked `assistantModels[0]` (undefined).
`azureConfigSetup` refuses that combination at startup; the merge now turns
`assistants` off when none of the models it leaves supports them, with a
warning, judged on the merged result so a later layer whose groups serve
assistants keeps them on. The check is `lacksAzureAssistantModels`, shared
with `azureConfigSetup`.

Opaque credentials: every runtime reader of the OCR, speech, web search and
Langfuse keys uses the decrypted value as is (`resolveConfigSecret`,
`resolveStoredConfigSecret`, `decryptConfigSecret`), so a `${...}` inside a
key the write encrypts is part of the key. Those fields are marked `opaque`:
the write-time check skips a value the write encrypts there, and the runtime
pass keeps their ciphertext instead of blanking it. A whole `${VAR}`
reference there, which the field passes through and its reader resolves, is
still checked, and so is stored plaintext. Custom endpoint (`initializeCustom`),
Azure group (`mapModelToAzureConfig`) and MCP (`processMCPEnv`) credentials
are expanded by their clients once decrypted and stay checked; the Assistants
keys have no reader yet and stay checked too.

Change batches: env references are judged on the document the batch leaves,
as its other issues are. An issue counts only when the end state still holds
a disallowed reference (ciphertext by its plaintext) where the batch sent one,
at a location the batch changed, so a value a later op removes or replaces
(`set ocr.baseURL`, then `unset ocr`) is no longer refused, and a stored
reference the batch puts back where it was is left to merge time.

* 🔐 fix: Proxy-Bound OAuth Secrets, Consistent Azure Group State, Batch Issues by Entry Key and Loaded Web Search References

- The MCP proxy is part of the OAuth client secret's binding (user tier, admin re-entry and the
  merge's rebinding guard share `getChangedOAuthSecretBindingFields`): the access token the
  secret obtains travels through it.
- A tombstone of `endpoints.azureOpenAI.groups` resolves the groups to none in the merge (empty
  `groupMap`, `modelGroupMap` and model lists, so the model list does not fall back to the
  environment's defaults), and removes what they resolve to in `applyConfigTombstones`.
- The merged Azure model lists name only models a merged group serves
  (`narrowAzureServedModels`), so an override's `assistantModels` no group serves no longer keeps
  Azure assistants on.
- `/changes` env issues are held by entry identity (`toConfigIdentityPath`), followed through
  renames and resolved on the batch's end state, so a removal or rename no longer shifts them.
- References loading librechat.yaml introduces (OCR's `${OCR_API_KEY}`, the web search defaults)
  are allowed at the location they are loaded at, so GET /base's sections are accepted written
  back, and nowhere else.

* 🔐 fix: Re-entry for Endpoint, OCR and Speech Keys, Own Keys Bound Over Base and User Key Destinations Kept

- The document that stores a custom endpoint, OCR or speech key can no longer
  move its destination without the key: PUT, PATCH, field deletes, tombstones
  and change batches answer CONFIG_SECRET_REENTRY_REQUIRED at the changed field
  (getBoundKeyReentryIssues), judged by value as the document alone sends it.
- A profile's own key for an endpoint, MCP server, OCR or speech service, or
  Azure groupMap group that Base defines is bound to that destination when it
  is entered: the rebinding guard reports a fingerprint of where it goes, the
  write stores it beside the key (<secret>Binding), and the guard keeps the key
  there until a lower layer moves it. Reads and the merged config leave the
  fingerprint out; kept keys carry it; client values are replaced.
- An inherited custom endpoint or MCP server that sends a credential each user
  holds (user_provided, customUserVars, apiKey.source user, OpenID or Graph
  token placeholders) keeps its destination: a layer's move is set back and
  listed in ignored.
2026-10-23 06:37:54 +02:00
Danny Avila
76e3c6b134
🪜 fix: Base-First Config Precedence, Profile Lifecycle and Role Renames That Keep Their Profile (#17352)
* 🪜 fix: Base-First Config Precedence, Profile Lifecycle and Role Renames That Keep Their Profile

Config documents merge in one total order (`compareConfigPrecedence`): Base (`role` /
`__base__`) first whatever its priority, then ascending priority, then role < group < user,
then document `_id`. The merge, `getApplicableConfigs` and `listAllConfigs` all use it, so a
tie no longer goes to the newest document whatever its type, and Base no longer outranks a
profile through its priority. A profile that writes fields of a librechat.yaml MCP server
therefore undoes a Base hide of that server for its principals. A write that creates a document
without a priority gives it its principal type's default (role 10, group 20, user 100, Base 0),
and a write that omits the priority keeps the stored one, so a broad PUT no longer resets a
profile to 10. Langfuse writes no longer pass a priority.

Profile writes (PUT, PATCH `/fields`, POST `/changes`) validate on librechat.yaml with the
active Base document resolved over it (`resolveRawConfig`, the fold the merge itself runs), so
a role write that is valid where it lands is accepted and one the merge would strip is refused.
Base still validates on librechat.yaml alone, an inactive Base is ignored, and `/changes` still
judges what librechat.yaml itself defines on the raw YAML.

`PATCH /api/admin/config/:principalType/:principalId/priority { priority, expectedRevision? }`
sets only the priority, for broad `manage:configs`, keeping overrides, tombstones and
`isActive`; it is audited as `operation: 'priority'`. A write that would create a principal's
first document (PUT, PATCH `/fields`, POST `/fields/tombstone`, POST `/changes` including a dry
run or a priority-only batch) answers 404 `PRINCIPAL_NOT_FOUND` unless the role (exact name),
group or user (lowercase ObjectId) exists in the caller's tenant partition, or at platform
level outside a tenant (`principalExists`). Each route checks inside its compare-and-swap
write, against the document the write replaces; the tombstone route now plans its write like
the others, so `AdminConfigDeps` no longer takes `tombstoneConfigField`. A PUT with
`expectedRevision: 'absent'` creates the profile even when it carries no overrides.

Renaming a role moves its config profile, system grants and ACL entries to the new name in the
caller's tenant partition. The profile moves through the store contract (`movePrincipal`: a
create-only copy, then removal at the copied revision). A profile already at the new name
answers 409 `ROLE_CONFIG_CONFLICT`, and any failed step rolls back the users, the role document
and every move (500 `ROLE_RENAME_FAILED`). Profiles, grants and ACL entries that renames made
before this change left at an old name are neither moved nor removed, and a role created under
that name still picks them up. The Base principal id is a reserved role name (400
`ROLE_NAME_RESERVED`), and a legacy role by that name never moves or deletes Base. The admin
config meta reports `deterministicPrecedence`, `priorityRoute`, `principalCheck` and
`roleRenameMovesProfile`.

* 🧪 test: Give the E2E Reload Sentinel a Role of Its Own

Admin config writes now answer 404 PRINCIPAL_NOT_FOUND for a principal that does not exist, so
the content-filter helpers' reload sentinel (a made-up user id) could no longer write and every
spec that reloads librechat.yaml failed. The sentinel is now a role the helper creates once (409
when it already exists) and deletes after its profile in cleanup; no user is a member, so its
empty profile changes no one's config.

* 🛟 fix: Keep a Moved Profile Whose Removal Cannot Be Confirmed, Validate on the Caller's Base and Restore Rolled-Back Descriptions

- `movePrincipal` no longer treats a failed read-back of the source, after its removal
  failed, as the source still being there. It keeps the copy, which may be the only one
  left, and rethrows the removal's failure instead of deleting the copy.
- Profile writes read the Base validation floor from the caller's tenant partition, so a
  caller without a tenant validates on the platform-level Base and never on a tenant's.
- A role rename that rolls back gives a role stored without a description the schema
  default back, instead of a `$set` of `undefined` that kept the new description.

* 🧭 fix: Scope Profile Priority Changes to the Caller's Tenant Partition

`setConfigPriority`, behind PATCH `/api/admin/config/:principalType/:principalId/priority`,
read and wrote through the unpartitioned config store. A platform-level admin without a
tenant runs in the default non-strict context, where the tenant-isolation plugin adds no
predicate, so the route could reorder a tenant's profile for the same principal, and answer
with it, when no platform-level profile existed.

It now runs on the partitioned operations that the role rename and the partitioned
`findConfigByPrincipal` use. The read is limited to the caller's partition: that tenant's
document, or without a tenant only a platform-level one (no tenant, `null` or `''`). The
write is pinned to the `_id` of the document that read returned. A tenantless caller
therefore gets 404 `CONFIG_NOT_FOUND` for a profile only a tenant holds. An
`expectedRevision` naming such a profile gets a revision conflict and changes nothing.

Tests: `config.spec.ts` (data-schemas) adds "setConfigPriority in the caller tenant
partition". It covers the platform profile changing alone, a profile that only a tenant holds
being neither changed nor returned, and only the active tenant's profile changing inside a
tenant. The tenant helpers are now shared with the rename suite.
`config.precedence.integration.spec.ts` adds the same check through the handler. With the old
wiring, a tenantless PATCH of a profile only tenant-a holds answers 200 and moves tenant-a's
profile to 40. With the fix it answers 404 and tenant-a keeps 10.

* 🧷 fix: Roll Back Only What a Rename Changed and Validate Profile Writes on the Base They Land Over

- Grant moves report what they changed (re-keyed grants, and superseded grants whose removal
  was confirmed); the undo re-keys only grants still at the new name and re-creates a
  superseded grant only while the new name still holds the grant that superseded it, so a
  grant revoked during a rename is never resurrected.
- The Mongoose binding settles a create whose acknowledgement was lost by the `_id` it chose
  (found at version 1: committed, returned), as the store contract now requires; a profile
  move whose copy committed finishes instead of leaving an orphan copy. The memory engine and
  the conformance suite cover it, plus a copy that cannot be withdrawn being logged.
- A rename rollback moves back only the profile it moved (by identity, edits included), puts
  back only members still on the new name, and reverts the description only while it is still
  the one the rename set.
- PUT, PATCH /fields and POST /changes read Base beside the profile on every attempt and read
  it again once the write commits; a write that Base changed under is judged on that Base and
  withdrawn (only at the revision it wrote) when it fails there.
- The priority route rereads a lost race's current revision in the caller's tenant partition.
2026-10-22 23:32:27 +02:00
Danny Avila
0abbf3313d
🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351)
* 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links

Sign-in decisions made before the user is known now read librechat.yaml plus the `__base__`
override of the request's tenant, or of the deployment outside a tenant, and fail closed
(`resolvePreAuthAppConfig`). Registration, the first phase of password reset and the first
email-domain check of the LDAP, OpenID, SAML and social strategies use it. The second check
applies the account's role overrides with or without a tenant, and a new account is checked
against the role it will be created with before anything is inserted. OpenID checks again when
the admin claim or role sync changes the role. Password reset issues no link when the
account's config cannot be read.

The signed-out `GET /api/config` serves Base `registration.socialLogins` and the pre-login
interface fields (`resolvePreLoginAppConfig`), falling back to librechat.yaml when overrides
cannot be read. `turnstile` becomes a base-only section, so Turnstile comes only from
librechat.yaml.

Config reads that merge documents stay in one tenant partition (`tenantPartition`, Mongoose
binding `tenantPartitionFilter`): the active tenant's documents, or the tenantless ones outside
a tenant. The config store's Mongoose binding reads, writes, lists and restores role documents,
`__base__` included, in that partition, and its `listActive` draws every document from it;
group and user documents stay addressed by id. Only a `list` with `acrossTenants` reads every
partition, which `listConfigTombstones` uses so the startup MCP tombstone report still names
each tenant's documents. The tenant-isolation conformance suite gains single-partition cases.

Privacy policy and terms of service `externalUrl` must be http(s), `mailto:`, `tel:`, relative
or blank (`isSafeLinkUrl`). Admin writes of another scheme are refused, a librechat.yaml link is
dropped with a warning at load, a stored one is dropped at merge, and every payload and the
client remove one that reaches them. The admin config meta reports
`features.preAuthBaseOverrides: true`.

* 🧪 test: Layer a Required-Field Override Through interface.currency Instead of Turnstile

Turnstile is set in librechat.yaml only now, so profile overrides of it are skipped and the
layering scenario could no longer see a role's Turnstile options completed by a user's site key.
The scenario now layers `interface.currency`, whose `code` and `rate` are both required: the role
stores only the rate, the user only the code, and /api/config serves both.

* 🛂 fix: Admit a First OpenID Login Under Its Claimed Role Before Creating the Account

The admin-role claim and role sync are now decided before a first-login OpenID account is created, and createUserOnce admits the email under that role's config, read in parallel with the USER role's, before inserting anything. A login the claimed role refuses creates no account and no start balance. Admitted logins are unchanged: the account is still created as USER (now explicitly), moved into the claimed role, re-checked and audited as before, with the claims decided once. An account a concurrent first login created gets the claims decided again for its own role and tenant.
2026-10-22 22:49:54 +02:00