A task loop repeatedly takes work from a defined queue, processes one item, records progress, and continues until the queue is empty or a stopping condition fires. Unlike a research loop, it handles known work items sequentially rather than exploring an open-ended question. section 9.2.8
Think of it as a checklist with an agent assigned to each line: the queue and decision flow remain outside the agent, while tools perform the current task. This external state supports longer workflows without requiring one internal cycle to hold everything. section 9.1.2 section 9.2.8
A reliable task loop makes these controls explicit:
- Track completed, failed, and pending items so progress is inspectable. section 9.6
- Retry transient failures, feed previous errors into retries, and preserve permanently failed items for review. section 9.5 section 9.6
- Layer hard iteration and budget limits with goal, quality, and stagnation conditions. section 9.5 section 9.6
- Use parallel processing only when items are independent, while checking rate limits. section 9.5 section 9.6
Batch-processing files
Create a queue of files, process one file per iteration with filesystem and search tools, record its result, and stop when the queue is empty or a termination condition is met. The same pattern applies to invoices, endpoint tests, document transformations, and record migrations. section 9.2.8
Figure 9.5 Workflow of a repetitive task loop agent. The agent pulls items from a task queue, processes each one using tools from MCP servers, records the result, and tracks progress until the queue is empty or a stop condition fires.
Use the workflow diagram to follow the queue-to-processing-to-result-to-progress cycle and see where termination occurs. section 9.2.8
