Source code for tools.debug_limbic_import

"""Debug tool: trace import health for the limbic subsystem."""

from __future__ import annotations

import logging
import os
import sys
import traceback

logger = logging.getLogger(__name__)

TOOL_NAME = "debug_limbic_import"
TOOL_DESCRIPTION = "Diagnostic tool that traces import errors in the limbic subsystem modules."
TOOL_PARAMETERS = {
    "type": "object",
    "properties": {},
}


[docs] async def run() -> str: """Execute this tool and return the result. Returns: str: Result string. """ output: list[str] = [] project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) output.append(f"Project root: {project_root}") for module_name in ("lsrd_v2_core", "lsrd_v3_core", "limbic_system", "ncm_engine"): module_path = os.path.join(project_root, f"{module_name}.py") exists = os.path.exists(module_path) output.append(f"\n--- {module_name} ---") output.append(f" File exists: {exists} ({module_path})") if not exists: continue try: mod = __import__(module_name) output.append(f" Import: OK (file={getattr(mod, '__file__', '?')})") except ImportError as e: output.append(f" Import FAILED: {e}") output.append(traceback.format_exc()) except Exception as e: output.append(f" Other Error: {e}") output.append(traceback.format_exc()) output.append(f"\nsys.path (first 5): {sys.path[:5]}") return "\n".join(output)