Font Size:
Ask Joget AI

Store to Agent Variable

Introduction

The Store to Agent Variable enhancer saves an agent task's output into a named variable that is available to all subsequent tasks in the same agent run, enabling tasks to build on each other's results.

Note

The agent variable you target must be declared in the agent's Properties panel before you configure this enhancer. Agent variables are scoped to a single run and do not persist after the agent completes.

What it does

After the agent task finishes, Store to Agent Variable captures the response and stores it under the variable name you specify. It offers two source modes:

Full Response stores the entire response text as the variable value. Use this when the output is a plain-text value that the next task should receive verbatim.

JSON Field parses the response as a JSON object and extracts only the value at a dot-notation path you specify. For example, a path of customer.name extracts "Alice" from \{"customer": \{"name": "Alice"\}\}. Use this when the LLM returns a structured object and only one field is needed downstream.

The stored value is immediately available to all subsequent tasks via the Agent Variables Prompt. It can also be written to a form or workflow variable by a later enhancer.

When to use it

Use Store to Agent Variable when all of the following are true:

  • One task produces a value that a later task in the same agent needs.
  • You do not need the value to persist beyond the current agent run.
  • You want to avoid writing to a form or workflow variable just to pass data between tasks.

Typical scenarios include the following:

  • CRM: Staged Enrichment: Task 1 extracts a company name from an email. Task 2 uses that name to look up open opportunities. Store to Agent Variable passes the name between tasks.
  • HR: Multi-step Analysis: Task 1 classifies a leave request as routine or exceptional. Task 2 drafts a response tailored to the classification. The variable carries the classification forward.
  • Procurement: JSON Field Routing: Task 1 extracts invoice fields as JSON. Store to Agent Variable pulls the vendor name from the JSON and injects it into Task 2's prompt for a supplier check.
When not to use it

Get started

How to use it

To add the Store to Agent Variable enhancer:

  1. Locate the Store to Agent Variable element under the Enhancers section of the palette.
  2. Drag and drop the element into the Drop an enhancer to here section.

Configure Enhancer Properties

Always-visible fields

  • Variable Name: The agent variable that receives the value. Enter the exact name declared in the agent's Properties panel. Case-sensitive. This field is required.
  • Value Source: Whether to store the full response or extract a JSON field. Full Response (text) to store the whole output. JSON Field to extract one value from a JSON response.

JSON Field mode

This field appears only when Value Source is set to JSON Field:

  • JSON Field Path: The dot-notation path into the JSON object. A path such as order.id or status. Extracts the matching value from the JSON response.

Samples

JSON Field mode: extract an invoice number
Agent variable declared: inv_number

Task 1 output (after JSON Extractor runs first):
{"invoice_number": "INV-2024-001", "amount": 5000, "vendor": "Acme Corp"}

Store to Agent Variable settings:
  Variable Name: inv_number
  Value Source: JSON Field
  JSON Field Path: invoice_number

Result: inv_number = "INV-2024-001"

Task 2 uses the Agent Variable prompt referencing inv_number
to inject "INV-2024-001" into its system prompt automatically.

Best Practices

  • Declare the variable first. If the variable name does not match a declared variable, the value is written to an undeclared key, and the Agent Variables prompt will not inject it correctly.
  • JSON Field path is case-sensitive. Invoice_Number and invoice_number are different paths. Match the exact key casing the LLM returns.
  • Pair with JSON Extractor for chatty models. If the LLM wraps the JSON in prose or code fences, place JSON Extractor Enhancer before this enhancer so JSON Field mode receives a clean object.
  • Variables are run-scoped. The value does not carry over to a second invocation of the same agent. For persistent storage, follow up with Store to Form Enhancer.
  • The Set Agent Variable Tool covers the same write but runs during a task (in the Tools phase) rather than after it. Use the tool when the variable must be set mid-task; use this enhancer when you want to capture the final response.
Created by Debanraj Ravindran Last modified by Debanraj Ravindran on Jul 10, 2026