Fixed web-search prompt, models can prompt claude to perform web searches on their behalf if and as needed

This commit is contained in:
Fahad
2025-06-12 20:05:55 +04:00
parent 4f2763689b
commit b34c63d710
2 changed files with 31 additions and 35 deletions

View File

@@ -390,7 +390,7 @@ Use zen and perform a thorough precommit ensuring there aren't any new regressio
- Supports specialized analysis types: architecture, performance, security, quality
- Uses file paths (not content) for clean terminal output
- Can identify patterns, anti-patterns, and refactoring opportunities
- **Web search capability**: When enabled with `use_websearch`, can look up framework documentation, design patterns, and best practices relevant to the code being analyzed
- **Web search capability**: When enabled with `use_websearch`, the model can request Claude to perform web searches and share results back to enhance analysis with current documentation, design patterns, and best practices
### 7. `get_version` - Server Information
```
"Get zen to show its version"
@@ -409,7 +409,7 @@ All tools that work with files support **both individual files and entire direct
- `analysis_type`: architecture|performance|security|quality|general
- `output_format`: summary|detailed|actionable
- `thinking_mode`: minimal|low|medium|high|max (default: medium, Gemini only)
- `use_websearch`: Enable web search for documentation and best practices (default: false)
- `use_websearch`: Enable web search for documentation and best practices - allows model to request Claude perform searches (default: true)
```
"Analyze the src/ directory for architectural patterns" (auto mode picks best model)
@@ -442,7 +442,7 @@ All tools that work with files support **both individual files and entire direct
- `runtime_info`: Environment details
- `previous_attempts`: What you've tried
- `thinking_mode`: minimal|low|medium|high|max (default: medium, Gemini only)
- `use_websearch`: Enable web search for error messages and solutions (default: false)
- `use_websearch`: Enable web search for error messages and solutions - allows model to request Claude perform searches (default: true)
```
"Debug this logic error with context from backend/" (auto mode picks best model)
@@ -457,7 +457,7 @@ All tools that work with files support **both individual files and entire direct
- `focus_areas`: Specific aspects to focus on
- `files`: Files or directories for context
- `thinking_mode`: minimal|low|medium|high|max (default: max, Gemini only)
- `use_websearch`: Enable web search for documentation and insights (default: false)
- `use_websearch`: Enable web search for documentation and insights - allows model to request Claude perform searches (default: true)
```
"Think deeper about my design with reference to src/models/" (auto mode picks best model)
@@ -705,25 +705,12 @@ Claude can then search for these specific topics and provide you with the most c
- More collaborative approach between the two AI assistants
- Reduces hallucination by encouraging verification of assumptions
**Disabling web search:**
If you prefer Gemini to work only with its training data, you can disable web search:
**Web search control:**
Web search is enabled by default, allowing models to request Claude perform searches for current documentation and solutions. If you prefer the model to work only with its training data, you can disable web search:
```
"Use gemini to review this code with use_websearch false"
```
### Standardized Response Format
All tools now return structured JSON responses for consistent handling:
```json
{
"status": "success|error|requires_clarification",
"content": "The actual response content",
"content_type": "text|markdown|json",
"metadata": {"tool_name": "analyze", ...}
}
```
This enables better integration, error handling, and support for the dynamic context request feature.
## Configuration
The server includes several configurable properties that control its behavior:

View File

@@ -60,8 +60,8 @@ class ToolRequest(BaseModel):
description="Thinking depth: minimal (128), low (2048), medium (8192), high (16384), max (32768)",
)
use_websearch: Optional[bool] = Field(
False,
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.",
True,
description="Enable web search for documentation, best practices, and current information. When enabled, the model can request Claude to perform web searches and share results back during conversations. 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.",
)
continuation_id: Optional[str] = Field(
None,
@@ -473,7 +473,7 @@ class BaseTool(ABC):
def get_websearch_instruction(self, use_websearch: bool, tool_specific: Optional[str] = None) -> str:
"""
Generate web search instruction based on the use_websearch parameter.
Generate standardized web search instruction based on the use_websearch parameter.
Args:
use_websearch: Whether web search is enabled
@@ -487,30 +487,39 @@ class BaseTool(ABC):
base_instruction = """
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."""
WEB SEARCH CAPABILITY: You can request Claude to perform web searches to enhance your analysis with current information!
IMPORTANT: When you identify areas where web searches would significantly improve your response (such as checking current documentation, finding recent solutions, verifying best practices, or gathering community insights), you MUST explicitly instruct Claude to perform specific web searches and then respond back using the continuation_id from this response to continue the analysis.
Use clear, direct language based on the value of the search:
For valuable supplementary information: "Please perform a web search on '[specific topic/query]' and then continue this analysis using the continuation_id from this response if you find relevant information."
For important missing information: "Please search for '[specific topic/query]' and respond back with the findings using the continuation_id from this response - this information is needed to provide a complete analysis."
For critical/essential information: "SEARCH REQUIRED: Please immediately perform a web search on '[specific topic/query]' and respond back with the results using the continuation_id from this response. Cannot provide accurate analysis without this current information."
This ensures you get the most current and comprehensive information while maintaining conversation context through the continuation_id."""
if 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]"""
When recommending searches, be specific about what information you need and why it would improve your analysis."""
# Default instruction for all tools
return f"""{base_instruction}
Consider searches for:
- Current documentation and best practices
- Similar issues and community solutions
- API references and usage examples
- Recent developments and updates
Consider requesting searches for:
- Current documentation and API references
- Recent best practices and patterns
- Known issues and community solutions
- Framework updates and compatibility
- Security advisories and patches
- Performance benchmarks and optimizations
If any of these would strengthen your analysis, specify what Claude should search for and why."""
When recommending searches, be specific about what information you need and why it would improve your analysis. Always remember to instruct Claude to use the continuation_id from this response when providing search results."""
@abstractmethod
def get_request_model(self):