From 6fcb4d148d77da5550e1dbb53a4b674d67fc48fb Mon Sep 17 00:00:00 2001 From: adonheis Date: Wed, 20 May 2026 10:52:53 -0400 Subject: [PATCH] refactor: align react_agent conftest with standard load_golden pattern Move load_golden() wrapper from test_tool_usage.py into conftest.py to match the convention used by agentic_rag, websearch_agent, and mcp_agent. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../react_agent/tests/behavioral/conftest.py | 9 +++++++++ .../react_agent/tests/behavioral/test_tool_usage.py | 12 ++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/agents/langgraph/react_agent/tests/behavioral/conftest.py b/agents/langgraph/react_agent/tests/behavioral/conftest.py index e818d9e..1cf644c 100644 --- a/agents/langgraph/react_agent/tests/behavioral/conftest.py +++ b/agents/langgraph/react_agent/tests/behavioral/conftest.py @@ -13,6 +13,7 @@ import httpx import pytest import yaml +from harness.fixtures import load_golden as _load_golden_from from harness.runner import TaskConfig, TaskResult, run_task try: @@ -39,6 +40,14 @@ def _find_repo_root() -> Path: ) +FIXTURES_DIR = Path(__file__).parent / "fixtures" + + +def load_golden(category: str | None = None) -> list[dict[str, Any]]: + """Load golden queries from the fixtures directory, optionally filtering by category.""" + return _load_golden_from(FIXTURES_DIR, category) + + @pytest.fixture def agent_url() -> str: """React agent URL from REACT_AGENT_URL env var or default localhost:8000.""" diff --git a/agents/langgraph/react_agent/tests/behavioral/test_tool_usage.py b/agents/langgraph/react_agent/tests/behavioral/test_tool_usage.py index 2d26d00..7ef58af 100644 --- a/agents/langgraph/react_agent/tests/behavioral/test_tool_usage.py +++ b/agents/langgraph/react_agent/tests/behavioral/test_tool_usage.py @@ -16,11 +16,10 @@ from __future__ import annotations import warnings -from pathlib import Path from typing import Any import pytest -from harness.fixtures import load_golden as _load_golden_from +from conftest import load_golden from harness.scorers.tool_sequence import ( score_hallucinated_tools, score_tool_call_validity, @@ -29,17 +28,10 @@ pytestmark = pytest.mark.langgraph_react -FIXTURES_DIR = Path(__file__).parent / "fixtures" - - -def _load_golden(category: str | None = None) -> list[dict[str, Any]]: - """Load golden queries, optionally filtering by category.""" - return _load_golden_from(FIXTURES_DIR, category) - def _factual_queries() -> list[dict[str, Any]]: """Return golden queries that should trigger tool calls.""" - return [q for q in _load_golden() if q.get("expected_tools")] + return [q for q in load_golden() if q.get("expected_tools")] @pytest.mark.parametrize(