Session State
In this article
- Say which id keys a session record, a run and a user, and predict what breaks when one session id is reused for a second task.
- Name the fields a session record holds (selected order, pending action, workflow step, expiry) and keep them apart from the message list.
- Decide which copy the next reply follows when the chat text and the session record disagree about a pending action.
- Predict what a returning id finds after its session was closed or its expiry passed, and what the reply must then say.
- Terms defined here: session state.
Overview
A support chat is a task that takes several turns, and the model forgets each turn the moment it answers. Something outside the model has to know that this chat is about order 8841, that a $35 refund was offered and not yet confirmed, and that the customer's next "yes" is the answer to that offer. That something is a small record with an id, a few fields and an end date.
Brightline, the home-internet provider from "Context, State, Memory and Knowledge", is made up, and so are its orders and numbers. Its support assistant can look up an order, issue a refund of at most $50 (the issue_refund code checks the cap), hand a chat to a person and keep a small memory per returning customer. Follow one of its chats to see which ids find the record, what the record holds, which copy wins when the chat disagrees, and what happens when the record runs out.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- A record for one conversation
- The messages are a separate list
- Two copies of one refund
- Three ids, three scopes
- Reading the record by id
- When a session ends
- Common mistakes
- Sources
- Check yourself, 13 questions