Stores a value in the Agent’s state. Use to remember data across steps. Set state block

Overview

The Set state block is a core building block that connects information between different parts of your blueprint, interface, and code. It acts as a bridge, allowing data to flow from one part of your workflow to another - whether that’s from blueprint to interface, between different blueprint blocks, from interface back to blueprint, or to and from custom Python code. You can specify the variable name, value, and value type (plain text or JSON). The value is then available in subsequent blocks via the state variable.

Common use cases

  • Storing user input or intermediate results
  • Passing data between blocks in a workflow
  • Saving API responses or generated content for later use
  • Managing workflow state or flags
  • Storing block results to display in interface components
  • Persisting data between interface updates and refreshes

How it works

  1. Link Variable: Specify the name of the state variable to set.
  2. Value type: Choose whether the value is plain text or JSON. The default if not specified is plain text.
  3. Value: Enter the value to store.
The block saves the value in the specified state variable. You can reference this variable in later blocks using the state syntax, for example, @{state.variable_name}.

Examples

Text generation workflow

This example shows how to generate text and display it in the interface using state management. Blueprint Flow:
  1. UI Trigger → User clicks “Generate” button
  2. Text generation → Creates content based on prompt
  3. Set state → Stores generated text
Interface → Has a Text component that displays the text from the state variable Block Configuration:
  • Link Variable: generated_text
  • Value type: text. The default if not specified is plain text.
  • Value: @{result}. This variable is the text generated by the text generation block that precedes the Set state block.
Set state workflow This workflow enables automated text generation and display in the interface.

Form submission workflow with JSON value type

This example shows how to package multiple form field responses into a single state variable. It’s useful when collecting and storing related data from interface forms. Blueprint Flow:
  1. UI Trigger → User submits a registration form. All the form fields have Link Variables set to the name of the field.
  2. Set state → Stores all form fields as JSON
Block Configuration:
  • Link Variable: form_data
  • Value type: JSON
  • Value:
    {
      "firstName": @{firstName},
      "lastName": @{lastName},
      "email": @{email},
      "phoneNumber": @{phoneNumber},
      "address": {
        "street": @{address.street},
        "city": @{address.city},
        "state": @{address.state},
        "zipCode": @{address.zipCode}
      },
      "preferences": {
        "newsletter": @{preferences.newsletter},
        "notifications": @{preferences.notifications}
      }
    }
    
Set state workflow To access specific fields of the JSON data, use the state syntax, for example @{form_data.firstName} or @{form_data.address.city}.
To access elements of the state variable using Python, treat it as a dictionary. For example, @{state["form_data"]["firstName"]} or @{state["form_data"]["address"]["city"]}.

Fields

NameTypeControlDefaultDescriptionOptionsValidation
Link VariableBinding--Set the variable here and use it across your agent--
Value typeText-text-
  • text - Plain text
  • JSON - JSON
-
ValueTextTextarea----

End states

Below are the possible end states of the block call.
NameFieldTypeDescription
Success-successIf the function doesn’t raise an Exception.
Error-errorIf the function raises an Exception.
The Set state block returns the value that was set in the state variable. You can access this value in the following block as @{result}, or you can use the state syntax to access the value in the state variable, for example @{form_data}.