← All resources

Foundations

The Agent Loop: Observe, Decide, Act, Repeat

The control cycle behind most tool-using AI agents, from initial goal to a verified stopping point.

Observe

The loop begins with a representation of the current state: the user goal, prior messages, tool results, stored facts, and remaining limits. Poor state representation causes the agent to reason from incomplete or stale information.

Decide and act

The model chooses a next action, such as calling a search tool, updating a record, or returning an answer. The application validates the request, executes the allowed action, and returns a structured observation.

Stop deliberately

A reliable loop has explicit completion, failure, escalation, time, and budget conditions. Without them, an agent can repeat unproductive actions or declare success without evidence.