Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
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.

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.

The shortcut

At each turn, run a quick three-question check: "What is the goal? What is still unknown? Which one action shrinks the unknown most?" That action is the next step.

Tripmate's first decisionStep 1 of 4
  1. Name the goal

    Reach Jaipur in time for the wedding, at the lowest fare, leaving Thursday evening or later.

A common mistake is planning too far ahead in detail. If the calendar shows the wedding is on Sunday, a rigid plan built for Friday is wasted. Plan roughly, act on the next step, and replan with new facts.

Drills

Answer fast — trust the rule.

quick drill

Asha says "leave tomorrow", but Tripmate books the wrong day. What perception gap is most likely?

quick drill

In the agent loop, what does the reason-and-plan stage produce?

quick drill

Which is part of an agent's perception on a given turn?

quick drill

The calendar shows the wedding moved to Sunday. What should Tripmate do with its plan?

Remember

  • Perceive everything relevant — input, history, and context like the date — then decide one next step.
  • Shortcut: goal, unknowns, the one action that shrinks the unknowns most.
  • Trap: rigid, detailed plans that ignore what each step reveals.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainChoose the next step

Asha writes: "Book me the cheapest train home after my conference ends." Describe what Tripmate needs to perceive to act on this, and explain how it should choose its first action.