Getting output from repetitive tasks

I am trying to get a structured output from the tables in the pdf using a tool. I am doing this successfully with 3 pdfs. But how can I make it automatically start over when each pdf completes its result when I give 30 pdfs? In other words, instead of processing 3 pdfs at the same time, a loop like agent-> tool usage-> data analysis->output->agent->tool usage… What I mean is task loop actually.