Font Size:
Ask Joget AI

Agent Variables

Introduction

The Agent Variables prompt serializes the current agent variable state into a SYSTEM message, making accumulated runtime values visible to the LLM before it generates a response.

Note

You need an agent configured in AI Central Config before you can add any prompt plugin. See AI Central Configuration plugin for setup instructions. Agent variables must be set earlier in the same agent run (via Set Agent Variable or Store to Agent Variable) before this prompt can expose them.

What it does

Agent Variable reads from the in-memory key/value store maintained across the current agent execution. It then formats those values as a SYSTEM-role message and prepends it to the LLM conversation for that task.

You control the scope with the Variables grid. If the grid is left empty, the plugin injects every agent variable currently in context as a flat list. If you configure specific rows in the grid, only those named variables are injected, each optionally accompanied by a human-readable Display Label that replaces the raw variable key in the message the model sees.

This prompt is the bridge between earlier agent steps (where tools fetch and store data) and later steps (where the LLM needs to reason about that data). Without it, the model has no awareness of values set by previous tools in the same run.

When to use it

Use Agent Variable whenever a later task in your agent needs to reason about values that were set by an earlier task, tool, or enhancer.

Common scenarios include the following:

  • Multi-step CRM qualification: An earlier task uses a Database Query Tool to fetch account tier and deal stage, stores them as agent variables, and then Agent Variable exposes them so the next task can generate a tailored pitch strategy.
  • HR leave approval chain: A tool stores the employee's leave balance and the manager's decision as variables. The Agent Variable injects both, so the final task can draft a notification email that references the actual balance and outcome.
  • Procurement risk scoring: A scoring tool writes a numeric risk score and a list of flagged clauses to variables. Agent Variable surfaces them so the next LLM task generates a human-readable risk summary grounded in the actual scores.
  • Sequential document drafting: A first task extracts key facts from a form and stores them. Agent Variable then makes those facts available to a second task that drafts a contract section without re-fetching the form data.
When not to use it
Do not use Agent Variable to inject form record data directly. For that, use Form Data, which loads and formats a complete form record. Agent Variable is for values the agent itself has computed or stored during the current run. If you need to pass a static value, use Text Prompt with a $\{varName\} placeholder instead.

Get started

How to use it

To use the Agent Variables prompt, follow these instructions:

  1. Locate the Agent Variables element under the Prompts section of the palette.
  2. Drag and drop the element into the Drop a prompt here section.

Configure Form Properties

To properly integrate and configure the Beanshell, set the following fields:

  • Personalized Name: Specify a custom name to display in the node viewer.
  • Variables: Click Add. List of specific variables to inject. Leave empty to inject all current agent variables.
    • Variable Name: The exact key of the agent variable as it was stored. Case-sensitive. This is a required field.
    • Display Label: A human-readable label shown in the injected SYSTEM message instead of the raw key. Helps the model understand what each value represents.

Samples

Inject all variables (empty grid)
Variables grid: (empty)

// The plugin injects every variable in context:
// e.g. applicantName, leaveBalance, managerDecision, submissionDate
Inject specific variables with labels
Variables grid:
  Variable Name: riskScore      Display Label: Supplier Risk Score
  Variable Name: flaggedClauses Display Label: Policy Violations Found
  Variable Name: reviewerName   Display Label: Assigned Reviewer

// Injected SYSTEM message will use the display labels, not the raw keys.

Best Practices

The following points will save you debugging time.

  • Variable names are case-sensitive. If the tool stored the value as riskScore and you type RiskScore in the grid, the plugin finds nothing, and the row is silently omitted from the injected message.
  • An empty grid injects everything. This is convenient during development but noisy in production. Once you know which variables the model actually needs, specify them explicitly to keep the context lean.
  • Variables must exist before this prompt runs. Agent Variable reads the state at the moment this task executes. If the variable was supposed to be set by an earlier task but that task failed or was skipped, the value will be missing. Check task ordering and error handling.
  • Display Labels help the model. A raw key like v_hr_lb_2024 tells the model nothing. A Display Label like "Remaining Leave Balance (days)" gives the model enough context to use the value correctly.
  • This prompt does not write variables. Agent Variable is read-only at prompt time. To write or update a variable from within a task, use Set Agent Variable  (a tool) or Store to Agent Variable (an enhancer).
Created by Debanraj Ravindran Last modified by Debanraj Ravindran on Jul 10, 2026