Execution context for storing and retrieving values during a run.

Functions

get

fn (key: Str | Var): Any
fn (key: Str | Var, default-value: Any): Any

Retrieve a value from the execution context by key.

With one argument, returns the stored value or null if key is not set. With two arguments, returns default-value when the key is unset or stored as null.

Example

api-key ::hot::ctx/get("anthropic.api.key")
model   ::hot::ctx/get("brain.model", "claude-sonnet-4-5")

mark-secret

fn (value: Any): Any

Mask value in this run's call records and return it unchanged, without storing it in the execution context. Maps and Vecs register each value inside them.

Use this for a credential that arrives as an ordinary argument, like a per-call opts Map, so that it is masked wherever it appears: inside composed strings like Bearer ${key}, and URL-encoded or base64-encoded.

Values shorter than 8 bytes are masked only where they are the whole value. Records of calls that finished before this call and were already written keep what they had: mark a credential before passing it on.

Example

::ctx ::hot::ctx

opts {api-key: ::ctx/get("example.api.key")}
api-key ::ctx/mark-secret(opts.api-key)
::hot::http/request("GET", "https://api.example.com/v1/me", {"Authorization": `Bearer ${api-key}`}, null)
// The records of these calls show `Bearer <secret>`

set

fn (ctx-map: Map)
fn (key: Str | Var, value: Any): Any

Store value in the execution context under key. Also accepts a map to set several values at once.

If the key is defined in ctx metadata, the secret setting of the key determines whether the value is masked in logs.

Example

::ctx ::hot::ctx

::ctx/set("request-id", Uuid())
::ctx/set({tenant: "acme", region: "us-east-1"})

::ctx/get("request-id")

set-secret

fn (ctx-map: Map)
fn (key: Str | Var, value: Any): Any

Store value in the execution context under key, explicitly marking it as a secret.

Prefer this over ::hot::ctx/set for runtime-created secrets that are not defined in ctx metadata, so that the value will be masked in logs.

Example

::ctx ::hot::ctx

response ::hot::http/post("https://auth.example.com/token", {code: "abc123"})
token response.body.access_token
::ctx/set-secret("provider.access.token", token)
// Records of this call and later ones show the value as <secret>