def execute_tool_safely( tool: BaseTool, tool_name: str, tool_input: Dict[str, Any] ) -> Dict[str, Any]: """ Executes a tool with error handling and logging. Args: tool: The tool instance to execute tool_name: Name of the tool (for logging) tool_input: Parameters to pass to the tool Returns: The tool's execution result or error information """ try: print(f" → Executing {tool_name} with input: {tool_input}") result = tool.execute(**tool_input) print(f" ✓ Tool execution successful") return result except Exception as e: error_msg = f"Tool execution failed: {str(e)}" print(f" ✗ {error_msg}") return {"error": error_msg} __ __