diff --git a/packages/api/src/agents/initialize.ts b/packages/api/src/agents/initialize.ts index e5f78ec5e6..be81f4fef9 100644 --- a/packages/api/src/agents/initialize.ts +++ b/packages/api/src/agents/initialize.ts @@ -1338,7 +1338,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 diff --git a/packages/api/src/agents/resources.test.ts b/packages/api/src/agents/resources.test.ts index 04849a5177..75b9bab471 100644 --- a/packages/api/src/agents/resources.test.ts +++ b/packages/api/src/agents/resources.test.ts @@ -110,7 +110,7 @@ describe('primeResources', () => { }); expect(mockGetFiles).not.toHaveBeenCalled(); - expect(result.attachments).toBeUndefined(); + expect(result.attachments).toEqual([]); expect(result.tool_resources).toEqual(tool_resources); }); }); @@ -1342,7 +1342,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 () => { @@ -1510,8 +1510,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 () => { @@ -1525,7 +1525,7 @@ describe('primeResources', () => { }); expect(result.tool_resources).toEqual({}); - expect(result.attachments).toBeUndefined(); + expect(result.attachments).toEqual([]); }); it('should handle empty requestFileSet', async () => {