Lesson 5: Hotel Flow
We will design three complex steps to do the entire flow.
- Explore Step
- Present Step
- Compare Step
Hotel Flow Code
We will create a HotelFlow and add these three steps.
It is super easy and clean to configure the steps as follow:
Full flow code:
export class HotelFlow extends Flow {
public constructor() {
super(HotelFlow);
// this.useModel('claude-opus-4-6');
this.useModel('gpt-4o');
// this.useModel('gpt-5.1');
// this.useModel('nvidia-deepseek-v4-flash');
// If no configuration is provided, the default summarizes after 16 messages
// and keeps the most recent 8 messages in memory.
this.getMemory()
.setSummaryModel('gpt-4o')
.setSummaryConfig({ minMessages: 16, recentMessages: 8 })
.enableSummary('hotel-explore');
}
protected defineSteps(): Step[] {
return [
new ExploreStep(this, true)
.useMemory('hotel-explore')
.useModel('gpt-5.1')
.useModelParams<'gpt-5.1'>({
reasoning: { effort: 'low' },
}),
new PresentStep(this).useModelParams<'gpt-4o'>({
temperature: 0.5,
}),
new CompareStep(this).useModel('gpt-5.1').useModelParams<'gpt-5.1'>({
reasoning: { effort: 'low' },
}),
new EndStep(this).useMemory('end'),
];
}
}
How HotelFlow is configured
The constructor first selects gpt-4o as the flow's default model. Individual steps can override it: ExploreStep and CompareStep use gpt-5.1 with low reasoning effort, while PresentStep uses the default model with a temperature of 0.5.
Memory summarization
Hotel searches often take many turns while the assistant gathers dates, budget, room type, amenities, and location preferences. The constructor configures memory compaction for that conversation:
enableSummary('hotel-explore')enables summarization for the namedhotel-explorememory space.- When this memory reaches 16 messages, PicoFlow uses the model chosen by
setSummaryModel('gpt-4o')to compress the older conversation into a summary. recentMessages: 8keeps the latest eight messages unchanged, preserving the user's current request and the immediate context.- Later turns receive the summary together with those recent messages, rather than the complete conversation history.
Memory is opt-in per step. ExploreStep attaches the summarized hotel-explore memory through useMemory('hotel-explore'). EndStep instead uses its own end memory space, so it does not share the hotel-exploration conversation by default.
What are these steps?
- ExploreStep: Gathers all the information needed from the user to make a hotel booking. This is similar to the details you would enter on a site like hilton.com.
- PresentStep: Searches for suitable hotels based on the collected information and presents the options to the user.
- CompareStep: Allows the user to compare selected hotels based on price, amenities, and other key attributes.
Granularity of step design: The complexity of each step is fully controllable by the developer. Instead of using a large, monolithic ExploreStep, you can break >the process into many smaller steps, each responsible for collecting a specific piece of information. This approach increases the >reliability of the LLM flow because simpler steps reduce the likelihood of hallucinations.
However, using many small steps comes with a trade-off: without a more sophisticated routing mechanism, the user cannot easily go back and correct information entered in a previous step. In our design, we chose to group all information collection into a single step. This allows more flexible user navigation, at the cost of a slightly higher risk of LLM hallucination—something that can be mitigated with other techniques.
Wrapping up
Next, let's five in the implementation of each step.