Flow object
This page requires Python familiarity. It is a reference for developers writing transition functions inside flows.
The Flow object gives you control over how the agent moves between steps in a flow. It is available as a parameter in any flow-scoped function (transition function).
The two companion methods on the Conversation object – conv.goto_flow() and conv.exit_flow() – handle transitions between flows and are documented at the bottom of this page.
goto_step(step_name, condition_label)
Moves the agent to another step in the current flow. This replaces the current step’s prompt and functions with those of the target step.
Always call return immediately after goto_step().
The runtime executes your function to completion before honoring the transition. If you call goto_step() more than once without returning, each call overwrites the previous transition state – only the final one takes effect. Using return after each call prevents accidental overwrites and makes control flow explicit.
If step_name doesn’t match any step in the flow, the transition fails silently. Step names are case-sensitive. See transition functions – debugging for troubleshooting guidance.
Execution context matters
flow.goto_step() behaves differently depending on where it’s called:
- In a transition function (LLM step) – the LLM decides whether to call the function based on the step prompt and user input. The transition only happens if the LLM invokes the function.
- In a Function step – the code runs directly without LLM involvement. The transition is deterministic. Here, the
condition_labelparameter controls which edge is highlighted in the visual editor.
Conditional transition
Input validation and state update
This is the recommended structure: validate input, update state, transition, then return.
current_step
Type: str
Returns: The name of the current step the agent is in.
Useful for debugging or conditional routing when a single function serves multiple steps.
Companion methods on the Conversation object
These methods live on the Conversation object, not on Flow, but are commonly used alongside flow.goto_step() in transition logic.
conv.goto_flow(flow_name)
Transitions to a different flow at the end of the current turn. Can be called from any function – flow-scoped or global.
See triggering flows for all the ways to start a flow.
conv.exit_flow()
Exits the current flow and returns the agent to its default (non-flow) behavior. Exit steps are visually marked in yellow in the Flow Editor.
Every flow should have at least one exit path. Un-exited flows can cause the agent to hallucinate or loop. See the flows overview for more on flow design.

