Variables
A variable is a named value you define once and use as a {{name}} token. Global variables live under Lab > Variables, so you do not declare them again in each agent’s Variables section. This page is part of the Lab builder.

Where a token gets its value
Section titled “Where a token gets its value”One server-side resolver fills every {{name}} token, in this order. The first match wins.
- A value supplied when the run starts (the Fill run variables dialog, or Trigger now on a saved agent).
- The agent’s own variable definition and its default.
- A global variable from Lab > Variables.
- A built-in variable.
- Otherwise the token is unresolved, and the run does not start. The error names the token.
Saved agents that already define their own variables behave as before. An agent’s own default beats a global of the same name, so you can still override a global for one agent.
Define a global variable
Section titled “Define a global variable”Lab > Variables lists every global variable with its type, whether it is a secret, and how many saved agents and prompts use it. New variable opens an editor:
- Name: letters, numbers and underscores. A built-in name such as
dateis refused. - Type: text, long text, number, or one of a list. The value is checked against the type.
- Value and an optional Description.

Deleting a variable warns you when saved agents or prompts still use it. They stay unresolved until you define it again.
The agent builder shows a variable that a global satisfies as using global and does not ask you to define it. The run dialog skips it too, and runs straight away when every variable is covered. A saved prompt you pick fills a global in without asking, and asks only for the names nothing can supply.
Secrets
Section titled “Secrets”Turn on Secret to store a credential as {{secret.NAME}}. A secret is write-only:
- It is sealed on this machine with the same key store as your provider keys. It is never kept in the database in plain text.
- The browser never gets it back, only set or not set. Leave the value blank when you edit to keep the stored one.
- It is never exported with an agent or a prompt file. An export keeps the
{{secret.NAME}}placeholder and notes that the target needs a value. - Stored runs and Rerun snapshots keep the placeholder.
A secret is filled in only inside an MCP server’s settings: its command, arguments, environment, headers and URL. For example, set a server header to Bearer {{secret.GITHUB_TOKEN}}. Using a secret anywhere else, such as a prompt, stops the run with a clear message, because everything a model sees is recorded in the run history.
As a second guard, a secret’s value is replaced with [secret] in any run event Cortex stores or streams, in case an MCP server echoes it back in a result or error. This covers Cortex’s own run history. Files the agent itself writes, such as framework trace files, are outside it, so treat a secret like any credential you hand to a tool.
Built-in variables
Section titled “Built-in variables”| Token | Value |
|---|---|
{{date}} |
Today, YYYY-MM-DD, in the server’s timezone |
{{time}} |
The current time, HH:MM |
{{datetime}} |
Date and time together |
{{weekday}} |
The day name, such as Thursday |
{{timezone}} |
The IANA timezone name |
{{workspace}} |
The agent’s workspace directory, when one is set |
{{agentName}} |
The agent’s name, when one is set |
Built-ins have the lowest precedence. A variable you define with the same name in an agent wins.
Moving agents and prompts
Section titled “Moving agents and prompts”By default, exporting an agent as code or as a file keeps {{name}} tokens as text. The export notes list each global variable it references by name, and a secret one as needing a value on the target. Define a variable with the same name on the other machine.
Include referenced variables
Section titled “Include referenced variables”The agent export and the prompt export have an Include referenced variables switch, off by default. It shows how many variables the export references. When it is on:
- Each referenced non-secret variable is written with its value: in a prompt file under
variables, in an agent file undermetadata["cortex-variables"], and in exported TypeScript as a commented// Cortex variablesblock (code cannot carry Cortex globals, so the comment is for whoever runs it). - A referenced secret is written as its name only, marked as needing a value on the target. A secret’s value is never in any export or file.
The file format version does not change. A Cortex that does not know the block ignores it, and a file without it imports as before.
Importing
Section titled “Importing”Importing an agent file, a prompt file or a variables file shows one Variables block. For each name the content references it says how it is satisfied here: set by the agent, a global variable, a built-in, or not defined. For each variable the file carries you choose:
- Create it with the file’s value, or skip it.
- On a name that already has a different value: keep mine, replace it with the file’s, or save the file’s under a new name (such as
name_2). The imported text follows the new name. - Use my existing variable instead: the imported text is rewritten to your variable’s name. This also works for a name the file does not carry.
A secret in a file is only a name. It is listed as needing a value here; define it in Lab > Variables. For prompts, the prompts and their variables are saved together or not at all. For an agent file, nothing is saved to Variables until you press Save variables.
Export and import the whole list
Section titled “Export and import the whole list”Lab > Variables has Export and Import. The file is cortex-variables version 1: every variable with its type, value, description and options. Secrets are listed by name only (“set on the source”). An import previews the same plan before anything is saved, and a file over 2 MB or 500 variables is refused.
Variables in chat
Section titled “Variables in chat”A chat session resolves {{name}} tokens in its persona, system prompt and task context the same way a run does: the session’s own variables, then global variables, then built-ins. Text without a token is sent as written. A token nothing defines stays as typed and is listed as a warning in the session info instead of stopping the chat. A {{secret.NAME}} in these fields is refused with the same message as a run, because secrets resolve only in MCP server settings. Tokens are resolved when the session’s agent is built, so a changed variable applies from the next rebuild.
Install
Bun (recommended)bun add reactive-agentsNode 22.5+npm install reactive-agentsGet notified on new releases
Release notes, about once a month.