diff --git a/pkgs/swarmauri/swarmauri/importer.py b/pkgs/swarmauri/swarmauri/importer.py index bc41c058..84674e40 100644 --- a/pkgs/swarmauri/swarmauri/importer.py +++ b/pkgs/swarmauri/swarmauri/importer.py @@ -24,6 +24,11 @@ def find_spec(self, fullname, path, target=None): if parent and parent not in sys.modules: print(f"Parent module '{parent}' not found. Cannot create namespace module: {fullname}") return None + + # Check if the module is an expected namespace component + if fullname not in REGISTRY and fullname.count(".") > 1: + print(f"Invalid namespace module: {fullname}") + return None print(f"Creating placeholder for namespace module: {fullname}") spec = ModuleSpec(fullname, self)