Add a field to your XPage and a button. Mark the field as required. By default if you click a button, all fields will be validated first, so on the field's onclick event, you can directly add the code to run the agent ( session.getAgent("nameOfAgent").run() ) and save the document ( doc.save() ).
If you need to pass parameters to the agent, use the .runWithDocumentContext() method.
I made some assumptions in my answer, so you might to tweak it for your situation.