refactor(core): migrate web search tool to tool-names (#10782)

This commit is contained in:
Abhi
2025-10-10 15:51:24 -04:00
committed by GitHub
parent 0a7ee67707
commit ab3804d823
4 changed files with 13 additions and 11 deletions
+7 -6
View File
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { WEB_SEARCH_TOOL_NAME } from '../packages/core/src/tools/tool-names.js';
import { describe, it, expect } from 'vitest';
import { TestRig, printDebugInfo, validateModelOutput } from './test-helper.js';
describe('google_web_search', () => {
describe(WEB_SEARCH_TOOL_NAME, () => {
it('should be able to search the web', async () => {
const rig = new TestRig();
await rig.setup('should be able to search the web');
@@ -30,7 +31,7 @@ describe('google_web_search', () => {
throw error; // Re-throw if not a network error
}
const foundToolCall = await rig.waitForToolCall('google_web_search');
const foundToolCall = await rig.waitForToolCall(WEB_SEARCH_TOOL_NAME);
// Add debugging information
if (!foundToolCall) {
@@ -39,11 +40,11 @@ describe('google_web_search', () => {
// Check if the tool call failed due to network issues
const failedSearchCalls = allTools.filter(
(t) =>
t.toolRequest.name === 'google_web_search' && !t.toolRequest.success,
t.toolRequest.name === WEB_SEARCH_TOOL_NAME && !t.toolRequest.success,
);
if (failedSearchCalls.length > 0) {
console.warn(
'google_web_search tool was called but failed, possibly due to network issues',
`${WEB_SEARCH_TOOL_NAME} tool was called but failed, possibly due to network issues`,
);
console.warn(
'Failed calls:',
@@ -55,7 +56,7 @@ describe('google_web_search', () => {
expect(
foundToolCall,
'Expected to find a call to google_web_search',
`Expected to find a call to ${WEB_SEARCH_TOOL_NAME}`,
).toBeTruthy();
// Validate model output - will throw if no output, warn if missing expected content
@@ -69,7 +70,7 @@ describe('google_web_search', () => {
if (!hasExpectedContent) {
const searchCalls = rig
.readToolLogs()
.filter((t) => t.toolRequest.name === 'google_web_search');
.filter((t) => t.toolRequest.name === WEB_SEARCH_TOOL_NAME);
if (searchCalls.length > 0) {
console.warn(
'Search queries used:',