States are the backbone of a well-structured agent conversation. Each state represents distinct steps or phases within a conversation, and help break down complex conversations into smaller, more manageable segments.

Why states matter

Organization and clarity

States provide a clear structure, making it easier to design, understand, and maintain agent flows.

Context management

States help overcome the limitations of limited memory capacity of language models, prevent hallucinations, and maintain the conversation’s accuracy.

Error handling

Breaking conversations into states allows for easily identifying errors and unexpected behavious in the agent’s conversation flow.

Improved accuracy

By focusing on one step at a time, states help language models stay on track, especially in longer conversations, and provide natural breakpoints for user confirmation.

State design principles

Example: States in flight booking

Let’s revisit the flight booking example to see states in action:

1

Greeting state

Agent welcomes the user and asks how it can help.

2

Discovery state

User indicates they want to book a flight. Agent presents flight options.

3

Booking state

Agent gathers passenger details (names, etc.) to confirm flight and seat choices.

4

Payment state

Agent securely processes payment information.

5

Confirmation state

Agent provides booking summary and offers further assistance.

Referencing states in agents

States can be referenced in the global insructions and state instructions by typing ’@’ and selecting the required state from the dropdown.

While you’ll select states using the ’@’ dropdown on the platform, throughout this documentation, states are referred to as state:StateName.

State transitions

State transitions define how the agent moves from one state to another during a conversation. These transitions are triggered by user input, variable values, or the completion of tasks within a state.

How transitions work

Conditional logic

Transitions are based on conditions. For example, “If the user confirms the flight selection, then transition to state:BookingState.”

User input driven

What the user says or does determines the next state. For example, “If the user provides their name, then transition to state:VerifyDetails.”

Variable-based transitions

You can set transitions based on the value of variables. For instance, “If variable:user_age is greater than 60, then transition to state:SeniorDiscount.”

Example: Transition in flight booking

Example transition instruction: Once the user has chosen a flight, update the variable selected_flight and then transition to state:booking_state

1

From greeting to discovery

When the user says “I want to book a flight,” the agent transitions from the “Greeting State” to the “Discovery State.”

2

From discovery to booking

Once the user has chosen a flight, the agent updates the selected_flight variable and then transitions to the “Booking State.”