Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions scripts/langchain/followup_issue_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,19 +908,22 @@ def _parse_checklist(lines: list[str]) -> list[str]:
def _get_llm_client(reasoning: bool = False) -> tuple[Any, str] | None:
"""Get LLM client using slot order with optional reasoning model override."""
try:
from tools.langchain_client import build_chat_client
from scripts.langchain._llm_client import build_client
except ImportError as e:
print(f"Warning: langchain_client not available: {e}", file=sys.stderr)
return None
try:
from _llm_client import build_client
except ImportError:
print(f"Warning: shared LLM client adapter not available: {e}", file=sys.stderr)
return None

if reasoning:
model = os.environ.get("FOLLOWUP_REASONING_MODEL", "o3-mini")
resolved = build_chat_client(model=model, provider="openai")
resolved = build_client(model=model, provider="openai")
if not resolved:
resolved = build_chat_client()
resolved = build_client()
else:
model = os.environ.get("FOLLOWUP_MODEL", "gpt-5.4")
resolved = build_chat_client(model=model)
resolved = build_client(model=model)

if not resolved:
print("Warning: No LLM API keys found", file=sys.stderr)
Expand Down
9 changes: 6 additions & 3 deletions scripts/langchain/progress_reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,14 @@ def review_progress_with_llm(
rounds_without_completion,
)
try:
from tools.langchain_client import build_chat_client
from scripts.langchain._llm_client import build_client
except ImportError:
build_chat_client = None
try:
from _llm_client import build_client
except ImportError:
build_client = None

resolved = build_chat_client(model=model) if build_chat_client else None
resolved = build_client(model=model) if build_client else None
if not resolved:
score, aligned, unaligned = heuristic_alignment_check(
acceptance_criteria, recent_commits, files_changed
Expand Down
15 changes: 15 additions & 0 deletions tests/tools/test_llm_client_single_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,18 @@ def fake_build_chat_client(**kwargs: object) -> object:
"force_openai": False,
}
]


def test_scripts_do_not_bypass_shared_llm_client_adapter() -> None:
for path in (REPO_ROOT / "scripts").rglob("*.py"):
if path.as_posix().endswith("scripts/langchain/_llm_client.py"):
continue
source = path.read_text(encoding="utf-8")
tree = ast.parse(source, filename=path.as_posix())
for node in ast.walk(tree):
if (
isinstance(node, ast.ImportFrom)
and node.module == "tools.langchain_client"
and any(alias.name == "build_chat_client" for alias in node.names)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
):
Comment thread
stranske marked this conversation as resolved.
raise AssertionError(path.relative_to(REPO_ROOT).as_posix())
Loading