How to Build and Evaluate a Multi-Agent Trip Planner with LangGraph + SearchApi.io
Hey friend,
This week I tried to make an AI travel agent lie to me.
I gave a multi-agent trip planner a $1,200 budget for a trip it could not possibly cover. Real flights, real hotels, live prices. The easy way out for an LLM is obvious: invent a cheap flight, make the numbers add up, keep the user happy.
It didn't do that.
The agents went back and searched again, hunting for cheaper options. Still over. One more try. Then it stopped and told me the truth: this trip can't be done for $1,200, and here's exactly how far over it is: $1,292.
No invented flight. And I can prove it, with an eval that checks every price in every answer against the data the tools actually returned.
Here's how it's built.
▶️ Watch the full video\
https://www.youtube.com/watch?v=m4kfY0uP3U0
The whole system on one page
It's a LangGraph graph with seven nodes:
- Intake agent. Turns my chat message into a structured trip request (airports, dates, travelers, budget). If something's missing, it asks a follow-up question instead of guessing.
- Three specialist agents in parallel: flights, hotels and Tripadvisor. Each one is an LLM with one SearchApi engine as its tool, capped at three searches.
- Budget check. Plain code, no LLM. If cheapest flight + cheapest hotel is over budget, the graph loops back and searches again, at most two retries.
- Grounding validator. Makes sure the writer only sees data that really came back from the API.
- Itinerary writer. Turns the verified data into a day-by-day plan.
Stack: FastAPI, LangGraph + LangChain, an OpenAI model, and a tiny chat page that streams each step.
Where the live data comes from
All the live data comes from SearchApi.io, a real-time SERP API. Google Flights, Google Hotels and Tripadvisor through one API: a GET request with an engine parameter and your API key, and you get clean, structured JSON back. No scraping, no HTML parsing.
That's exactly what an agent needs: live, structured data it can reason over.
🎁 SearchApi gives you 100 free credits when you sign up: searchapi.io. Enough to build and run this whole project yourself.
Lesson 1: Don't hand the raw response to your agent
Look at how much is in a single Google Flights response: best flights, other flights, per-leg airports, carbon emissions, legroom, airline logos, booking tokens. Tens of kilobytes, and nearly all of it is noise for planning a trip.
Every extra field costs tokens, money and accuracy.
So the data layer keeps only what a traveller cares about (price, airlines, flight numbers, times, stops, duration), sorts by price and keeps the top five. Hotels and Tripadvisor get the same treatment.
Lesson 2: What actually makes something an agent
A function runs a search you decided on. An agent is an LLM with tools, in a loop: it chooses the search, reads the result, and decides whether to search again.
Every tool call in this project is wrapped with three guardrails:
- A hard cap of three searches per agent, so a confused model can't burn your credits.
- Errors go back to the model as a tool result, so it can fix its own parameters (say, a bad airport code).
- It records exactly what the tool returned.
That last one is the most important design decision in the whole project:
We never use what the agent says as data. We keep what the tools returned. The model controls the question, but it can't change the answer.
Lesson 3: The agent proposes, code disposes
The LLM is great at deciding how to search. It is not in charge of what's allowed.
- Validate request is plain code: are these real three-letter airport codes, are the dates in the future, is there a budget? A model can be wrong about a date; this check can't be talked out of it.
- Budget check is plain code: cheapest flight × travellers + cheapest hotel stay. If it's over, it writes feedback for the agents' next pass. The agents decide how to tighten (lowest-price sort, lower rating filter, a price cap). I don't hardcode the strategy.
- The retry limit is hardcoded. That's a safety limit, and it's why the loop always ends.
The live run, traced end to end
A different trip, city names only: the intake agent looks up the airports, three agents finish at about the same time, and out comes a real flight, a real hotel, a total price and a plan built from Tripadvisor places.
With LangSmith tracing on (three lines in .env), every run shows up as a trace: intake, the three parallel branches, the budget check, the writer. Every SearchApi request is its own span, so you can see exactly which parameters the agent chose and what it changed on each retry. When an agent does something wrong, this is where you debug it.
The evals: proving it doesn't lie
An answer that looks great is exactly what a hallucinating agent also produces. So I split the evals into three layers, cheapest first:
- Wiring tests. A fake tool-calling model and a stubbed SearchApi. No keys, no credits, but the real agent loops. Does the graph route correctly? Is the search cap enforced? Does state hold the right data even when the agent's text lies?
- The grounding check. The one I care about most.
- Behaviour cases. Eight cases, each a user message plus what should happen. I assert on the final state (retries, whether a question was asked, within budget), not the wording. Wording changes every run; state doesn't.
Demo report from an offline-fixtures run: a fake writer deliberately slips in a $99 flight to test the checker.
The grounding check is simple: take the final answer, pull out every price and every flight number, and look each one up in the data the tools actually returned. Anything not found is a violation.
It's plain code, with no LLM-as-a-judge, so it's cheap, repeatable, and it can't hallucinate. It even allows simple derived numbers like price × travellers, or "over budget by X", but only when the trip really is over budget.
And to be honest about its limits: it checks numbers and flight numbers, not free text. If the agent invents a restaurant name, this won't catch it. For that you'd add an LLM-as-a-judge, which is where the next video goes.
The loop
Agents decide what to search. Code decides what's allowed. Evals check the result.
Build the agent, then build the thing that tells you whether to trust it.
- ▶️ Full video:
- 🔗 SearchApi.io, 100 free credits:
- 💻 Code: github.com/zahere-dev/multi-agent-planner-with-searchapi-dot-io
About the author
I am a Journalist-turned-Software Engineer. I love coding and the associated grind of learning every day. A firm believer in social learning, I owe my dev career to all the tech content creators I have learned from. This is my contribution back to the community.
Comments
Join the discussionNo comments yet. Be the first to comment.

