Skip to main content

Your travel agent plans flight, hotel and cab up front, and when the planned flight is sold out it still books the hotel for the old dates. How should the loop be designed?

Agents and tools · Pro 1

Short answer

A plan is a guess that must be checked after every step. The loop should look at each tool result, compare it with what the plan assumed, and replan when a step fails or an assumption breaks. Steps that depend on each other should be confirmed in order, and irreversible bookings should wait until the earlier ones are secure.

Deeper answer

Planning up front is cheap and keeps the agent focused, but the world does not follow the plan. The failure here is that the agent executed step two without reading what step one returned. A good loop has an observe stage: after every action, did it succeed, and are the plan's assumptions still true? If not, the agent revises the remaining steps. It does not just continue.

The plan should also carry dependencies. The hotel dates depend on the flight, so the hotel step cannot run until the flight is confirmed. Where the tools allow it, hold or reserve first and pay last, so a late failure can be undone. Replanning needs limits too: a maximum number of attempts, and a rule to go back to the user when a hard constraint such as the travel date or the budget must change. Interviewers listen for observe and replan, for dependencies between steps, and for knowing when to ask the user.

What a strong answer covers

Answer it out loud in the mock interview about 2 min

Follow-ups to expect

Common mistakes

Learn it

Planning and reflection

Practice Agents and tools questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.