refactor: single dependency probe in capability detection; real test coverage

detect_mode_availability accepts a pre-computed dep_status so the agent
probes once; interface and fallback paths now have content-level tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
James Smith
2026-06-12 08:37:30 +01:00
parent 0588055d1f
commit 5cff7de117
3 changed files with 112 additions and 22 deletions
+8 -2
View File
@@ -60,15 +60,21 @@ FALLBACK_TOOL_CHECKS = {
}
def detect_mode_availability() -> dict[str, bool]:
def detect_mode_availability(dep_status: dict | None = None) -> dict[str, bool]:
"""Detect mode availability from tool dependencies.
Returns a ``{cap_mode: bool}`` map of raw tool readiness. Falls back to
direct tool checks if :func:`check_all_dependencies` raises.
Args:
dep_status: Pre-computed result of :func:`check_all_dependencies`. When
supplied the probe is skipped entirely, avoiding a second call when
the caller has already fetched it.
"""
modes: dict[str, bool] = {}
try:
dep_status = check_all_dependencies()
if dep_status is None:
dep_status = check_all_dependencies()
except Exception as e:
logger.warning(f"Dependency check failed, using fallback: {e}")
return _detect_mode_availability_fallback()