AI / A CONCEPT NOTE

Execution Loop

the perceive → reason → act cycle that drives autonomous agents

~70 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

The execution loop (also called the agent loop or cognitive loop) is the core cycle of any AI agent: Perceive (gather observations from tools or the environment), Reason (the LLM decides what to do next based on observations and goals), Act (execute the chosen action — call a tool, return a response, or ask for clarification). This loop repeats until the task is complete or a termination condition is met.

02 / FOLLOW THE MECHANISM

How the perceive → reason → act cycle runs

  1. Perceive

    the agent observes its current state — tool outputs, user messages, environment data, and conversation history.

  2. Reason

    the LLM processes all observations and decides the next action: 'I need to query the database to answer this question.'

  3. Act

    the chosen action is executed — a tool call, API request, or final response generation.

  4. Loop check

    was the task completed? If yes, return the result. If no, feed the action's output back into the perceive step and loop.

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

pseudocode for a basic execution loop

python -c "while not done and steps < MAX_STEPS: observation = tool.run(action); action = llm.decide(observation); steps += 1"

Explore command anatomy in the CLI lab