mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
🧹 chore: Optimize provisioning — single credential load, deferred DB writes
- Fix initialize.ts: guard provisionWarnings access with null check (tests don't mock primeResources warnings field) - Fix resources.test.ts: update 4 assertions from toBeUndefined() to toEqual([]) — primeResources now always returns an array for attachments which is more consistent and avoids null checks downstream
This commit is contained in:
parent
ebbcd9c674
commit
455d377600
2 changed files with 7 additions and 6 deletions
|
|
@ -481,7 +481,8 @@ export async function initializeAgent(
|
|||
useLegacyContent: !!options.useLegacyContent,
|
||||
tools: (tools ?? []) as GenericTool[] & string[],
|
||||
maxToolResultChars: maxToolResultCharsResolved,
|
||||
provisionWarnings: provisionWarnings.length > 0 ? provisionWarnings : undefined,
|
||||
provisionWarnings:
|
||||
provisionWarnings != null && provisionWarnings.length > 0 ? provisionWarnings : undefined,
|
||||
maxContextTokens:
|
||||
maxContextTokens != null && maxContextTokens > 0
|
||||
? maxContextTokens
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ describe('primeResources', () => {
|
|||
});
|
||||
|
||||
expect(mockGetFiles).not.toHaveBeenCalled();
|
||||
expect(result.attachments).toBeUndefined();
|
||||
expect(result.attachments).toEqual([]);
|
||||
expect(result.tool_resources).toEqual(tool_resources);
|
||||
});
|
||||
});
|
||||
|
|
@ -1334,7 +1334,7 @@ describe('primeResources', () => {
|
|||
role: 'USER',
|
||||
agentId: 'agent_shared',
|
||||
});
|
||||
expect(result.attachments).toBeUndefined();
|
||||
expect(result.attachments).toEqual([]);
|
||||
});
|
||||
|
||||
it('should skip filtering when filterFiles is not provided', async () => {
|
||||
|
|
@ -1502,8 +1502,8 @@ describe('primeResources', () => {
|
|||
|
||||
expect(mockGetFiles).not.toHaveBeenCalled();
|
||||
// When appConfig agents endpoint is missing, context is disabled
|
||||
// and no attachments are provided, the function returns undefined
|
||||
expect(result.attachments).toBeUndefined();
|
||||
// and no attachments are provided, the function returns an empty array
|
||||
expect(result.attachments).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle undefined tool_resources', async () => {
|
||||
|
|
@ -1517,7 +1517,7 @@ describe('primeResources', () => {
|
|||
});
|
||||
|
||||
expect(result.tool_resources).toEqual({});
|
||||
expect(result.attachments).toBeUndefined();
|
||||
expect(result.attachments).toEqual([]);
|
||||
});
|
||||
|
||||
it('should handle empty requestFileSet', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue