> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cogniagent.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Agent Variable Node

> Change an agent variable from a workflow, such as a counter, a status or the last time something ran.

The Update Agent Variable step changes one [agent variable](https://docs.cogniagent.ai/features/agent-variables.md) of the agent the workflow belongs to. Later steps, other workflows, conversation flows and coworkers of that agent read the new value straight away.

## When to use

* **Keep a status** that other items read, such as `open` or `closed`
* **Remember when something last ran**, so the next run knows where to start
* **Count** how many requests came in today
* **Switch a behavior** for the agent's conversation flows and coworkers

For data that belongs to one run only, use [Update Variable](https://docs.cogniagent.ai/nodes/actions/update-variable.md). Agent variables belong to the whole agent and stay until changed.

## Fill in the step

| Field | What it does |
| - | - |
| **Variable group** | Pick one of the agent's variable groups |
| **Variable** | The name of an existing variable |
| **Value** | The new value. Takes `{{…}}` from earlier steps |

The value must fit the variable's type. A number variable refuses text, and a date variable refuses a value that isn't a date. The group can't be `environment`: that name is reserved.

> [!NOTE]
>
> The step changes a variable that already exists. It can't set a Secret: only people set secrets.

## What it gives back

| Output | Meaning |
| - | - |
| `revision` | The variable's new version number |
| `value` | The value now stored |

Use them in later steps, for example `{{update_agent_variable_1.value}}`.

## Example: remember the last run

**1. Do the work**

A scheduled workflow fetches new orders.

**2. Save the time**

Add an Update Agent Variable step. Pick the **Variable group** `Sync`, the **Variable** `last_run`, and the **Value** `{{start_1.date}}`.

**3. Read it next time**

The first step of the next run asks only for orders after `{{agent.Sync.last_run}}`.

## Good to know

* Every change goes to the group's **History**, under the workflow's name.
* A workflow of another agent can't change this agent's variables.
* Changing a group's key, or renaming the variable, rewrites the step for you.

## Next steps

> [card] [Agent variables and secrets](https://docs.cogniagent.ai/features/agent-variables.md)
>
> Types, history and secrets.

> [card] [Update Variable](https://docs.cogniagent.ai/nodes/actions/update-variable.md)
>
> Remember something for one run.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.