feat: enhance websearch functionality with reasoning-based approach

- Changed use_websearch default from False to True for all tools
- Redesigned websearch behavior to focus on reasoning rather than direct search
- Tools now analyze when web searches would be helpful and recommend specific searches
- Updated all tool-specific websearch instructions to be more thoughtful
- Gemini will now suggest what Claude should search for and explain why

Key improvements:
- Web search is now enabled by default for better documentation awareness
- Instead of performing searches, Gemini reasons about what searches would help
- Provides specific search recommendations for Claude to execute
- More collaborative approach between Gemini and Claude

This change makes the tools more intelligent about when external information
would be valuable while keeping Claude in control of actual web searches.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Fahad
2025-06-10 12:45:57 +04:00
parent ba8f7192c3
commit 3d958ef7e9
7 changed files with 33 additions and 21 deletions

View File

@@ -86,7 +86,7 @@ class AnalyzeTool(BaseTool):
"use_websearch": {
"type": "boolean",
"description": "Enable web search for documentation, best practices, and current information. Particularly useful for: brainstorming sessions, architectural design discussions, exploring industry best practices, working with specific frameworks/technologies, researching solutions to complex problems, or when current documentation and community insights would enhance the analysis.",
"default": False,
"default": True,
},
},
"required": ["files", "question"],
@@ -157,7 +157,7 @@ class AnalyzeTool(BaseTool):
# Add web search instruction if enabled
websearch_instruction = self.get_websearch_instruction(
request.use_websearch,
"""Specifically search for:
"""When analyzing code, consider if searches for these would help:
- Documentation for technologies or frameworks found in the code
- Best practices and design patterns relevant to the analysis
- API references and usage examples

View File

@@ -165,18 +165,30 @@ class BaseTool(ABC):
base_instruction = """
WEB SEARCH ENABLED: Feel free to perform appropriate web searches to enhance your analysis."""
WEB SEARCH REASONING: As you analyze this request, consider whether web searches would enhance your response.
If you identify areas where current documentation, API references, or community solutions would be valuable,
please note in your response what specific searches Claude should perform and why they would be helpful."""
if tool_specific:
return f"{base_instruction} {tool_specific}"
return f"{base_instruction}
{tool_specific}
In your response, if web searches would be beneficial, include a section like:
**Recommended Web Searches for Claude:**
- [Specific topic/framework/library] - to verify/understand/confirm [specific aspect]
- [Another search topic] - to explore [specific concern or feature]"""
# Default instruction for all tools
return f"""{base_instruction} Search for:
return f"""{base_instruction}
Consider searches for:
- Current documentation and best practices
- Similar issues and community solutions
- Similar issues and community solutions
- API references and usage examples
- Recent developments and updates
Consider relevant findings when formulating your response."""
If any of these would strengthen your analysis, specify what Claude should search for and why."""
@abstractmethod
def get_request_model(self):

View File

@@ -71,7 +71,7 @@ class ChatTool(BaseTool):
"use_websearch": {
"type": "boolean",
"description": "Enable web search for documentation, best practices, and current information. Particularly useful for: brainstorming sessions, architectural design discussions, exploring industry best practices, working with specific frameworks/technologies, researching solutions to complex problems, or when current documentation and community insights would enhance the analysis.",
"default": False,
"default": True,
},
},
"required": ["prompt"],
@@ -123,7 +123,7 @@ class ChatTool(BaseTool):
# Add web search instruction if enabled
websearch_instruction = self.get_websearch_instruction(
request.use_websearch,
"""Specifically search for:
"""When discussing topics, consider if searches for these would help:
- Documentation for any technologies or concepts mentioned
- Current best practices and patterns
- Recent developments or updates

View File

@@ -124,7 +124,7 @@ class CodeReviewTool(BaseTool):
"use_websearch": {
"type": "boolean",
"description": "Enable web search for documentation, best practices, and current information. Particularly useful for: brainstorming sessions, architectural design discussions, exploring industry best practices, working with specific frameworks/technologies, researching solutions to complex problems, or when current documentation and community insights would enhance the analysis.",
"default": False,
"default": True,
},
},
"required": ["files", "context"],
@@ -213,7 +213,7 @@ class CodeReviewTool(BaseTool):
# Add web search instruction if enabled
websearch_instruction = self.get_websearch_instruction(
request.use_websearch,
"""Specifically search for:
"""When reviewing code, consider if searches for these would help:
- Security vulnerabilities and CVEs for libraries/frameworks used
- Best practices for the languages and frameworks in the code
- Common anti-patterns and their solutions

View File

@@ -89,7 +89,7 @@ class DebugIssueTool(BaseTool):
"use_websearch": {
"type": "boolean",
"description": "Enable web search for documentation, best practices, and current information. Particularly useful for: brainstorming sessions, architectural design discussions, exploring industry best practices, working with specific frameworks/technologies, researching solutions to complex problems, or when current documentation and community insights would enhance the analysis.",
"default": False,
"default": True,
},
},
"required": ["error_description"],
@@ -166,7 +166,7 @@ class DebugIssueTool(BaseTool):
# Add web search instruction if enabled
websearch_instruction = self.get_websearch_instruction(
request.use_websearch,
"""Specifically search for:
"""When debugging issues, consider if searches for these would help:
- The exact error message to find known solutions
- Framework-specific error codes and their meanings
- Similar issues in forums, GitHub issues, or Stack Overflow

View File

@@ -98,7 +98,7 @@ class Precommit(BaseTool):
schema["properties"]["use_websearch"] = {
"type": "boolean",
"description": "Enable web search for documentation, best practices, and current information. Particularly useful for: brainstorming sessions, architectural design discussions, exploring industry best practices, working with specific frameworks/technologies, researching solutions to complex problems, or when current documentation and community insights would enhance the analysis.",
"default": False,
"default": True,
}
return schema
@@ -380,7 +380,7 @@ class Precommit(BaseTool):
# Add web search instruction if enabled
websearch_instruction = self.get_websearch_instruction(
request.use_websearch,
"""Specifically search for:
"""When validating changes, consider if searches for these would help:
- Best practices for new features or patterns introduced
- Security implications of the changes
- Known issues with libraries or APIs being used

View File

@@ -85,7 +85,7 @@ class ThinkDeepTool(BaseTool):
"use_websearch": {
"type": "boolean",
"description": "Enable web search for documentation, best practices, and current information. Particularly useful for: brainstorming sessions, architectural design discussions, exploring industry best practices, working with specific frameworks/technologies, researching solutions to complex problems, or when current documentation and community insights would enhance the analysis.",
"default": False,
"default": True,
},
},
"required": ["current_analysis"],
@@ -155,11 +155,11 @@ class ThinkDeepTool(BaseTool):
# Add web search instruction if enabled
websearch_instruction = self.get_websearch_instruction(
request.use_websearch,
"""Specifically search for:
- Current documentation for technologies, frameworks, or APIs being discussed
- Similar issues and their solutions from the community
- Best practices and recent developments
- Official sources to verify information""",
"""When analyzing complex problems, consider if searches for these would help:
- Current documentation for specific technologies, frameworks, or APIs mentioned
- Known issues, workarounds, or community solutions for similar problems
- Recent updates, deprecations, or best practices that might affect the approach
- Official sources to verify assumptions or clarify technical details""",
)
# Combine system prompt with context