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

# Data Variables

> The data.integer, data.message and data.messages components: a value kept for an execution or a session.

A data component holds one value that other components read from their inputs and write to their outputs. It is never a
step: no flow route enters or leaves it, and a component reaches it through a data connection to its data reference. A
data component nothing refers to fails [the definition's check](https://docs.blobhub.io/blob-types/workflow/operations/check-definition.md) with
``Component `<name>` is not referred to``.

`data.integer` holds an `integer`, `data.message` a `message` and `data.messages` a list of them
([Data Types](https://docs.blobhub.io/blob-types/workflow/workflows/data-types.md)). A conversation that many parties write to is a
[`data.thread`](https://docs.blobhub.io/blob-types/workflow/workflows/component-data-thread) instead.

## Persistence

A data component's `persistence` port says where its value lives while the flow runs.

| Persistence | What it keeps | For how long |
| :- | :- | :- |
| `none` | Nothing. A read gives the inline `value`, and a write is dropped. | A write is never kept. |
| `execution` | The last value written, in the state of the execution. A read before any write gives the inline `value`. | Until the execution ends. |
| `session` | The last value written, as a [session object](https://docs.blobhub.io/blob-types/workflow/session-objects/introduction.md) under the `alias`. | As long as the session object. |

* **A write replaces the value whole.** A component that writes a `data.messages` replaces the list; it does not append.
* **A session value is never read from the inline `value`.** A read gives the object stored under the alias, or nothing
  when the alias holds none, so a `session` component needs its value written first, by an earlier execution, a
  component, or the [Upload Session Object](https://docs.blobhub.io/blob-types/workflow/operations/upload-session-object.md) operation.
* **A session value outlives the execution.** The next execution of the session reads it, and so does a caller of
  [Download Session Object](https://docs.blobhub.io/blob-types/workflow/operations/download-session-object.md). Each write posts an
  `object.written` [session event](https://docs.blobhub.io/blob-types/workflow/workflows/session-events.md).
* **A session write counts against the session's object limit** when its alias is new
  ([limits](https://docs.blobhub.io/general/limits.md#workflow)), and the resolved alias must follow the
  [alias grammar](https://docs.blobhub.io/blob-types/workflow/session-objects/introduction.md#alias-grammar-the-namespace).
* **`data.integer` has no `session`.** Its choices are `none` and `execution`.

A `session` component with no `alias` fails when it is read or written with
`Component "<id>" alias not specified for session persistence mode`.

### Defaults

The default in the Value column of each Route table is what the editor writes into a new component. A definition that
leaves the `persistence` port out runs as `none`, whatever the type.

| Component | Persistence | Inline value |
| :- | :- | :- |
| `data.integer` | `execution` | `0` |
| `data.message` | `none` | None |
| `data.messages` | `none` | None |

### A value or a persistence

A data component must hold an inline `value` or persist somewhere. One with no `value` whose persistence is `none`,
or left out, fails the definition's check with:

```text theme={null}
Data component should have inline value (`value`) or be marked as persisted (`persistence`)
```

The check reads the definition and does not see what a session holds, so a component read from a session whose value an
upload or another execution writes carries `persistence` `session`, and no `value`.

## Alias and run input

`data.message` and `data.messages` have an `alias` port, a `text`. It does two things.

* **It names the session object** of a `session` component.
* **It addresses the component to a run.** An entry of a run's `input_data`, `{"alias", "type", "value"}`, reaches the
  data component whose alias it names, and `type` may name the component's type to be sure
  ([Create Execution](https://docs.blobhub.io/blob-types/workflow/operations/create-execution.md),
  [Choosing a Model per Run](https://docs.blobhub.io/blob-types/workflow/workflows/choosing-a-model.md)).

A run's input starts the component's value for that execution alone, as if a component had just written it. It reaches
only an `execution` component, which reads it in place of the inline `value`. A `none` component reads its inline
`value` as before, and a `session` component reads its session object, so an entry for either changes nothing.

`data.integer` has no `alias` port and takes no run input. A `data.thread` takes no run input either.

An alias may hold a template over the run's input, as `{{ execution.input_data.<alias> }}`, rendered when the
component is read or written. An alias that cannot be rendered fails with `Unable to resolve alias: "<alias>"`.

## `data.integer`

An integer, which the editor starts at `0`. Use it for a counter, a limit or an index that a `logic.code` reads and
writes while a flow loops.

| Route | Category | Value | Notes |
| :- | :- | :- | :- |
| `value` | Data input | `integer`, default `0` | The inline value, read when nothing has been written. |
| `persistence` | Data input | `choice`, default `execution` | `none` or `execution`. |

```json theme={null}
{"id": "attempts", "category": "data", "type": "data.integer", "name": "Attempts",
 "position": {"x": 0, "y": 400},
 "ports": [
   {"category": "data_input", "route": "value", "value": {"type": "integer", "integer": 0}},
   {"category": "data_input", "route": "persistence", "value": {"type": "choice", "id": "execution"}}
 ]}
```

## `data.message`

One message: a prompt, a question or an answer, held for a component to read or to write its output to.

| Route | Category | Value | Notes |
| :- | :- | :- | :- |
| `value` | Data input | `message` | The inline message. |
| `persistence` | Data input | `choice`, default `none` | `none`, `execution` or `session`. |
| `alias` | Data input | `text` | The session object of a `session` component, and the name a run's input addresses it by. |

Halden Systems keeps the support policy a chat is told to follow in a `data.message` named `support_policy`, with
`persistence` `session` and the alias `support/policy`. A maintainer uploads the policy once, and every execution of the
session reads it.

```json theme={null}
{"id": "policy", "category": "data", "type": "data.message", "name": "Support policy",
 "position": {"x": 0, "y": 200},
 "ports": [
   {"category": "data_input", "route": "persistence", "value": {"type": "choice", "id": "session"}},
   {"category": "data_input", "route": "alias", "value": {"type": "text", "text": "support/policy"}}
 ]}
```

## `data.messages`

A list of messages: a few-shot prompt, a history or a set of search results. It is what a chat reads on its `history`
and what a `logic.copy` fills.

| Route | Category | Value | Notes |
| :- | :- | :- | :- |
| `value` | Data input | `messages` | The inline list. |
| `persistence` | Data input | `choice`, default `none` | `none`, `execution` or `session`. |
| `alias` | Data input | `text` | The session object of a `session` component, and the name a run's input addresses it by. |

Ostrava Pumps passes each run the technician's earlier questions as a `messages` entry named `history`, which reaches
the `data.messages` with that alias. Its `persistence` is `execution`, so the run's entry is what a chat reads on
`history`, and no inline `value` is needed.

```json theme={null}
{"id": "history", "category": "data", "type": "data.messages", "name": "History",
 "position": {"x": 0, "y": 600},
 "ports": [
   {"category": "data_input", "route": "persistence", "value": {"type": "choice", "id": "execution"}},
   {"category": "data_input", "route": "alias", "value": {"type": "text", "text": "history"}}
 ]}
```


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