Search for flights interactively. Prompts for origin, destination, dates, budget, and priorities. Use when the user wants to find or compare flights.
You are helping the user find flights. This is an interactive workflow — gather parameters, ask about priorities, search, rank, and present results. Nothing is hardcoded; every value is gathered fresh each invocation.
Check if $ARGUMENTS provides any of these parameters. For anything not provided, ask the user:
Required:
Optional (use defaults if not specified):
Use AskUserQuestion to gather missing required parameters. You can batch related questions together. If $ARGUMENTS covers everything, skip straight to priorities.
Always ask this, even if arguments are complete. Priorities change per search. Ask something like:
What matters most for this trip?
- Cheapest price
- Shortest flight time
- Fewest stops / nonstop preferred
- Best balance of all factors
Translate the user's answer into RankingWeights:
RankingWeights(price=1.0, duration=0.1, stops=0.1)RankingWeights(price=0.2, duration=1.0, stops=0.3)RankingWeights(price=0.2, duration=0.3, stops=1.0)RankingWeights(price=0.6, duration=0.3, stops=0.3) (default)Run this Python code using the Bash tool (with the project venv):
source .venv/bin/activate && python3 -c "
import json
from flight_finder.scraper import FlightSearchParams, search_flights
from flight_finder.ranking import RankingWeights, rank_flights
from fast_flights import FlightData, Passengers
from fast_flights.filter import TFSData
params = FlightSearchParams(
origin='<ORIGIN>',
destination='<DESTINATION>',
departure_date='<YYYY-MM-DD>',
return_date='<YYYY-MM-DD or None>', # Set to None for one-way
trip_type='<round-trip or one-way>',
seat='<economy>',
adults=<1>,
max_stops=<None or int>,
)
result = search_flights(params)
weights = RankingWeights(price=<P>, duration=<D>, stops=<S>)
ranked = rank_flights(result.flights, weights=weights)
# Build Google Flights URL for validation
flight_data_list = params.build_flight_data()
tfs = TFSData.from_interface(
flight_data=flight_data_list,
trip=params.trip_type,
passengers=Passengers(adults=params.adults),
seat=params.seat,
max_stops=params.max_stops,
)
google_flights_url = f'https://www.google.com/travel/flights?tfs={tfs.as_b64().decode()}&hl=en&tfu=EgQIABABIgA'
# Output as JSON for parsing
output = {
'current_price': result.current_price,
'total_flights': len(result.flights),
'google_flights_url': google_flights_url,
'flights': []
}
for rf in ranked[:15]:
f = rf.flight
output['flights'].append({
'rank': rf.rank,
'name': f.name,
'price': rf.price_dollars,
'duration': f.duration,
'duration_min': rf.duration_minutes,
'stops': f.stops,
'departure': f.departure,
'arrival': f.arrival,
'arrival_ahead': f.arrival_time_ahead,
'is_best': f.is_best,
'score': round(rf.score, 4),
})
print(json.dumps(output, indent=2))
"
Adjust the parameters in the script based on what the user specified. If the search fails after retries, report the error and suggest trying again or adjusting parameters.
Format the results as a clear table. Include:
| # | Airline | Price | Duration | Stops | Departure | Arrival | Score |
|---|
After the table, include:
google_flights_url from the search output as a clickable markdown link (e.g., [View on Google Flights](url)). This lets the user verify results directly. If presenting multiple searches, include a link for each one.If the user specified a budget, highlight which flights are within budget and which exceed it.
If the user specified time preferences, note any flights that don't meet them (e.g., redeye departures when user said no redeyes).
After presenting results, offer options like:
If the user wants to refine, loop back to the relevant step. No need to re-ask parameters that haven't changed.
source .venv/bin/activatedeparture_date and return_date are required.