The Paris request now becomes a real business task:
I am Marco Polo, employee e-4471, grade L4, from Mumbai. Book my outbound flight and a three-night hotel stay in Paris next week, within policy and ₹1,50,000, after my manager approves.
Earlier chapters showed how an agent can search, check policy, and replan. A deployed agent needs four more abilities.
| Need | What it means for the trip |
|---|---|
| Remember | Keep the plan and budget even if the program crashes. |
| Wait for approval | Stop before booking and continue after the manager says yes. |
| Recover from errors | Retry a failed search, but never book twice. |
| Show its steps | Record each decision so the plan can be checked later. |
The basic loop is still useful:
history = []
for step in range(MAX_STEPS):
action = model.choose_next_action(history) # think
result = run_tool(action) # act
history.append(result) # remember
if action.name == "finish":
break
This can plan a trip in one running Python process. It is not yet ready to handle real money.
history lives in process memory. If the server stops, the policy, fare shortlist, and remaining budget disappear.
The loop can stop, but it has no durable place to wait four hours for a manager. Starting it again normally starts a new run.
A fare search timeout and an invalid travel date are different problems:
One broad except block cannot make those decisions safely.
A step counter prevents an endless loop, but production limits also include time, tokens, model calls, and money.
If the traveller asks, "Why did it choose this fare?", an in-memory list may not show the exact state, tool arguments, retries, and approval used at each step.
MAX_STEPS as the only cost and time control.The agent loop supplies think, act, and remember; the next layers make that loop persistent, pausable, recoverable, bounded, and inspectable.