MCPcopy Index your code
hub / github.com/codeaashu/claude-code / call

Function call

src/tools/WebSearchTool/WebSearchTool.ts:254–400  ·  view source on GitHub ↗
(input, context, _canUseTool, _parentMessage, onProgress)

Source from the content-addressed store, hash-verified

252 return { result: true }
253 },
254 async call(input, context, _canUseTool, _parentMessage, onProgress) {
255 const startTime = performance.now()
256 const { query } = input
257 const userMessage = createUserMessage({
258 content: 'Perform a web search for the query: ' + query,
259 })
260 const toolSchema = makeToolSchema(input)
261
262 const useHaiku = getFeatureValue_CACHED_MAY_BE_STALE(
263 'tengu_plum_vx3',
264 false,
265 )
266
267 const appState = context.getAppState()
268 const queryStream = queryModelWithStreaming({
269 messages: [userMessage],
270 systemPrompt: asSystemPrompt([
271 'You are an assistant for performing a web search tool use',
272 ]),
273 thinkingConfig: useHaiku
274 ? { type: 'disabled' as const }
275 : context.options.thinkingConfig,
276 tools: [],
277 signal: context.abortController.signal,
278 options: {
279 getToolPermissionContext: async () => appState.toolPermissionContext,
280 model: useHaiku ? getSmallFastModel() : context.options.mainLoopModel,
281 toolChoice: useHaiku ? { type: 'tool', name: 'web_search' } : undefined,
282 isNonInteractiveSession: context.options.isNonInteractiveSession,
283 hasAppendSystemPrompt: !!context.options.appendSystemPrompt,
284 extraToolSchemas: [toolSchema],
285 querySource: 'web_search_tool',
286 agents: context.options.agentDefinitions.activeAgents,
287 mcpTools: [],
288 agentId: context.agentId,
289 effortValue: appState.effortValue,
290 },
291 })
292
293 const allContentBlocks: BetaContentBlock[] = []
294 let currentToolUseId = null
295 let currentToolUseJson = ''
296 let progressCounter = 0
297 const toolUseQueries = new Map() // Map of tool_use_id to query
298
299 for await (const event of queryStream) {
300 if (event.type === 'assistant') {
301 allContentBlocks.push(...event.message.content)
302 continue
303 }
304
305 // Track tool use ID when server_tool_use starts
306 if (
307 event.type === 'stream_event' &&
308 event.event?.type === 'content_block_start'
309 ) {
310 const contentBlock = event.event.content_block
311 if (contentBlock && contentBlock.type === 'server_tool_use') {

Callers

nothing calls this directly

Calls 13

createUserMessageFunction · 0.85
makeToolSchemaFunction · 0.85
queryModelWithStreamingFunction · 0.85
asSystemPromptFunction · 0.85
getSmallFastModelFunction · 0.85
jsonParseFunction · 0.85
getMethod · 0.65
onProgressFunction · 0.50
pushMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected