mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-10-20 17:13:44 +00:00
📐 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:
parent
e88f7a8f19
commit
f5c64a4d6d
1 changed files with 15 additions and 1 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue