Library
REF 10 Cheat Sheet · Reference

agent variable + Instruqt-Var

The agent's variable store is a key-value bridge between scripts and assignment bodies. Scripts set keys; bodies read them via [[ Instruqt-Var ]] interpolation.

agent variable set Script side · write

Store a value. Available in subsequent scripts (any host) and to the body via [[ Instruqt-Var ]].

DB_URL="postgresql://..." agent variable set DB_URL "$DB_URL" # Multi-line values OK; single string # limit. For structured payloads use a # JSON broker sidecar instead.
agent variable get Script side · read

Read a value previously set. Common in cleanup to retrieve resource IDs for deletion.

PROJECT_ID=$(agent variable get \ ES_PROJECT_ID) curl -X DELETE \ "https://api.example.com/projects/$PROJECT_ID" \ -H "Authorization: Bearer $TOKEN"
Instruqt-Var in body Body side · interpolation

Render a stored value inside assignment.md. Works inside any string field, including fenced code blocks.

Database URL: `[[ Instruqt-Var key="DB_URL" hostname="db" ]]` ```bash,run psql "[[ Instruqt-Var key=\"DB_URL\" hostname=\"db\" ]]" ```
_SANDBOX_ID gap Auto-injected, but…

_SANDBOX_ID is a shell env var, not in the agent variable store. Bridge it explicitly if the body needs it.

# In track_scripts/setup-workstation: agent variable set SANDBOX_ID \ "$_SANDBOX_ID" # In assignment.md: URL: `https://app-8080-[[ Instruqt-Var key="SANDBOX_ID" hostname="..." ]] .env.play.instruqt.com`
Bridging cloud creds Surface in body

Cloud credential env vars (INSTRUQT_AWS_ACCOUNT_, etc.) are* in the agent variable store automatically — no bridge needed. Bridge synthesized values.

# Auto-injected — works directly: [[ Instruqt-Var key="INSTRUQT_AWS_ACCOUNT_LAB_ACCOUNT_ID" hostname="cloud-client" ]] # Synthesized values need a bridge: agent variable set CONSOLE_URL \ "https://${ACCOUNT_ID}.signin.aws.amazon.com"
Cross-host coordination Single string limit

Agent variables are visible to every host. For passing one or two values between hosts, this is the lightest mechanism.

# On the leader VM: TOKEN=$(generate_token) agent variable set CLUSTER_TOKEN \ "$TOKEN" # On a peer VM (later setup or # challenge): TOKEN=$(agent variable get \ CLUSTER_TOKEN) join_cluster --token "$TOKEN"
For structured payloads: use a JSON broker sidecar (HTTP server on a port returning JSON). Single-string keys get awkward fast for multi-field state.
Notes