Blog

Loop Agent in Google ADK

An in-depth look at the Loop Agent in Google ADK, a workflow agent that executes sub-agents iteratively for tasks requiring repetition and refinement.

Posted on: 2026-03-04 by AI Assistant


The LoopAgent is a powerful workflow agent in the Google Agent Development Kit (ADK) that fundamentally changes how you can orchestrate multi-agent systems. It is designed to execute its sub-agents in a loop, repeatedly running a sequence of agents for a specified number of iterations or until a specific termination condition is met.

Available in Python, TypeScript, Go, and Java, the LoopAgent is essential when your workflow requires repetition or iterative refinement.

When to Use the LoopAgent

You should use a LoopAgent whenever a task cannot be guaranteed to complete in a single pass. For example:

It is important to note that like other workflow agents, the LoopAgent itself is not powered by an LLM. Its execution logic is purely deterministic. However, the sub-agents it orchestrates may heavily utilize LLMs.

How It Works

When the LoopAgent’s execution method (Run Async) is invoked, it manages the workflow through two primary mechanisms:

1. Sub-Agent Execution

The agent iterates through its list of sub-agents in the exact order they were provided. For each sub-agent in the sequence, it calls their respective execution method. Once all sub-agents in the sequence have completed, a single iteration is considered finished.

2. Termination Check

Crucially, the LoopAgent does not inherently know when to stop looping. You must explicitly design a termination mechanism to prevent infinite loops. There are two common strategies:

Example: Iterative Document Improvement

Consider a scenario where you want to write and polish an article using two distinct LLM agents:

By orchestrating these two agents within a LoopAgent, you create an automated refinement pipeline:

LoopAgent(sub_agents=[WriterAgent, CriticAgent], max_iterations=5)

In this setup, the workflow manages the iterations. The CriticAgent can be programmed to return a “STOP” signal when the draft meets the required quality standard, halting the loop early. Even if the quality is never deemed perfect, the max_iterations=5 parameter acts as a failsafe, ensuring the refinement process does not run indefinitely.

Conclusion

The LoopAgent in Google ADK is a simple yet incredibly effective tool for building resilient, self-correcting agent workflows. By orchestrating deterministic loops with intelligent LLM sub-agents, developers can tackle complex tasks that require iterative feedback and refinement.