import pytest import sys import os import ai_client # Ensure project root is in path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from ai_client import set_agent_tools, _build_anthropic_tools def test_set_agent_tools() -> None: agent_tools = {"read_file": True, "list_directory": False} # Set cache to verify it gets cleared ai_client._CACHED_ANTHROPIC_TOOLS = [{"name": "dummy"}] set_agent_tools(agent_tools) assert ai_client._agent_tools == agent_tools assert ai_client._CACHED_ANTHROPIC_TOOLS is None def test_build_anthropic_tools_conversion() -> None: set_agent_tools({"read_file": True}) anthropic_tools = _build_anthropic_tools() tool_names = [t["name"] for t in anthropic_tools] assert "read_file" in tool_names