feat: add proper BuiltinTool support for both websearch providers

- Add web_search to BuiltinTool enum for consistency with brave_search
- Add WEB_SEARCH_BRAVE_TOOL constant following existing patterns
- Update agent logic to properly map both websearch tools:
  * web_search → BuiltinTool.web_search → WEB_SEARCH_TOOL → Tavily
  * web_search_brave → BuiltinTool.brave_search → WEB_SEARCH_BRAVE_TOOL → Brave
- Add tool encoding support for BuiltinTool.web_search in Llama model
- Replace hardcoded strings with constants for maintainability
- Fix tool conflicts that caused non-deterministic provider selection

This resolves the architectural issues where both websearch providers
exposed the same tool name, causing unpredictable behavior and making
it impossible for users to reliably choose their preferred provider.

Fixes #2606
This commit is contained in:
skamenan7 2025-07-07 15:41:41 -04:00
parent a0a8b86fc8
commit 533c1323b8
3 changed files with 14 additions and 4 deletions

View file

@ -220,7 +220,10 @@ class ToolUtils:
@staticmethod
def encode_tool_call(t: ToolCall, tool_prompt_format: ToolPromptFormat) -> str:
if t.tool_name == BuiltinTool.brave_search:
if t.tool_name == BuiltinTool.web_search:
q = t.arguments["query"]
return f'web_search.call(query="{q}")'
elif t.tool_name == BuiltinTool.brave_search:
q = t.arguments["query"]
return f'brave_search.call(query="{q}")'
elif t.tool_name == BuiltinTool.wolfram_alpha: