Font Size:
Ask Joget AI

Set Agent Variable Tool

The Set Agent Variable tool lets the agent write a named value into its own running memory during a session, so later tasks in the same run can read and act on that value.

Before you start
You must declare the variable names in the agent's own settings before this tool can use them. Open the agent's properties and add the variables you need in the Agent Variables section, then add this tool to a task.

What it does

A Joget agent runs through one or more tasks in sequence. By default, each task starts fresh. The Set Agent Variable tool gives the agent a scratchpad: it can store a value under a named key at any point in a run, and any later task can read that value back.

When the LLM decides it has a piece of information worth saving for later, it calls this tool with the variable name and the value to store. The value is held in memory for the duration of the current run. Later tasks that include the Agent Variables prompt automatically receive those stored values as part of their context, so the LLM in each subsequent task knows what was saved.

This tool has no settings of its own. Its behaviour is entirely determined by the variable names you declare at the agent level.

When to use it

Use the Set Agent Variable tool when both of the following are true:

  • Your agent has more than one task, and information gathered in an earlier task is needed in a later one.
  • You need the agent to carry state forward without storing it externally.

Typical scenarios include the following:

  • CRM Qualification: Task 1 collects a prospect's company size and stores it as a variable. Task 2 reads that variable to recommend the right product tier without asking again.
  • HR Onboarding: Task 1 identifies the new employee's department and stores it. Task 2 uses the stored department to pull the correct policy documents and present them.
  • Procurement Approval: Task 1 checks whether an order exceeds the budget threshold and stores an approval_required flag. Task 2 reads the flag and routes accordingly.

When not to use it
Agent variables exist only for the duration of a single run. They are cleared when the run ends. If you need to persist information across multiple runs or across different sessions, use the Mem0 Chat Memory Tool instead.

If you only need to carry the agent's full response text forward, use the Store to Agent Variable enhancer, which captures the output automatically without requiring the LLM to call a tool explicitly.

Get started

How to use it

Add the tool from inside the AI Agent Builder:

  1. Locate the Run AI Agent element under the Tools section of the palette.
  2. Drag and drop the element into the Drop a tool here section.
  3. In the agent's settings panel, add the variables you need to the Agent Variables section. Give each one a clear name, for example customer_tier or approval_status .
  4. Select the task where the agent should store the value.
  5. Add the Set Agent Variable tool to that task from the Tools palette.
  6. Add the Agent Variables prompt to any later task that needs to read those values.
  7. Save the agent.

Configure Agent Properties

The Set Agent Variable tool has no configurable settings of its own. All configuration is done at the agent level in the Agent Variables section. The tool reads the declared variable names from there and makes them available to the LLM as the valid names it can write to.

No settings panel
When you add this tool to a task, you will see no fields to fill in. That is correct. Declare your variables in the agent's top-level settings, and the tool picks them up automatically.

Tips and gotchas

  • Declare variables before adding the tool. The LLM learns which variable names it can use from the agent's declared variable list. If no variables are declared, the tool offers the LLM nothing to write to.
  • Variables are in-memory for the current run only. They do not persist after the run ends and are not shared between different users or sessions.
  • Pair with the Agent Variable prompt on later tasks. Storing a variable is only half the job. The Agent Variables prompt injects the stored values into the LLM's context for each subsequent task. Without that prompt, later tasks will not see what was stored.
  • Variable names are case-sensitive. A variable declared as customer_tier must be referenced exactly as customer_tier . Mismatches cause the stored value to be ignored.
Created by Debanraj Ravindran Last modified by Debanraj Ravindran on Sep 20, 2026