# Tags

Connection tags are visual representations of the data available from connected blocks, providing an easy way to reference data between blocks and outputs from previous blocks in your workflow.

[Video: connections.mp4](https://d4h6f8f5tksdw.cloudfront.net/connections.mp4)

### What Are Connection Tags?

Connection tags are interactive elements that appear when blocks are connected. They represent the data that can flow from one block to another and allow you to:

* Visualize available data from source blocks
* Reference specific data fields in destination blocks
* Create dynamic data flows between blocks

Connection tags make it easy to see what data is available from previous blocks and use it in your
current block without having to remember complex data structures.

## Using Connection Tags

There are two primary ways to use connection tags in your workflows:

<h3>
  Drag and Drop
</h3>

Click on a connection tag and drag it into input fields of destination blocks. A dropdown will
appear showing available values.

<ol>
  <li>
    Hover over a connection tag to see available data
  </li>

  <li>
    Click and drag the tag to an input field
  </li>

  <li>
    Select the specific data field from the dropdown
  </li>

  <li>
    The reference is inserted automatically
  </li>
</ol>

<h3>
  Angle Bracket Syntax
</h3>

Type <code>\<</code> in input fields to see a dropdown of available connection values
from previous blocks.

<ol>
  <li>
    Click in any input field where you want to use connected data
  </li>

  <li>
    Type <code>\<</code> to trigger the connection dropdown
  </li>

  <li>
    Browse and select the data you want to reference
  </li>

  <li>
    Continue typing or select from the dropdown to complete the reference
  </li>
</ol>

## Tag Syntax

Connection tags use a simple syntax to reference data:

```
<blockName.path.to.data>
```

Where:

* `blockName` is the name of the source block
* `path.to.data` is the path to the specific data field

For example:

* `<agent1.content>` - References the content field from a block with ID "agent1"
* `<api2.data.users[0].name>` - References the name of the first user in the users array from the data field of a block with ID "api2"

Tags resolve in every field except the literal fields of a [Judgment](/blocks/judgment) or [Laya Decision](/blocks/laya) block: Instructions, option descriptions, level descriptions, and Ask Several questions. A tag in one of those fields is not resolved, and the run fails before anything is sent to TypeSafe or Laya. Put references in the block's State field.

## Loop and Parallel References

Blocks inside a Loop or Parallel block can reference the container's iteration state with the reserved `loop` and `parallel` prefixes. SteelEngine resolves these prefixes before block references, so they work without a connection from the container:

| Reference                | Value                                                                                                  |
| ------------------------ | ------------------------------------------------------------------------------------------------------ |
| `<loop.index>`           | Zero-based iteration number (`<loop.iteration>` is an alias)                                           |
| `<loop.currentItem>`     | The current item in a ForEach loop (`<loop.item>` is an alias)                                         |
| `<loop.items>`           | The whole collection a ForEach loop iterates over                                                      |
| `<loop.results>`         | The loop's collected outputs, for blocks that run after the loop (`<loop.result>` is an alias)         |
| `<parallel.index>`       | Zero-based branch number                                                                               |
| `<parallel.currentItem>` | The item assigned to this branch when distributing a collection                                        |
| `<parallel.items>`       | The whole distributed collection                                                                       |
| `<parallel.results>`     | The parallel block's collected outputs, for blocks that run after it (`<parallel.result>` is an alias) |

The bare prefix resolves to the innermost container around the current block. To target a specific container, use its block name instead of the prefix, for example `<myLoop.index>`. Iteration fields (`index`, `currentItem`, `items`) only resolve inside the named container. From outside it, the raw `<myLoop.index>` text stays in the field. `results` is the exception. You read it after the container finishes. Count-based loops and parallels have no `currentItem` or `items`, so those references also stay unresolved. An unknown property such as `<loop.foo>` fails the block with an error that lists the available fields. See [Loop](/blocks/loop) and [Parallel](/blocks/parallel) for the shape of each `results` entry.

### References Inside Parallel Windows

Inside a loop within a [Parallel Window](/blocks/parallel-window#loops-inside-a-window), `<parallel.currentItem>` identifies the window item and `<loop.currentItem>` identifies the current element of the innermost loop. Named loop references can read an enclosing loop's iteration context. Each window item has its own loop state and outputs.

Read a loop's `result` or `results` only after that loop finishes. Blocks inside it cannot read its incomplete aggregate. A loop's collection is evaluated before the loop starts, so `<loop.items>` in that collection must refer to an enclosing loop. While and Do While conditions can read their own loop's current context.

## Dynamic Tag References

Connection tags are evaluated at runtime, which means:

1. They always reference the most current data
2. They can be used in expressions and combined with static text
3. They can be nested within other data structures

### Examples

```javascript
// Reference in text
"The user's name is <userBlock.name>"

// Reference in JSON
{
  "userName": "<userBlock.name>",
  "orderTotal": <apiBlock.data.total>
}

// Reference in code
const greeting = "Hello, <userBlock.name>!";
const total = <apiBlock.data.total> * 1.1; // Add 10% tax
```

When using connection tags in numeric contexts, make sure the referenced data is actually a number
to avoid type conversion issues.

## Common Questions

**How are tag references resolved at runtime?**

The executor uses a chain of resolvers. Each reference like <blockName.path> is matched against resolvers in order: loop references, parallel references, workflow variables, environment variables, and finally block output references. The first resolver that recognizes the reference handles it.

**Does the block name in a tag reference need to match exactly?**

Block names are normalized by converting to lowercase and removing spaces before matching. So <My Agent.content> and <myagent.content> resolve to the same block. However, the field path after the block name (e.g., content, data.users) is case-sensitive.

**Can I reference environment variables in tag syntax?**

Yes, but environment variables use double-brace syntax instead of angle brackets: {{MY_VAR}}. These are resolved by a dedicated environment variable resolver during execution.

**What happens if I reference a block that did not execute on the current path?**

If the referenced block exists in the workflow but did not produce output (for example, it was on an unselected condition branch), the reference resolves to an empty value. In most blocks this becomes an empty string; in Function blocks it becomes null.

**Can I access array elements inside a tag reference?**

Yes. Use bracket notation for array indices within the dot path, for example <api1.data.users[0].name>. The resolver supports multiple levels of array indexing like items[0][1] as well.

**How are tag values formatted inside Function blocks versus other blocks?**

In Function blocks, resolved values are formatted as code literals (strings are quoted, objects are JSON, null stays as null) so they can be used directly in JavaScript or Python code. In other block types, objects are JSON-stringified and primitives are converted to plain strings.

**Can I mix static text with tag references?**

Yes. You can embed tag references anywhere in a text string, such as "Hello, <agent1.content>! Your order total is <api1.data.total>." The resolver replaces each tag in place while leaving the surrounding text intact.
