LibreChat/api/server/services/Endpoints/agents
Marco Beretta 8fab21d882
🧬 fix: Skip Re-Embedding Legacy File Search Files After Upgrade (#17206)
* fix: Skip Re-Embedding Legacy File Search Files an Agent Already Holds

Files embedded before per-namespace tracking carry no embeddedEntities, so
lazy provisioning treated them as unembedded and embedded them a second
time on the first search after upgrading, duplicating every passage.

A legacy record in the agent's own file_search resources was embedded for
it, so trust its embedded flag there instead of re-queueing it.

* fix: Adopt Legacy Search Embeddings Only for Their Sole Holder

Trusting the embedded flag for every legacy File Search file left an agent
that inherited one querying a namespace without its vectors. Legacy files
held by no other agent now record the active agent as their namespace, a
one-time write, and are not embedded again; a file another agent also
holds keeps the per-namespace re-embed.

Adds an e2e scenario that reshapes an uploaded agent file into the v0.8.7
record and checks that search queries it without a second embed.

* test: Cover Legacy Search Files Shared With Another Agent

* test: Read the Stored File Id in Legacy Search Scenarios

* fix: Pin Legacy Search Adoption to Loaded Records and Wire Every Agent Init

file_id is not unique, so adoption now matches each record by its owner and
tenant as well, and only rewrites the records priming loaded. The added
conversation and client agent initializations receive the dependency too,
so their sole-holder legacy files are not embedded a second time.

* fix: Adopt Each Legacy Search Record in One Conditional Write

* fix: Count a Concurrent Same-Agent Adoption as Adopted

* fix: Run Legacy Search Adoption Beside the Liveness Probe and Fall Back on Failure

* fix: Keep Committed Legacy Search Adoptions When a Sibling Write Fails

* fix: Confirm Legacy Search Embeddings With RAG Before Adopting Them

Inferring the embedding agent from current File Search holders could adopt a
file for an agent whose namespace held none of its vectors, for example after
the agent that embedded it was deleted. Priming now asks RAG for one chunk of
each legacy file under the agent's entity_id and records the namespace only
on a hit; a miss or an unreachable RAG keeps the file queued for embedding.

The data-schemas method no longer scans agents and matches untenanted records
as untenanted. The fake RAG server answers these presence checks from the
embeds it stores.

* fix: Require the Entity's Own Chunks and Keep Confirmed Vectors

RAG also returns chunks owned by the requesting user, so a presence check now
counts only chunks recorded under the agent itself. Once vectors are
confirmed, the turn skips the re-embed even if recording the namespace fails.

* fix: Bound the Legacy Search Check and Keep the Fake RAG Query Shape

The RAG presence check now times out (fileConfig.legacySearchProbeTimeoutMs,
5s by default) and falls back to embedding, so a stalled RAG cannot hang
priming. The fake RAG server records presence checks in their own list and
keeps the file_search query records it already returned.

* fix: Check Any Unrecorded Namespace Before Embedding a Search File

A file another agent embedded first lists only that agent, so the agent
whose older vectors went unrecorded skipped the check and embedded a second
copy. Priming now asks RAG for every agent File Search file that records no
embedding for the active agent, and recording adds the namespace to the ones
already there.

* fix: Ask RAG for Several Chunks So a User Copy Cannot Hide the Agent's

RAG ranks chunks across every owner of a file_id and, once the top one is
authorized, returns them all. A copy of an agent file embedded for the
requesting user could rank first with k: 1 and hide the agent's own chunks,
so the presence check now asks for ten and checks every owner.

* fix: Confirm Setup Embeddings in Shared-File Runs and Log Safely

The run-file host primes an agent's setup files on its own, so it now
receives the RAG presence check and the namespace recorder too; without
them a shared-file run could embed a legacy setup file a second time.
Failed checks are logged with getSafeErrorMetadata rather than the raw
error, which carries the vector store's response body.
2026-10-17 19:19:14 +02:00
..
addedConvo.js 🧬 fix: Skip Re-Embedding Legacy File Search Files After Upgrade (#17206) 2026-10-17 19:19:14 +02:00
addedConvo.spec.js 🍵 fix: Support Renewable MCP Credentials for Schedules (#15908) 2026-09-14 10:27:47 -04:00
backgroundCompletion.js 🪇 perf: Coalesce Ready Background Completions (#16650) 2026-10-02 15:03:22 -04:00
build.js ⚡ perf: Exclude Agent Version History From Default getAgent Reads (#16070) 2026-09-20 19:27:21 -04:00
eventChildLease.js 📨 feat: Continue Bound Child Agents from Events (#15112) 2026-08-23 01:15:57 -04:00
index.js
initialize.js 🧬 fix: Skip Re-Embedding Legacy File Search Files After Upgrade (#17206) 2026-10-17 19:19:14 +02:00
initialize.spec.js 🏝️ fix: Apply the No-Workspace Decision Wherever an Agent's Code Route Resolves (#16798) 2026-10-06 07:40:42 -04:00
linkedInstructions.js 🔗 feat: use LibreChat prompt groups as agent instructions (#16686) 2026-10-04 21:27:26 -04:00
skillDeps.js 🔌 feat: Integrate Durable Skill Lifecycle Across Writers and Routes (#17043) 2026-10-16 09:05:05 -07:00
skillDeps.spec.js 🔌 feat: Integrate Durable Skill Lifecycle Across Writers and Routes (#17043) 2026-10-16 09:05:05 -07:00
subagentThreadStore.js 📼 fix: Replay Running Subagent Activity (#16541) 2026-10-02 13:24:47 -04:00
subagentThreadStore.spec.js 📼 fix: Replay Running Subagent Activity (#16541) 2026-10-02 13:24:47 -04:00
title.js 🖲️ fix: Enable Running Chat Menus and Preserve Renamed Titles (#16697) 2026-10-03 23:17:15 -04:00
title.test.js 🖲️ fix: Enable Running Chat Menus and Preserve Renamed Titles (#16697) 2026-10-03 23:17:15 -04:00