mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* 🧾 perf: Load Tool-Call Previews and Fetch Full Parts on Demand Long agent conversations shipped every tool output, argument string and subagent transcript on load, though the cards render collapsed: 12-18 MB of message JSON per chat, enough to crash iPhone Safari tabs. A client that adds ?toolPreviews=1 to the conversation load now receives bounded previews of settled tool calls (start and end of long outputs, JSON arguments and outputs kept valid with only their longest strings shortened, exit-status trailers kept whole, subagent transcripts omitted) with explicit markers and full lengths. Opening a card or a subagent panel fetches the stored part from a new owner-scoped endpoint, GET /api/messages/:conversationId/:messageId/parts/:partIndex, cached under its own React Query key. Clients that do not ask, exports and share links keep the full payload; bounds are configurable under toolCallPreviews in librechat.yaml, and a client-authored message that carries previews is refused rather than saved. * 🧾 fix: Validate Part Reads in Parallel and Preview Fork Responses The full-part read now starts beside conversation-access validation instead of after it, and keeps the active-job fallback the conversation read has, so a conversation still live before its first save can expand its previews. Fork, duplicate and shared-link fork responses honor the preview parameter, so they no longer seed the conversation cache with the full history. Background-task results whose structure cannot fit a valid JSON preview go whole, image cards keep their prompts, and the subagent panel offers a retry when its stored part fails to load. * 🧾 fix: Key Hydrated Parts by Preview Revision and Call Identity A fetched part is now cached under the preview's revision and replaces only the fields the server shortened, so a call whose stored output changes later (a harvested background result) is fetched again rather than rolled back. Part lookups carry the run-step and agent identity and refuse an ambiguous fallback, since provider tool-call ids can repeat within one response. A subagent that finished without final text has its transcript omitted like any other settled call, and JSON nested past a fixed depth falls back to a text preview; a call whose preview fails is sent whole instead of failing the conversation load. * 🧾 fix: Release Hydrated Parts With Their History and Bound JSON Work Full tool-call parts fetched for a conversation are removed when its message history is released or cleared, so they cannot outlive it under their own key. The structure-preserving JSON preview now bails out before cloning when the value has more nodes or strings than could ever fit, keeps a __proto__ key as ordinary data, and the part endpoint accepts any safe-integer index instead of an arbitrary ceiling. * 🧾 fix: Count Property Names Before Cloning a JSON Preview Property names are never shortened, so the pre-check now adds their length to its budget and falls back to the text preview before any cloning when they alone could not fit. * 🧾 fix: Preview Artifact and Branch Responses and Rehydrate Subagent Prompts Artifact edits and parallel-response branches merge the message the server returns into the conversation cache, so both requests now ask for previews and their routes honor it. The subagent panel reads the prompt from the stored arguments once they load, and the part endpoint no longer caps identifier length, so any previewed call can be fetched. * 🧾 fix: Preview Only Tool Calls That Can Be Fetched Back by Identity A call without an id has nothing but its position to name it, and the position can shift on the client, so it is left whole instead of being previewed. The part endpoint now requires a tool-call id, so an indexed lookup always confirms the call it returns. * 🧾 fix: Fetch Parts by Exact Identity and Preview Only Unique Ones The part endpoint now finds a call by its exact identity (provider id, run-step id, agent) instead of trusting the client's index, and the preview pass only shortens calls whose identity is unique in their message, so every preview names exactly one stored part. Legacy web-search failures that carry their error phrase mid-output go whole, since the collapsed card reads that phrase anywhere. * 🧾 fix: Bound the JSON Fit Walk Before Queueing and Normalize Empty Identities The structure check now counts an array's or object's children against the node budget before queueing them, so a very wide value is refused without building a work list its size. An empty run-step or agent id is treated as absent by the part lookup, matching how the preview pass and the client already treat it. * 🧾 fix: Key Fetched Parts to the Stored Version and Hydrate Search Details Each preview now carries `previewRevision`, when its message last changed, and the client keys fetched parts to that plus a fingerprint of the whole preview, so any change to the stored call is fetched again. The web-search details card asks for the stored call when it opens, so its query is never left shortened. * 🧾 fix: Cache Fetched Parts by Identity and Hold Copy Until Hydrated The part query key drops the client-side index, which only rides along in the request; the server locates the call by message and exact identity, so a shifted index serves the cached copy instead of downloading it again. Copy controls inside a previewed part are disabled until the stored content arrives, so a slow or failed fetch cannot export shortened text. * 🧾 fix: Shape Shared Forks With the Recipient's Bounds and Keep JSON Numbers Exact A shared-link fork resolves the share owner's config for its content checks, but the forked conversation belongs to the requester, so its preview bounds now come from the requester's tenant and role (prepareResultToolCallPreviews). A structure-preserving JSON preview now requires every number in the text to survive a parse and re-serialization as the same value; an integer past 2^53, an out-of-range exponent or an over-precise decimal falls back to the text preview (or the whole output for parsed-output tools) instead of showing a changed value.
77 lines
2.6 KiB
JavaScript
77 lines
2.6 KiB
JavaScript
const blockRetiredSetupToken = require('./blockRetiredSetupToken');
|
|
const validatePasswordReset = require('./validatePasswordReset');
|
|
const setTwoFactorTempUser = require('./setTwoFactorTempUser');
|
|
const { setTwoFactorAcknowledgementTempUser, setTwoFactorFinalizationTempUser } =
|
|
setTwoFactorTempUser;
|
|
const validateRegistration = require('./validateRegistration');
|
|
const buildEndpointOption = require('./buildEndpointOption');
|
|
const validateEmailLogin = require('./validateEmailLogin');
|
|
const validateMessageReq = require('./validateMessageReq');
|
|
const {
|
|
canReadActiveJobConversation,
|
|
createMessageRequestValidation,
|
|
prepareMessageRequestValidation,
|
|
sendValidationResponse,
|
|
} = require('./messageValidation');
|
|
const checkDomainAllowed = require('./checkDomainAllowed');
|
|
const { markOAuthNavigation } = require('./oauthNavigation');
|
|
const requireSameOrigin = require('./requireSameOrigin');
|
|
const requireLocalAuth = require('./requireLocalAuth');
|
|
const canDeleteAccount = require('./canDeleteAccount');
|
|
const accessResources = require('./accessResources');
|
|
const requireLdapAuth = require('./requireLdapAuth');
|
|
const abortMiddleware = require('./abortMiddleware');
|
|
const checkInviteUser = require('./checkInviteUser');
|
|
const requireJwtAuth = require('./requireJwtAuth');
|
|
const { requireRumProxyAuth } = require('./requireJwtAuth');
|
|
const configMiddleware = require('./config/app');
|
|
const { strictConfigMiddleware } = require('./config/app');
|
|
const validateModel = require('./validateModel');
|
|
const moderateText = require('./moderateText');
|
|
const logHeaders = require('./logHeaders');
|
|
const setHeaders = require('./setHeaders');
|
|
const validate = require('./validate');
|
|
const limiters = require('./limiters');
|
|
const uaParser = require('./uaParser');
|
|
const checkBan = require('./checkBan');
|
|
const noIndex = require('./noIndex');
|
|
const roles = require('./roles');
|
|
|
|
module.exports = {
|
|
...abortMiddleware,
|
|
...validate,
|
|
...limiters,
|
|
...roles,
|
|
...accessResources,
|
|
noIndex,
|
|
checkBan,
|
|
uaParser,
|
|
setHeaders,
|
|
logHeaders,
|
|
markOAuthNavigation,
|
|
moderateText,
|
|
validateModel,
|
|
requireJwtAuth,
|
|
requireRumProxyAuth,
|
|
setTwoFactorTempUser,
|
|
setTwoFactorAcknowledgementTempUser,
|
|
setTwoFactorFinalizationTempUser,
|
|
blockRetiredSetupToken,
|
|
checkInviteUser,
|
|
requireLdapAuth,
|
|
requireLocalAuth,
|
|
requireSameOrigin,
|
|
canDeleteAccount,
|
|
configMiddleware,
|
|
strictConfigMiddleware,
|
|
checkDomainAllowed,
|
|
validateMessageReq,
|
|
canReadActiveJobConversation,
|
|
sendValidationResponse,
|
|
createMessageRequestValidation,
|
|
prepareMessageRequestValidation,
|
|
buildEndpointOption,
|
|
validateRegistration,
|
|
validatePasswordReset,
|
|
validateEmailLogin,
|
|
};
|