📐 test: Guard Web Search Description Length (#14044)

* test: Guard web search description length

* test: Check registered web search description

* style: Format web search description assertion
This commit is contained in:
Danny Avila 2026-07-01 10:42:53 -04:00 • committed by GitHub
parent e88f7a8f19
commit f5c64a4d6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
import { Providers } from '@librechat/agents';
import { Providers, WebSearchToolDefinition } from '@librechat/agents';
import type {
LoadToolDefinitionsParams,
LoadToolDefinitionsDeps,
@ -8,6 +8,8 @@ import { toolkitExpansion, toolkitParent } from './toolkits/mapping';
import { getToolDefinition } from './registry/definitions';
import { loadToolDefinitions } from './definitions';
const MAX_PROVIDER_TOOL_DESCRIPTION_LENGTH = 1024;
describe('definitions.ts', () => {
const mockGetOrFetchMCPServerTools = jest.fn().mockResolvedValue(null);
const mockIsBuiltInTool = jest.fn().mockReturnValue(false);
@ -16,6 +18,18 @@ describe('definitions.ts', () => {
jest.clearAllMocks();
});
it('keeps the registered web_search description within common API limits', () => {
const definition = getToolDefinition(WebSearchToolDefinition.name);
if (definition == null) {
throw new Error('Expected web_search tool definition to be registered');
}
expect(definition.description).toBe(WebSearchToolDefinition.description);
expect(definition.description).toMatch(/search/i);
expect(definition.description.length).toBeLessThanOrEqual(MAX_PROVIDER_TOOL_DESCRIPTION_LENGTH);
});
describe('loadToolDefinitions', () => {
it('should return empty result for empty tools array', async () => {
const params: LoadToolDefinitionsParams = {