# tests/evals/test_tool_contracts.py import pytest def test_search_entities_contract(): """ Canary eval: triggers the tool and validates the full cycle. If search_entities changes its interface, this breaks before production does. """ agent_response = run_agent( prompt="Find all company entities named Samsung in the registry.", tools=TOOL_REGISTRY, ) # Check the tool was called tool_calls = extract_tool_calls(agent_response) search_calls = [c for c in tool_calls if c["name"] == "search_entities"] assert len(search_calls) > 0, "Agent did not call search_entities" # Check the call used the current schema for call in search_calls: assert "entity_type" in call["args"], ( "Agent called search_entities without entity_type — " "tool description may be out of sync with schema" ) # Check the response matched expected shape assert agent_response.tool_errors == [], ( f"Tool returned unexpected shape: {agent_response.tool_errors}" )