Skip to the workspace
Pebellslearn by building
The Agent Loop  ›  Lesson

Perceive, Then Reason and Plan

Perception / User Input 12 minEach turn the agent perceives the user input plus history and context the app supplies, then reasons about the goal and unknowns to choose the single next step, keeping the rest of the plan as a draft.

ai agents / Perceive, Then Reason and Plan

Explore each scene at your own pace.

01 · The rule

The rule

Perceive, Then Reason and Plan

Asha types: "Get me to Jaipur for Priya's wedding, cheapest option, I can't leave before Thursday evening." Before Tripmate can act, it has to take that sentence in, together with everything else it knows, and turn it into a next move. Those are the first two stages of every agent loop.

The rule

Perceive everything relevant, then decide the single next step.

Perception is how input reaches the model. In an agent it is more than the user's latest message. Each turn, the program assembles:

  • the user input — text, and sometimes images, files or voice turned into text,
  • the state so far — earlier turns, tool results, notes from memory,
  • the environment — today's date, the user's time zone, what tools exist.

Anything the program leaves out, the model cannot perceive. "Thursday evening" means nothing unless the model also knows what today's date is. Perception also means leaving things out: pasting a whole 40-page timetable into every turn buries the few lines that matter, so good agents choose what to show.

Reasoning and planning is the model working out what to do with that picture. For Tripmate it might go:

Goal: arrive in Jaipur before the wedding, cheapest fare.
Known: can leave Thursday after 6 pm. Wedding date: unknown.
Plan: 1) ask or look up the wedding date  2) search trains Thu night–Fri
      3) compare fares  4) propose the cheapest that arrives in time
Next step: look up the wedding date in Asha's calendar.

A plan is useful, but it is a draft. The loop only commits to the next step; after seeing the result, the model can revise the rest.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.