Setting max_loops="auto" allows an agent to decide when a task is complete. The agent will continue reasoning and acting until it reaches a stopping condition. This is ideal for open-ended research or iterative tasks (e.g., write $\rightarrow$ review $\rightarrow$ revise).
For latency or cost-sensitive production pipelines with well-defined steps, use a fixed integer for max_loops instead.
from swarms import Agent
agent = Agent(
agent_name="Autonomous-Research-Agent",
agent_description="An autonomous agent that conducts multi-step research independently.",
system_prompt=(
"You are an autonomous research agent. Break down complex tasks into steps, "
"execute each step thoroughly, and signal completion only when the full task is done."
),
model_name="gpt-5.4",
max_loops="auto", # Agent decides when it's done — no fixed iteration cap
autosave=True,
verbose=True,
)
# The agent will keep looping — planning, executing, and reflecting — until it
# determines the task is fully complete.
result = agent.run(
"Research the current state of quantum computing, identify the top three "
"hardware approaches, and summarize the key challenges each faces."
)
print(result)