Skip to content

Agent Cycle Patterns: From Simple to Complex

Summary

The agent cycle is a sequence of 'observation → decision → action' implemented through agent-loop; this article explores the main patterns of its construction and selection criteria.

Basic Cycle

Any agent operates in a cycle: it receives input data, forms a decision, performs an action, observes the result, and repeats until the goal is achieved. The minimal implementation is a while loop with calls to LLM and tools.

while not done:
    observation = get_observation()
    action = llm.decide(observation)
    result = execute(action)
    done = check_done(result)

This cycle forms the basis of ReAct and agentic-workflow.

ReAct Pattern

ReAct (Reasoning + Acting) is the most common pattern: at each step, the model generates reasoning (Thought) and action (Action), then receives an observation (Observation).

for step in range(max_steps):
    prompt = build_prompt(history)
    response = llm(prompt)
    thought, action = parse(response)
    if action == "finish":
        return thought
    observation = call_tool(action)
    history.append(observation)

More details in react-autonomous-agents.

Plan-and-Execute Pattern

It differs in that the agent first formulates a plan consisting of several steps, then executes them sequentially, correcting the plan if necessary.

graph TD
    A[Input] --> B[Planner]
    B --> C[Plan: step 1, step 2, ...]
    C --> D[Executor]
    D --> E{Success?}
    E -->|Yes| F[Result]
    E -->|No| G[Rerouting]
    G --> B

This pattern reduces the number of LLM calls compared to ReAct but requires a high-quality planner.

Reflexion Pattern

Reflexion adds a self-assessment stage: after performing an action, the agent analyzes the result, forms verbal feedback, and uses it in the next iteration.

memory = []
for step in range(max_steps):
    action = llm(history + memory)
    result = execute(action)
    reflection = llm(f"Evaluate the result: {result}")
    memory.append(reflection)

This improves quality on complex tasks but increases cost.

Multi-Agent Cycles

In multi-agent-systems, the cycle becomes more complex: several agents exchange messages, coordinate through an orchestrator. Example — crewai and langgraph.

graph LR
    A[Explorer Agent] -->|data| B[Analytic Agent]
    B -->|report| C[Writer Agent]
    C -->|article| D[Orchestrator]
    D -->|feedback| A

Selection Criteria

Pattern When to Use Cost Complexity
ReAct Simple tasks, few steps Low Low
Plan-and-Execute Tasks with clear structure Medium Medium
Reflexion Tasks with high error cost High Medium
Multi-Agent Complex tasks with role division High High

I choose ReAct for most scenarios, Plan-and-Execute when the task is decomposed, Reflexion for critical processes. Multi-agent cycles are justified only with real parallelism.