LibreChat/api/server/services
Danny Avila 60a74e6cd4
🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End (#18028)
* 🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End

A steer the server accepted (202) but the run never applied was handed back
in FINAL as `pendingSteers` and re-owned by the browser as a tab-local queued
message. A reload, closed tab, or a predecessor race before the drain lost it.

At terminal publication, a normally completed run now promotes such steers
into server-owned agent queued turns (parent: the ended response, epoch: the
ended generation's createdAt, chained behind any turn already queued against
that epoch). The job store hands the parked copy over atomically
(`promoteSteerLeftover`: parked item removed, receipt settled `recovered`), so
status recovery, lost-ACK retries and legacy recovery starts cannot queue the
same words again. FINAL reports the receipts in `promotedSteers`; the client
adopts them as server rows instead of converting the steer locally.

Promotion is opt-in per steer (`promoteLeftover`, sent only by clients that
adopt receipts and only for steers with no tab-only context), so older
clients keep the legacy path unchanged, and older servers simply never
report `promotedSteers`.

* 🔒 fix: Settle a Promoted Steer's Hand-Off at Admission, Not Only at FINAL

The job-store hand-off of a promoted steer now returns an outcome and stamps
the receipt with the owning queued turn, so it is idempotent for that turn.
The queued-turn resolver repeats it before admitting a promoted turn: it
completes a hand-off a crash interrupted, and cancels the turn when the
parked copy was discarded or recovered elsewhere, so the words never run
twice. At FINAL, a row whose hand-off was refused and whose retirement cannot
be confirmed is withheld from `pendingSteers` and left for that admission
check. The conservative reconcile frame keeps `promotedSteers`, and the
client adopts it there before sweeping local chips.

* 🔏 fix: Give Promoted Steers Durable Ownership, Their Run's Queue Lineage and Approval Mode

A turn promoted from an unapplied steer now records its source on its own
row: the steer's ids, the generation that accepted it, and a mark set only
once the job store handed the parked copy to that row. Admission runs a
promoted turn on that mark or on a hand-off the job store confirms now;
without proof (the store's evidence expired, or the host cannot ask) the
turn is held for review instead of running.

- Hand-off replies that are lost no longer cancel the row. The row stays as
  the client's handle and its admission settles ownership, so a committed
  hand-off can no longer leave the steer with no runnable copy.
- A replayed promotion never hands the parked copy to a row that was
  cancelled or failed.
- Promoted turns join the queue lineage of the generation that accepted
  the steer, so a sibling still queued behind that run no longer strands
  them with a predecessor mismatch.
- The steer request carries the sender's code approval mode onto the
  promoted turn; an unreadable mode keeps the steer on the client path.
- A steer whose quotes its owner stripped stays on the client path.
- The queued-turn receipt names the promoted steer by both ids, and the
  receipt list retires a pane's local copies even when it missed FINAL.

* 🚧 fix: Fence Promoted Turns to Workers That Prove Steer Ownership

A promoted row without an approval mode was published under the v1 queued
turn capability, so during a rolling deploy a worker that predates the
ownership check could claim it and run an unsettled row while the parked
steer was still recoverable elsewhere.

Promoted rows now publish under a new agent_queued_turn_v3 capability and a
v3 delivery identity, always reserved before insertion. A replica that
projects an older version can neither publish the reserved delivery nor
claim it, and enqueue refuses a promoted row without a reservation.

* 🪦 fix: Keep a Dead Promoted Turn Answering for Words It Held

A pane that learns of a promoted steer from the receipt list dropped the
mapping for every dead row. A row quarantined as ADMISSION_INDETERMINATE can
still settle as admitted, and a row that died after it was proven the sole
owner of the words is their only surface, so in both cases the pane kept a
chip whose recovery could never run.

The receipt now says whether the turn owned its steer's words, and a dead
receipt keeps answering for them when it did or when its admission is
indeterminate. A replayed promotion applies the same rule to a settled row.

* 🧾 fix: Find Promoted Turns by the Steer a Pane Holds, Join Root Lineages, Redact Hand-off Errors

- A promoted turn's request id is now derived from the client steer id, and a
  pane asks for the receipts of the steers it still holds a local copy of
  (recovery rows and failed chips). A promoted turn that already ran is only
  listed when asked for by name, so a pane that missed FINAL now finds it
  and retires its copy. A client steer id too long to key a queued turn is
  not promoted.
- The lineage lookup includes a generation admitted from a root queued turn,
  which has a parent and no epoch. The promoted turn joins that lineage
  without an epoch instead of opening a second one.
- A failed hand-off at admission reports a fixed message. The job store's
  own error text stays out of the dead-letter record a client can read, and
  promotion logs carry safe error metadata instead of error text.

* 🔢 fix: Ask for Held Steers First Under the Receipt Lookup Limit

The receipt list answers for at most 100 request ids, and a pane's server
rows were listed ahead of the steers it still holds, so a full server queue
could push every held steer out of the request. A promoted turn that had
already run was then never found.

Held steers now come first. An active server row is listed whether or not
it is asked for, while a settled promoted turn is found only by name.
2026-11-10 22:43:32 -05:00
..
__tests__ 🔌 perf: Look Up MCP Server Catalogs Concurrently for Tool Definitions (#17973) 2026-11-10 17:33:18 +01:00
Agents 🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End (#18028) 2026-11-10 22:43:32 -05:00
Artifacts 🧵 fix: Preserve Fenced Markdown Artifacts (#14121) 2026-07-05 12:04:59 -04:00
Config 🧭 perf: Validate Agent Models Against Their Own Endpoint Catalog (#17972) 2026-11-10 17:33:29 +01:00
Endpoints 🧭 perf: Validate Agent Models Against Their Own Endpoint Catalog (#17972) 2026-11-10 17:33:29 +01:00
Files 🦪 fix: Preserve Generated File Byte Snapshots (#18009) 2026-11-10 13:45:15 -05:00
MCP 🔐 fix: Fence ACL Viewers and Surface Revocation Failures When Removing Shared MCP Servers (#17506) 2026-10-28 00:37:07 +01:00
Runs 🗑️ fix: Drain Assistants Runs Before Erasing the Account (#17937) 2026-11-09 15:35:31 +01:00
Schedules 🪸 refactor: Separate Shared-Link and Schedule Persistence (#18031) 2026-11-10 15:44:13 -05:00
Skills 🔌 feat: Integrate Durable Skill Lifecycle Across Writers and Routes (#17043) 2026-10-16 09:05:05 -07:00
start 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
Threads ⚡ perf: Async Local File Saves and Compile Hot-Path Regexes Once (#16712) 2026-10-04 15:52:55 -04:00
Tools 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
ActionService.js 🫢 fix: Keep OAuth Credentials Out of Logs (#17409) 2026-10-24 09:43:06 +02:00
ActionService.spec.js 🫢 fix: Keep OAuth Credentials Out of Logs (#17409) 2026-10-24 09:43:06 +02:00
AssistantService.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
AuthService.js 📪 fix: Require Email Delivery for Password Reset Links (#17823) 2026-11-09 08:27:33 -05:00
AuthService.spec.js 📪 fix: Require Email Delivery for Password Reset Links (#17823) 2026-11-09 08:27:33 -05:00
createRunBody.js 🛂 feat: Filter Model-Bound Content by Source (#14425) 2026-08-21 22:43:32 -04:00
createRunBody.spec.js 🛂 feat: Filter Model-Bound Content by Source (#14425) 2026-08-21 22:43:32 -04:00
GraphApiService.js 🥸 fix: Resolve Directory Principals Through Trusted Integration Data (#17825) 2026-11-10 09:22:08 -05:00
GraphApiService.spec.js 🥸 fix: Resolve Directory Principals Through Trusted Integration Data (#17825) 2026-11-10 09:22:08 -05:00
GraphTokenService.js
initializeMCPs.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeMCPs.plugins.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeMCPs.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeOAuthReconnectManager.js 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
initializeOAuthReconnectManager.spec.js 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
LangfusePromptSync.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
LangfusePromptSync.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
MCP.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
MCP.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
MCPAuthorizationFenceRetry.js 🛂 fix: Back Off MCP OAuth Discovery (#15783) 2026-09-09 22:21:34 -04:00
MCPAuthorizationFenceRetry.spec.js 🛂 fix: Back Off MCP OAuth Discovery (#15783) 2026-09-09 22:21:34 -04:00
MCPRequestContext.js
OboPolicyService.js
OboTokenService.js 🙈 fix: Mask Emails and Drop Personal Identifiers From Logs (#17048) 2026-10-15 15:54:27 +02:00
OboTokenService.spec.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
OpenIDRefreshFlight.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
OpenIDRefreshFlight.spec.js 🪫 fix: Recharge Direct OpenID MCP Bearer Sessions (#15704) 2026-09-07 21:05:26 -04:00
OpenIDRefreshRecovery.js 🔐 fix: Retire Credentials by Their Committing Write and on Opt-In 2FA (#17504) 2026-11-05 22:53:11 +01:00
OpenIDSessionRefresh.js 🪫 fix: Recharge Direct OpenID MCP Bearer Sessions (#15704) 2026-09-07 21:05:26 -04:00
OpenIDSessionRefresh.spec.js 🪪 fix: Boot-Paint a Cached Theme Only for Its Signed-In Owner (#16926) 2026-10-14 11:08:53 +02:00
PermissionService.js 🥸 fix: Resolve Directory Principals Through Trusted Integration Data (#17825) 2026-11-10 09:22:08 -05:00
PermissionService.spec.js 🥸 fix: Resolve Directory Principals Through Trusted Integration Data (#17825) 2026-11-10 09:22:08 -05:00
PluginService.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
PluginService.spec.js 🔐 fix: Encrypt User Plugin Credentials With Random-IV v3 Format (#16996) 2026-10-12 16:33:08 +02:00
Prompts.consumers.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
Prompts.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
Prompts.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
RefreshTokenBridge.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
RefreshTokenBridge.spec.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
systemGrant.spec.js
ToolService.js 🔌 perf: Look Up MCP Server Catalogs Concurrently for Tool Definitions (#17973) 2026-11-10 17:33:18 +01:00
twoFactorService.js 🗝️ fix: Strengthen Two-Factor Recovery Credentials (#16742) 2026-10-04 12:16:37 -04:00
twoFactorService.spec.js 🗃️ refactor: Remove Dead Data Schemas Methods and Data Provider Exports (#17113) 2026-10-15 12:23:29 +02:00