Academy

How an AI agent thinks

An agent takes a goal, reasons, acts, and observes the result — repeating that loop until it's done. A simple mental model for how agents reason and decide.

The Felesh team 5 min

The perceive–reason–act loop

How does an agent “think”? The simplest model is a loop that repeats until a goal is reached: perceive, reason and plan, act, then perceive again. During perception, every input — text, image, audio, or raw data — is converted into text the model can parse. The more precise that description, the better the agent reasons. It then decides on a course of action, executes it, observes the result, and the loop continues.

The perceive, reason, act loop on one taskFour stations in a circle for one task, rebooking a cancelled flight. Perceive: an email and a boarding-pass photo become text, flight 482 cancelled, booking K7QM2P. Reason: the next step is to find a seat on tomorrow’s flights. Act: the tool search_flights is called for Tuesday. Observe: three seats come back, 09:15 is the cheapest. That observation returns to the first station as the next input, and the loop repeats until the goal is met.1 perceive2 reason3 act4 observeemail + photo → text:FL 482 cancelled, K7QM2Pnow also: 3 seats foundnext: find a seat ontomorrow’s flightssearch_flights(Tue)a tool call, exact input3 seats, 09:15 cheapestit feeds the next perceiveuntil the goal is met
The loop turns every result into the next input: the three seats the agent just found are what it perceives on the next turn.

Reasoning before acting

The most widely used version of this loop is “reason and act,” built from three repeating steps: thought, action, and observation. In the thought step, the agent asks itself, “What should I do now?” and reasons step by step. In the action step, it calls a specific tool with exact inputs. In the observation step, it reads the result. Then it thinks again. The key insight is that forcing the agent to “think out loud” before acting leads to better decisions.

A reason-and-act trace, row by rowThe trace of one agent on booking K7QM2P, five rows. Thought: cancelled, what now, look for a seat on Tuesday. Action: search_flights for Tuesday to BER. Observation: three flights at 09:15 for 142 dollars, 13:40 for 168 and 18:05 for 151. Thought: 09:15 is cheapest, rebooking costs money, so ask first. Action: request_approval for flight FL 611 at 09:15. Every action is preceded by its reason.agent trace · booking K7QM2PthoughtactionobservethoughtactionCancelled. What now? Look for a seat on Tuesday.search_flights(day=Tue, to=BER)09:15 · $142 13:40 · $168 18:05 · $15109:15 is cheapest. It costs money: ask first.request_approval(rebook FL 611, 09:15)every action is preceded by its reason
Before every action the agent writes down why, so the trace keeps the reason right next to the call it led to.

Tools

An agent without tools is just the model alone. Each tool consists of three parts: a name, a description the model reads to decide when to use it, and defined inputs. A precise description matters a great deal; a vague one leads the agent to choose the wrong tool. There is also an operational principle: give the agent only the tools it truly needs, and require human approval for irreversible actions.

Three tools, one with a vague descriptionA table of three tools with name, the description the model reads, and inputs. search_flights lists flights for a day and destination, read-only, inputs day and to. rebook_flight moves a booking to another flight and charges the fare gap, asks a person first, inputs booking and flight. flight_tool is described only as handles flights, input data, and the agent can pick the wrong tool because of it.namedescription the model readsinputssearch_flightsLists flights for a dayand destination. Read-only.daytorebook_flightMoves a booking to anotherflight. Charges the fare gap.asks a person firstbookingflightflight_toolhandles flightsdataa vague line: which tool fits? it may pick the wrong one
A tool is a name, a description and inputs; the model picks by the description, so a vague one gets the wrong tool picked.

Why this makes an agent auditable

There is a quiet benefit in how these pieces fit together. An agent’s capabilities aren’t hidden inside it; they are handed to it explicitly — this exact model, these specific tools, each with a name and a readable description. You can see at a glance everything an agent is able to do simply by looking at what it was given. Nothing reaches for a capability in secret.

What the agent was handedThe agent is handed one named model and three tools, each with a name and a readable description: search_flights, get_booking, both read-only, and rebook_flight, which asks first. Two other tools, refund_ticket and delete_booking, were not given, so the agent has no path to them. Everything it can do is on the list.the agent1 model, named3 tools, each withname + descriptionhanded to itsearch_flightsread-onlyget_bookingread-onlyrebook_flightasks firstrefund_ticketnot givendelete_bookingnot giveneverything it can do is on this list
An agent's abilities are the list it was handed, so reading that list tells you everything it is able to do.

Combine that with the think-out-loud trace from earlier, and every step becomes inspectable. For each action the agent took, you have its stated reason, the exact tool it called, and the result it observed. You can follow the entire chain after the fact: which tool fired, on what input, and why. An agent built this way isn’t a black box emitting an answer; it is a decision you can audit, step by step.

When to stop

A loop with no stopping condition can spin forever and run up costs. An agent therefore needs clear conditions for halting: when the final answer is ready, when it reaches a hard cap on the number of steps, or when it calls the same tool with the same input repeatedly and is clearly stuck. Defining these exit conditions matters just as much as the loop itself.

One goal, several degrees of autonomy

Not all agents operate with the same independence. At one end is an assistant that only suggests, leaving the human to decide every step. In the middle is an agent that takes a goal, lays out the steps, and asks for approval at key points. At the other end is the fully independent agent — still more of a laboratory thing than something ready for real work. Choosing the degree of autonomy is itself a core part of the design.

Who decides, at three degrees of autonomyA grid for rebooking K7QM2P with three steps: find flights, pick one, rebook and charge. An assistant that only suggests: a person decides all three. An agent that plans and asks at key points: the agent finds and picks, a person approves the rebooking. A fully independent agent: the agent decides all three, but this is still a laboratory setup, not ready for real work. Choosing the degree is part of the design.rebookingK7QM2Psuggestsonlyplans, asks atkey pointsfullyindependentfind flightspick onerebook + chargeyou decideyou decideyou decideagentagentyou approveagentagentagentlab stage, not ready for real workchoosing the degree is part of the design
The same rebooking at three degrees of autonomy: who decides each step changes, the task does not.