I believe there were the 'rogue' elements in Iran which launched the missiles into Pakistan and the next day Pakistan retaliated in an arranged tit for tat. Iran is not an integrated security state like Pakistan has. The two countries' threat perceptions are very different due to their geography and geopolitics and thus have evolved differently. No Pakistani has ever not noticed where the real threat lies: To Pakistan's east--in India.
Having said that, I believe the Iran-Pakistan relations are almost back to the Shah of Iran era. You may want to follow the American analyst Patrick Henningsen, who seems connected with the Iran establishment, to understand Pakistan-Iran relations, which are kept on low key.
As to what Pakistan will do in this conflict, it would hugely surprise me if Pakistan gets sucked majorly on Saudi Arabia's side due to that agreement. The language of that agreement doesn't automatically make Pakistan to launch missiles on Iran. At most, air defenses for Saudi Arabia but even that's a long shot. Iranians, Saudis, Turks, and Pakistanis really know it is Israel who is the ultimate enemy.