forked from HAL9000/cleveragents-core
a074b4846f
Remove FakeListLLM as a silent fallback in agent graph constructors (plan_generation.py, context_analysis.py, auto_debug.py). All three now raise ValueError when llm=None, making missing-provider errors explicit. Add Settings.mock_providers flag and validate_provider_availability() method. Update container.get_ai_provider() to check Settings.mock_providers first, with env-var fallback for backward compatibility. Add resolve_provider_by_name() helper to the provider registry and export it from cleveragents.providers. Add structlog trace logging to ProviderRegistry.get_default_provider_type() to record selection reasoning. Update all existing behave step files, robot tests, and benchmarks that relied on the implicit FakeListLLM default to pass an explicit LLM instance instead. Add new BDD tests (features/provider_fixes.feature with 17 scenarios), Robot Framework integration tests (robot/provider_detection_smoke.robot), and ASV benchmarks (benchmarks/provider_selection_bench.py). ISSUES CLOSED: #323
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""Helper utilities for PlanGenerationGraph Robot tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
CURRENT_DIR = Path(__file__).resolve().parent
|
|
PROJECT_ROOT = CURRENT_DIR.parent
|
|
SRC_DIR = PROJECT_ROOT / "src"
|
|
if str(SRC_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SRC_DIR))
|
|
|
|
from langchain_community.llms import FakeListLLM # noqa: E402
|
|
|
|
from cleveragents.agents.plan_generation import PlanGenerationGraph # noqa: E402
|
|
from cleveragents.domain.models.core import Context # noqa: E402
|
|
|
|
|
|
def run_context_summary() -> None:
|
|
"""Generate plan context metadata to validate Robot tests."""
|
|
|
|
graph = PlanGenerationGraph(llm=FakeListLLM(responses=["test response"] * 3))
|
|
with tempfile.NamedTemporaryFile(delete=False, suffix=".py") as tmp:
|
|
tmp.write(b"def main():\n return True\n")
|
|
tmp_path = Path(tmp.name)
|
|
|
|
content = tmp_path.read_text()
|
|
contexts = [Context(plan_id=1, path=str(tmp_path), content=content)]
|
|
try:
|
|
result = graph._load_context({"contexts": contexts})
|
|
assert result["context_summary"], "context_summary should not be empty"
|
|
assert result["context_dependencies"], (
|
|
"context_dependencies should not be empty"
|
|
)
|
|
print("Context analysis summary ready")
|
|
finally:
|
|
tmp_path.unlink(missing_ok=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_context_summary()
|