Skip to content

Commit 2b8e6ed

Browse files
refactor: align react_agent conftest with standard load_golden pattern (#109)
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) <noreply@anthropic.com>
1 parent 33cc35f commit 2b8e6ed

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

agents/langgraph/react_agent/tests/behavioral/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import httpx
1414
import pytest
1515
import yaml
16+
from harness.fixtures import load_golden as _load_golden_from
1617
from harness.runner import TaskConfig, TaskResult, run_task
1718

1819
try:
@@ -39,6 +40,14 @@ def _find_repo_root() -> Path:
3940
)
4041

4142

43+
FIXTURES_DIR = Path(__file__).parent / "fixtures"
44+
45+
46+
def load_golden(category: str | None = None) -> list[dict[str, Any]]:
47+
"""Load golden queries from the fixtures directory, optionally filtering by category."""
48+
return _load_golden_from(FIXTURES_DIR, category)
49+
50+
4251
@pytest.fixture
4352
def agent_url() -> str:
4453
"""React agent URL from REACT_AGENT_URL env var or default localhost:8000."""

agents/langgraph/react_agent/tests/behavioral/test_tool_usage.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
from __future__ import annotations
1717

1818
import warnings
19-
from pathlib import Path
2019
from typing import Any
2120

2221
import pytest
23-
from harness.fixtures import load_golden as _load_golden_from
22+
from conftest import load_golden
2423
from harness.scorers.tool_sequence import (
2524
score_hallucinated_tools,
2625
score_tool_call_validity,
@@ -29,17 +28,10 @@
2928

3029
pytestmark = pytest.mark.langgraph_react
3130

32-
FIXTURES_DIR = Path(__file__).parent / "fixtures"
33-
34-
35-
def _load_golden(category: str | None = None) -> list[dict[str, Any]]:
36-
"""Load golden queries, optionally filtering by category."""
37-
return _load_golden_from(FIXTURES_DIR, category)
38-
3931

4032
def _factual_queries() -> list[dict[str, Any]]:
4133
"""Return golden queries that should trigger tool calls."""
42-
return [q for q in _load_golden() if q.get("expected_tools")]
34+
return [q for q in load_golden() if q.get("expected_tools")]
4335

4436

4537
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)