Observe, Reflect, and Know When to Stop
The train search comes back: "No sleeper seats available on 15 October." A careless agent would search the same thing again, and again, burning money until someone pulls the plug. Tripmate needs to read the result, think about what it means, and know when the job is done — or when to give up.
The rule
Read every result, adjust the plan, and stop on purpose.
Observation is taking in what the action produced: the tool result, an error, or the fact that nothing came back. Reflection is asking what that means for the goal:
- Did the step succeed? ("Three trains found.")
- Did it fail in a way I can fix? ("Date format rejected — send it as YYYY-MM-DD.")
- Did it change the plan? ("No sleepers Thursday — try Friday, or try third AC.")
Then the loop goes back to reasoning with the new facts.
Stopping criteria are the rules that end the loop. Good agents have several, because any single one can fail:
- Goal met — the model gives a final answer instead of another tool call.
- Step limit — for example, at most 15 tool calls per request.
- Budget limit — a cap on tokens, money or time.
- Stuck detection — the same call with the same arguments repeated.
- Needs a human — a decision only the user can make, like paying a higher fare.
loop:
reply = model(context)
if reply is a final answer: stop (goal met)
if steps >= 15 or cost >= limit: stop (report what was found)
result = run_tool(reply.tool_call)
context.add(result) # observation feeds the next turnThe shortcut
After every observation, sort it into one of three bins: "done", "adjust", or "escalate". Done → answer. Adjust → change the next step (never repeat an identical failed call). Escalate → stop and ask the user, or report honestly.
Observe
search_trainsfor Thursday returns no sleeper seats.
The classic failure is the infinite loop: an agent retrying the same failing call forever. A hard step limit catches it even when the model's judgement does not.
Drills
Answer fast — trust the rule.
A tool returns an error saying the date format is wrong. What is the best next step?
Why give an agent a hard maximum number of steps?
The only train that fits costs twice Asha's budget. Which bin is this?
Which signal most clearly means the goal is met in a typical loop?
Remember
- Observe every result, reflect on what it means, and feed it into the next decision.
- Shortcut: done, adjust, or escalate — and never repeat an identical failed call.
- Trap: loops with no step, budget or stuck limit.
