fix: ensure researcher agent uses web search tool instead of generating URLs (#702) (#704)

* fix: ensure researcher agent uses web search tool instead of generating URLs (#702)

- Add enforce_researcher_search configuration option (default: True) to control web search requirement
- Strengthen researcher prompts in both English and Chinese with explicit instructions to use web_search tool
- Implement validate_web_search_usage function to detect if web search tool was used during research
- Add validation logic that warns when researcher doesn't use web search tool
- Enhance logging for web search tools with special markers for easy tracking
- Skip validation during unit tests to avoid test failures
- Update _execute_agent_step to accept config parameter for proper configuration access

This addresses issue #702 where the researcher agent was generating URLs on its own instead of using the web search tool.

* fix: addressed the code review comment

* fix the unit test error and update the code
This commit is contained in:
Willem Jiang
2025-11-24 20:07:28 +08:00
committed by GitHub
parent cc9414f978
commit 478291df07
6 changed files with 84 additions and 11 deletions
+4 -1
View File
@@ -37,7 +37,8 @@ You have access to two types of tools:
3. **Plan the Solution**: Determine the best approach to solve the problem using the available tools.
4. **Execute the Solution**:
- Forget your previous knowledge, so you **should leverage the tools** to retrieve the information.
- Use the {% if resources %}**local_search_tool** or{% endif %}**web_search** or other suitable search tool to perform a search with the provided keywords.
- **CRITICAL**: You MUST use the {% if resources %}**local_search_tool** or{% endif %}**web_search** tool to search for information. NEVER generate URLs on your own. All URLs must come from tool results.
- **MANDATORY**: Always perform at least one web search using the **web_search** tool at the beginning of your research. This is not optional.
- When the task includes time range requirements:
- Incorporate appropriate time-based search parameters in your queries (e.g., "after:2020", "before:2023", or specific date ranges)
- Ensure search results respect the specified time constraints.
@@ -71,6 +72,8 @@ You have access to two types of tools:
# Notes
- **CRITICAL**: NEVER generate URLs on your own. All URLs must come from search tool results. This is a mandatory requirement.
- **MANDATORY**: Always start with a web search. Do not rely on your internal knowledge.
- Always verify the relevance and credibility of the information gathered.
- If no URL is provided, focus solely on the search results.
- Never do any math or any file operations.