Happy to help. An addition that would likely be helpful for your loop.
from optking import optwrapper, convCheck
optwrapper.initialize_options({"g_convergence": "foo_bar"})
If you would like to use optking’s convergence machinery you can call this method. Works as seen in the Psi4 optking documentation. q_pivot is for IRCs.
def convCheck.conv_check(iterNum, oMolsys, dq, f, energies, q_pivot=None):