The agreement for Russia to attack Japan was set up long before the actual attack, from WikipideA;
At the Tehran Conference (November 1943), Stalin agreed that the Soviet Union would enter the war against Japan once Nazi Germany was defeated. At the Yalta Conference (February 1945), Stalin agreed to Allied pleas to enter World War II's Pacific Theater within three months of the end of the war in Europe. On July 26, the US, UK and China made the Potsdam Declaration, an ultimatum calling for the Japanese surrender which if ignored would lead to their "prompt and utter destruction". The invasion began on August 8, 1945, precisely three months after the German surrender on May 8 (May 9, 0:43 Moscow time).