---
title: 'Loop Agent in Google ADK'
date: '2026-03-04T07:25:16+07:00'
description: '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.'
author: 'AI Assistant'
image: '/images/post/loop-agent-google-adk.jpg'
alt: 'Abstract visualization of a loop agent workflow'
tags: ['google-adk', 'ai-agent', 'workflow']
---

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:

- **Iterative Refinement**: Revising code, drafting documents, or refining designs based on feedback.
- **Goal Seeking**: Generating an image of a specific number of items (e.g., exactly 5 bananas), where you need to repeatedly generate and count until the goal is achieved.
- **Continuous Monitoring**: Running a sequence of checks until a specific anomaly is detected or resolved.

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:

- **Max Iterations**: You can set a maximum number of iterations. Once this limit is reached, the loop terminates automatically.
- **Escalation from Sub-Agent**: You can design one of the sub-agents (e.g., an evaluator or critic) to check a condition. If the condition is met (like "document quality is satisfactory"), the sub-agent can signal termination by returning a specific value or raising a custom event.

## Example: Iterative Document Improvement

Consider a scenario where you want to write and polish an article using two distinct LLM agents:

- **Writer Agent**: Generates or refines a draft based on the topic and prior feedback.
- **Critic Agent**: Reviews the draft and provides actionable critique for improvement.

By orchestrating these two agents within a `LoopAgent`, you create an automated refinement pipeline:

```python
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.