"""Unit tests for agent initialization.""" import os from unittest.mock import patch import main class TestAgentInitialization: @patch.dict(os.environ, {"OPENAI_API_KEY": "test-key"}) def test_agent_has_all_four_tools(self): """Agent should be initialized with all four file system tools.""" agent = main.create_agent() # The agent's tools are accessible via the graph's nodes # create_agent stores tools in the agent; we can check # by inspecting the tool names from the agent's tool node. tool_node = agent.nodes.get("tools") assert tool_node is not None, "Agent should have a 'tools' node" # The actual ToolNode is wrapped in a PregelNode; access via .bound tool_names = list(tool_node.bound.tools_by_name.keys()) expected = {"read_file", "grep", "write_file", "list_dir", "replace_in_file"} assert set(tool_names) == expected, ( f"Expected tools {expected}, got {set(tool_names)}" )