Agent Script Pattern: Enforce Required Workflows for a Topic

Use conditional transitions to guarantee users pass through required steps before accessing other features.

Use conditional transitions at the top of your instructions to force users through required steps. Unlike filtering with available when, these transitions execute immediately and guarantee the routing behavior.

Use filtering (available when) when you want to remove options. Use this required flow pattern (also described as a "conditional transition") when users must complete a step before anything else occurs.

ApproachWhen to Use
available whenControl which reasoning actions are available; LLM chooses among them
Conditional transitionRequire users to complete a step; no LLM choice

For critical flows like identity verification, a conditional transition in instructions is more reliable than available when filtering alone. While filtering restricts options, it doesn’t enforce workflows. For example, instead of prompting the user to verify their identity, the agent can exclusively choose options that don’t require user verification. A conditional transition guarantees the workflow before any reasoning takes place.

Pattern Examples:

  • Force unverified users through identity verification before they can access order management, returns, or any other sensitive topics.
  • Ensure order return topics ask the correct next question based on previous answers, and that all required questions are asked.

To require a topic flow before a user can move to any other topics, in the Topic Selector, place a conditional transition at the top of your instructions. If the condition is met, the transition happens immediately before any other processing.

Unverified users are immediately routed to the Identity topic. No topic classification takes place and no prompt is sent to the LLM. After the user completes verification with the Identity topic, the process starts over. Because the Verified variable is now set to True, the conditional is satisfied. The agent can proceed through the remaining instructions and the other topics in the Topic Selector are available to the user.

This pattern works in any topic, not just the topic selector. Use it when an individual topic requires a prerequisite.

  • Use the go_to_ prefix: Name transition actions with a go_to_ prefix (for example, go_to_orders, go_to_faq) so the LLM understands they navigate to other topics.
  • Place required flows first: Put conditional transitions at the top of instructions so they execute before any other instructions. If the agent transitions to another topic before reasoning, no prompt is sent to the LLM. Prior instructions aren't used or preserved, so executing them just increases latency and (in the case of running an action) can incur costs.
  • Use descriptive names: Avoid generic names like tool1 or action2; use names that describe the destination or purpose.