| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
* ⚡ perf: Load Provider SDKs on First Use, Not at Import Time Every provider SDK loaded when anything imported the package: the registry stored constructed classes, so providers.ts had to import all of them — @langchain/mistralai alone cost ~290ms of module init, paid by hosts that never configure Mistral. Built-ins now register loaders that the registry resolves and memoizes on the first model request, validating constructibility at resolve time; the host-facing registerProvider contract is unchanged. Loads go through src/lazyRequire.ts — the one module allowed to touch import.meta — using package self-references against new ./llm/<provider> subpath exports, so resolution is identical from the CJS and ESM builds. Jest maps the seam to a stub that resolves source modules through its own resolver, the same precedent as the @langchain/mistralai stub (whose original reason — providers.ts eagerly importing Mistral — this change removes). * ⚡ perf: Defer the Remaining Eager Provider Imports Four modules kept a provider SDK on the root entry's graph after the registry went lazy: the openai-family instanceof guards in llm/init and run, the tool-cache converters in the openrouter and bedrock caches, and the Calculator's mathjs import (~150ms for a tool that may never be invoked). Each now loads its dependency on the code path that needs it: the guards run only for their own provider family — and can only match an instance whose class is already loaded — and a calculator that is never called never parses mathjs. * 🔥 chore: Move Provider Chat-Model Classes off the Root Barrel CustomChatMistralAI, CustomOpenAIClient, and ChatOpenRouter were the last root re-exports forcing their SDKs to load with the barrel. They remain available from their own entries (@librechat/agents/llm/mistral, /llm/openai, /llm/openrouter). LibreChat imports none of them from the root; external consumers migrate to the subpaths. Root entry load: 785ms -> 247ms. LibreChat boot to ready: ~1,740ms -> ~1,320ms, alternating A/B, four boots per arm. * 🎯 fix: Keep Lazy Loads Inside the Active Module Graph Three review findings. Package self-references always selected the require condition, so the ESM build's lazy providers came from dist/cjs with their own LangChain class identities — instanceof checks and Langfuse usage normalization would silently miss. The seam now loads format-matched siblings: .cjs neighbors from the CJS build and .mjs neighbors from the ESM build via require(esm), safe on the declared Node >=24 engine; the openai instanceof guard in run.ts resolves the package's own module, matching what the registry constructs, in both formats. Verified: the registry-resolved class is identical to each dist's own module export. Source-mode commands get an explicit path instead of a broken implicit one: bridging CJS require into an actively-evaluating ESM source graph both trips ERR_REQUIRE_CYCLE_MODULE and would split identities, so @/llm/providers.eager imports every lazily loadable module through the active loader and registers it with the seam; the cli entrypoints import it first, and an unregistered source-mode load now fails with an actionable message rather than resolving stale dist output. For the record, start:cli fails identically on main today — resolving @mistralai/mistralai through the eager import this branch removes — so no working source flow regresses. typesVersions gains llm/* mappings so moduleResolution node10 consumers resolve the new subpaths. * 🧷 fix: Match Vertex Overrides Across Module Formats The vertex guard's lazily required ChatVertexAI always came from the dependency's require condition, so an ESM consumer's override instance — built from the import condition's distinct constructor — failed the instanceof and every Vertex clientOptions assignment was silently skipped. The guard now walks the override's constructor chain for the lc_name serialization id, which matches both builds of @langchain/google-vertexai while this package's own vertex class reports LibreChatVertexAI and keeps failing the guard exactly as it did under instanceof. Verified behaviorally in both dist formats: ESM and CJS langchain overrides receive the assignments, the sibling class does not, and no third-party module loads for the check. Also unnests the build-extension ternary that failed lint. * 🪺 fix: Guard Without Loading and Pre-Warm Source Runs Two review findings. The openai instanceof guards in init and run loaded the built-in OpenAI module just to conclude an answer, so a host-registered family-openai model paid that entire load — and in source mode would throw — for a check its class could never pass. Both guards now share a structural constructor-chain walk on the lc_name serialization ids: only this package's ChatOpenAI/AzureChatOpenAI declare LibreChatOpenAI/LibreChatAzureOpenAI, subclasses keep them in the chain, and upstream @langchain/openai classes never carry them. Verified instanceof-equivalent across all eight relevant classes in both dist formats (including the faithful DeepSeek/XAI exclusions), with zero module loading; the vertex guard reuses the same walker. Source-mode registration no longer depends on each entrypoint remembering an import: Run.create awaits the eager provider module when the package runs from TypeScript source, which every live script funnels through, and the built package skips the branch entirely — verified that no provider module loads for a built-mode host-family model. The cli entrypoint imports are gone with the requirement. * 🔥 fix: Bootstrap the Direct-Init Probe for Source Runs context-overflow-probe.ts is the one script that calls initializeModel directly instead of funneling through Run.create, so the async source-mode prewarm never runs for it. Model initialization is synchronous, which is exactly why the seam exists — a sync path cannot await the active loader — so direct callers bootstrap explicitly: the probe imports the eager provider module up front, and the seam's error message remains the actionable backstop for any future direct caller.
* perf: establish log-first message projection baseline * feat: observe provider message projection provenance
* feat: track subagent control receipts * feat: expose control receipt transition seam * fix: isolate control receipt projections
* perf: compact closed tools within long turns * fix: preserve compaction replay boundaries * fix: keep native tool results in their turn * fix(compaction): validate provider tool pair boundaries * docs(compaction): record selection overhead * fix(compaction): preserve fallback checkpoint semantics
* ⚡ perf: Keep History Message Identity Across Turn Formatting Two per-turn passes redid full-history work whose output was identical to their input's, and the second one silently defeated an earlier optimization. formatContentStrings cloned every text-only history message on legacy-content providers each turn — and because the clone replaced the object the pressure meter had baselined, the meter's identity fast path from the count-reuse work never matched, so the whole history was re-tokenized (twice) per turn despite host-supplied counts. formatAgentMessages now takes a legacyContent option: hosts whose provider uses legacy string content get flattenable text emitted as the joined string at construction, through the same helper the projection uses, so the per-request pass finds nothing to convert and every message keeps its identity. Hosts that do not opt in are byte-identical to before. Provenance stamping paid two hardened descriptor-walk copies per message per turn on messages format.ts had just constructed itself. setFreshProviderMessageProvenance shares the hardened path's normalization and registration but publishes with plain spreads — same end state, verified by equality tests — and is documented as valid only for locally constructed messages; every external seam keeps the hardened variant. Measured on the LibreChat runtime bench (fake model, 1000-message history, exact 30-turn CPU profile windows): busy CPU 54.7 to 39.9 ms/turn, message-machinery 9.0 to 2.5, tokenizer 2.2 to 0.08, GC 3.5 to 1.9. A 1000-message turn now costs what a 300-message turn did before. * 🧹 fix: Flatten at Emission and Keep Concrete Kwargs Types Three review findings. The legacy flatten ran as a closing rescan over the completed result — an avoidable extra O(history) pass — so it now runs inside the emission choke point every formatted message already passes through; the summary boundary slices payload entries before formatting and nothing mutates an emitted message's content afterwards, so emission-time and return-time flattening are equivalent. The fresh provenance publisher dropped its Record casts for the domain kwargs type and BaseMessage's own lc_kwargs field type, and the test fixture satisfies TPayload directly instead of asserting through unknown.
| Back | FazBrowse Home | New Git URL |
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )