Skip to content

Commit f914f62

Browse files
committed
style: travel planner
1 parent 4ee6538 commit f914f62

3 files changed

Lines changed: 29 additions & 14 deletions

File tree

ai-server/src/mastra/agents/travel-planner-agent.prompt.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ render the result as UI widgets via showComponents.
88
1. Extract from the user request:
99
- from (departure city — use EXACTLY the name as given by the user, no translation)
1010
- to (destination city — use EXACTLY the name as given by the user, no translation)
11-
- stops (intermediate stop cities in travel order — use EXACTLY the names as given by the user, no translation;
12-
e.g. "Stopp in Wien" → stops: ["Wien"], "via Vienna" → stops: ["Vienna"];
13-
if no stops mentioned → stops: [])
11+
- stops (intermediate stop cities on the OUTBOUND journey only — use EXACTLY the names as given by the user, no translation;
12+
e.g. "Stopp in Wien", "über Wien", "via Wien" → stops: ["Wien"];
13+
only add a city here if the user explicitly says it is on the way TO the destination;
14+
if no outbound stops mentioned → stops: [])
15+
- returnStops (intermediate stop cities on the RETURN journey only — use EXACTLY the names as given by the user, no translation;
16+
e.g. "beim Heimflug Stopp in Paris", "auf dem Rückweg über Paris", "return via Paris", "on the way back stop in Paris" → returnStops: ["Paris"];
17+
only add a city here if the user explicitly mentions it is on the way BACK / return / Heimflug / Rückflug / Rückweg;
18+
if no return stops mentioned → returnStops: [])
1419
- departDate (ISO 8601)
1520
- returnDate (ISO 8601)
1621
Resolve relative dates ("morgen", "nächste Woche", "ab Mai") against today's date.
1722
If from/to or dates are missing, still proceed with your best guess.
1823
1924
2. Call the workflow tool "packageTourWorkflow" exactly ONCE with
20-
{ from, to, stops, departDate, returnDate }.
25+
{ from, to, stops, returnStops, departDate, returnDate }.
2126
It returns:
2227
- legs — array of { from, to, candidates[] } in travel order:
2328
[from→stops[0]], …, [stops[n-1]→to], [to→stops[n-1]], …, [stops[0]→from]
@@ -42,11 +47,13 @@ render the result as UI widgets via showComponents.
4247
- Only skip the hotel (same-day transit) if the arrival is in the morning or afternoon
4348
AND there is a plausible onward flight the same day AND the user's request gives no hint
4449
of a longer stop.
45-
- If an overnight stay is needed → pick ONE hotel from destination.hotels
46-
based on the user's preferences (stars, budget, location, etc.) and render a hotelWidget.
47-
- If a city requires an overnight stay but destination.hotels is empty (or no
48-
candidate matches the preferences), do NOT render a hotelWidget for that city
49-
and note it in the messageWidget instead.
50+
- If an overnight stay is needed → ALWAYS render a hotelWidget. Pick ONE hotel from
51+
destination.hotels that best matches the user's preferences (stars, budget, location).
52+
Preferences are a guide for ranking candidates, NOT a hard filter — if no hotel
53+
perfectly matches, pick the closest available option and note the compromise briefly
54+
in the messageWidget. NEVER skip a city's hotel because of unmet preferences.
55+
- Only omit a hotelWidget if destination.hotels is completely empty (no candidates at all),
56+
in which case note it in the messageWidget.
5057
5158
4. Render the result with EXACTLY ONE showComponents call, in this order:
5259
1. messageWidget({ text: "<summary of the proposed trip in the user's language>" })

ai-server/src/mastra/workflows/package-tour-workflow.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ const packageInputSchema = z.object({
1111
stops: z
1212
.array(z.string())
1313
.default([])
14-
.describe('Intermediate stop cities in travel order between from and to.'),
14+
.describe(
15+
'Intermediate stop cities on the OUTBOUND journey, in travel order between from and to.',
16+
),
17+
returnStops: z
18+
.array(z.string())
19+
.default([])
20+
.describe(
21+
'Intermediate stop cities on the RETURN journey, in travel order between to and from.',
22+
),
1523
departDate: z
1624
.string()
1725
.describe('Planned outbound departure date (ISO 8601, e.g. 2026-05-15).'),
@@ -106,8 +114,8 @@ const findFlightsStep = createStep({
106114
};
107115
await emitStepStatus(ctx, 'findFlights', 'started');
108116

109-
const { from, to, stops } = inputData;
110-
const citySequence = [from, ...stops, to, from];
117+
const { from, to, stops, returnStops } = inputData;
118+
const citySequence = [from, ...stops, to, ...returnStops, from];
111119
const legPairs = citySequence
112120
.slice(0, -1)
113121
.map((city, i) => ({ from: city, to: citySequence[i + 1] }));
@@ -155,7 +163,7 @@ const findHotelsStep = createStep({
155163
await emitStepStatus(ctx, 'findHotels', 'started');
156164

157165
const init = getInitData<z.infer<typeof packageInputSchema>>();
158-
const cities = [...init.stops, init.to];
166+
const cities = [...init.stops, init.to, ...init.returnStops];
159167
const bridge = readBridge(requestContext);
160168
const agent = mastra.getAgent('hotelAgent');
161169

src/app/domains/ticketing/ai/travel-planner/travel-planner-page.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@
455455

456456
.flight-cell {
457457
flex: 1 1 0;
458-
min-height: 205px;
458+
min-height: 200px;
459459
display: flex;
460460
flex-direction: column;
461461
}

0 commit comments

Comments
 (0)