def _discover_built_in_tools(self):
        """Load all built-in tools from the built_in directory."""
        if not os.path.exists(self.built_in_path):
            logger.warning(
                f"Built-in tools directory not found: {self.built_in_path}"
            )
            return

        # Add to Python path if needed
        if self.built_in_path not in sys.path:
            sys.path.append(os.path.dirname(self.built_in_path))

        # Import the built_in package
        try:
            built_in_pkg = importlib.import_module("built_in")
        except ImportError:
            logger.error("Failed to import built_in tools package")
            return

        # Discover all modules in the package
        for _, module_name, is_pkg in pkgutil.iter_modules(
            [self.built_in_path]
        ):
            if is_pkg:  # Skip subpackages
                continue

            try:
                module = importlib.import_module(f"built_in.{module_name}")

                # Find all tool classes in the module
                for name, obj in inspect.getmembers(module, inspect.isclass):
                    if (
                        issubclass(obj, Tool)
                        and obj.__module__ == module.__name__
                        and obj != Tool
                    ):
                        try:
                            tool_instance = obj()
                            self._built_in_tools[tool_instance.name] = obj
                            logger.debug(
                                f"Loaded built-in tool: {tool_instance.name}"
                            )
                        except Exception as e:
                            logger.error(
                                f"Error instantiating built-in tool {name}: {e}"
                            )
            except Exception as e:
                logger.error(
                    f"Error loading built-in tool module {module_name}: {e}"
                )
Load all built-in tools from the built_in directory.
py/core/base/agent/tools/registry.py