mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-14 12:48:03 +00:00
fix(chat): require explicit web search enable
This commit is contained in:
@@ -16,6 +16,39 @@ GUIDE_ONLY_DIRECTIVE = (
|
||||
"output they will produce locally."
|
||||
)
|
||||
|
||||
WEB_TOOL_NAMES = frozenset({"web_search", "web_fetch"})
|
||||
|
||||
|
||||
def tool_toggle_enabled(value: object) -> bool:
|
||||
"""Return true only for explicit true-like tool toggle values."""
|
||||
|
||||
return str(value).lower() == "true"
|
||||
|
||||
|
||||
def tool_toggle_explicitly_denied(value: object) -> bool:
|
||||
"""Return true when a caller explicitly supplied a non-true toggle value."""
|
||||
|
||||
return value is not None and not tool_toggle_enabled(value)
|
||||
|
||||
|
||||
def is_web_search_explicitly_denied(allow_web_search: object) -> bool:
|
||||
"""Whether the web-search agent toggle was explicitly set to false."""
|
||||
|
||||
return tool_toggle_explicitly_denied(allow_web_search)
|
||||
|
||||
|
||||
def web_search_enabled_for_turn(allow_web_search: object, use_web: object = None) -> bool:
|
||||
"""Return true only when this request explicitly enables web search.
|
||||
|
||||
Agent mode sends ``allow_web_search``; chat-mode pre-search sends
|
||||
``use_web``. If both are present, an explicit ``allow_web_search=false``
|
||||
wins so a stale or conflicting intent path cannot re-enable web tools.
|
||||
"""
|
||||
|
||||
if is_web_search_explicitly_denied(allow_web_search):
|
||||
return False
|
||||
return tool_toggle_enabled(allow_web_search) or tool_toggle_enabled(use_web)
|
||||
|
||||
|
||||
_COMMON_TOOL_NAMES = {
|
||||
"api_call",
|
||||
|
||||
Reference in New Issue
Block a user