The 'Benn Act' compels the Prime Minister to take certain actions by certain dates and times. Has any previous legislation (passed, or otherwise) compelled the government to take action like this? Specifically with regards to foreign policy but any similar act would be interesting.
To a degree. The EU Withdrawal Act 2019 (which is distinct from the EU Withdrawal (No. 2) Act 2019) forced the government to seek an extension, however at that time the Prime Minister was Theresa May, who was considered to be more trustworthy, and so the letter of the legislation was significantly less watertight. She was not required to write a specific letter by a specific date, merely:
the Prime Minister must seek an extension of the period specified in Article 50(3) of the Treaty on European Union to a period ending on the date included in that motion.
The motion referenced is a vote the government is forced to hold in Parliament approving an extension date of their (I.E. the government's choosing). This vote was required to be held the day after the Bill received Royal Assent at the latest.
So, specific actions by specific (albeit relative) dates, but not so stringent as the Benn Act. This is the only other time I've heard of something like this happening.
If you extend it beyond laws, i.e. to motions, there have been more recent examples, e.g. May's government was voted as being in contempt of Parliament in Dec last year for not disclosing "the full legal advice underpinning her Brexit plan".
The unprecedented contempt vote was prompted by the government's refusal to publish the legal advice on May's Brexit deal, despite having previously accepted a parliamentary motion directing it to do so.
The attorney general, Geoffrey Cox, had argued it was not in Britain's national interest to publish it in full, and instead offered a summary to Parliament on Monday. "There is nothing to see here," Cox insisted.