Skip to main content

Overview

In Julep broadly speaking there are two types of steps:

Control Flow Steps

These steps control the flow of the task. They are used to create conditional logic, loops, and parallel execution.

Key-Value Steps

These steps are used to get and set values in the task.

Iteration Steps

These steps are used to iterate over a collection.

Conditional Steps

These steps are used to create conditional logic.

Other Control Flow Steps

These steps are used to control the flow of the task.

The steps defined out here are in the YAML format. You can learn more about the YAML format here.

Control Flow Steps

Prompt Step

Send messages to the AI model:
YAML
When auto_run_tools is set to true in a prompt step, any tools available to the agent will be automatically executed if the model decides to use them. The results are then fed back to the model to continue processing. This is particularly useful for creating autonomous workflows where the agent can gather information and make decisions without manual intervention.
The response_format setting allows you to request structured output from the model. There are two main options:
  • type: json_object - Ensures the model responds with valid JSON
  • type: json_schema - Enforces a specific JSON structure defined by a schema
When using response_format, make sure to instruct the model to produce JSON in your prompt (via system or user message) for best results. Response format support varies by model provider - check the supported models documentation for compatibility.
In the prompt step we offer a bunch of Python functions to help you manipulate data. Here is a list of the functions you can use:
  • Standard library modules:
    • re: Regular expressions (safe against ReDoS)
    • json: JSON encoding/decoding
    • yaml: YAML parsing/dumping
    • string: String constants and operations
    • datetime: Date and time operations
    • math: Mathematical functions
    • statistics: Statistical operations
    • base64: Base64 encoding/decoding
    • urllib: URL parsing operations
    • random: Random number generation
    • time: Time operations
  • Constants:
    • NEWLINE: Newline character
    • true: Boolean true
    • false: Boolean false
    • null: None value

Tool Call Step

Execute tools defined in the task:
YAML

Evaluate Step

Perform calculations or data manipulation:
YAML
In the evaluate step we offer a bunch of Python functions to help you manipulate data. Check out the Python Expressions for more information.

Wait for Input Step

Pause workflow for user input:
YAML

Subworkflow Step

Executing a subworkflow from a main workflow:
YAML
  • The arguments passed from the main workflow to the subworkflow are available in the steps[0].input of the subworkflow.
  • The result of the subworkflow is available in the steps[1].output.result of the main workflow.
  • The Input/Output Data References between steps is exclusive to the workflow they are defined in. A workflow cannot reference the input or output of another workflow between the steps. To learn more about Input/Output Data References click here.
Self recursion is allowed in a subworkflow but not in a main workflow.

Key-Value Steps

Get Step

Retrieve values from storage:
YAML

Set Step

Store values for later use:
YAML
Values stored using the set step are added to the workflow’s global state object, which can be accessed anywhere in the workflow using state.variable_name. For example:
YAML
Each subworkflow has its own isolated state object. Values set in one subworkflow are not accessible from other subworkflows or the parent workflow.

Label Step

Label a step to make it easier to identify and access those values later in any step:
YAML
In any steps following the label step, you can access the values set in the label step using the $ steps['label_name'].input.attribute_name or $ steps['label_name'].output.attribute_name syntax. For example:
YAML

Iteration Steps

Foreach Step

Iterate over a collection:
YAML

Map-Reduce Step

Process collections in parallel:
YAML
  • By default the parallelism if not mentioned is 100. If mentioned, it is the maximum number of steps that can run in parallel concurrently.
  • When using over step, the map step is executed for each value in the collection.
  • The reduce step is executed after the map step.

Conditional Steps

If-Else Step

Conditional execution:
YAML

Switch Step

Multiple condition handling:
YAML

Other Control Flow

Sleep Step

Pause execution:
YAML

Return Step

Return values from workflow:
YAML

Log Step

Log messages or specific values:
YAML

Error Step

Handle errors by specifying an error message:
YAML

Example: Complex Workflow

Here’s an example combining various step types:
YAML

Best Practices

Step Organization

  • Group related steps logically
  • Use comments to explain complex steps
  • Keep step chains focused and manageable

Error Handling

  • Use if-else for error conditions
  • Provide fallback options
  • Log important state changes

Performance

  • Use parallel execution when possible
  • Optimize data passing between steps
  • Cache frequently used values

Support

If you need help with further questions in Julep: