> For the complete documentation index, see [llms.txt](https://docs.interactive.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.interactive.ai/context/macros.md).

# Macros

A macro is a block of text the agent inserts into a conversation, written once and reused wherever it is needed. A sign-off, a handoff to a human, a compliance notice: anything you would otherwise copy into several routines and then have to keep in sync.

Macros are the one context type you do not attach to an agent. A routine reaches them instead, through a Macro node that names the macro and injects its text at that point in the flow, so the text lives in one place rather than being duplicated across every flow that ends the same way.

### Writing a macro

A macro is YAML with a single `text` field holding the body. `id` is optional, since macros are referenced by their storage name.

<div data-with-frame="true"><figure><img src="/files/hFg2CxqeBGSXi5eTx8hA" alt=""><figcaption></figcaption></figure></div>

The body goes in a literal block, written as `text: |`. Plain text and Markdown also work, and whatever you write becomes the message injected at the call site. Insert template gives you the correct starting shape.

<div data-with-frame="true"><figure><img src="/files/nMAe73TnO2sH4PyLvCWw" alt=""><figcaption></figcaption></figure></div>

**Config** holds arbitrary JSON attached to the version. It travels with that version and is available whenever the item is fetched, which makes it a place for metadata such as parameters your own tooling reads.

### Variables

Write `{{variable_name}}` anywhere in the body and the platform picks it up automatically, with no separate registration step. Names take letters and underscores only. The detail view lists every variable it found, which is the quickest way to catch one you have mistyped.

<div data-with-frame="true"><figure><img src="/files/5cG56tFJarMG2ej6uBQq" alt=""><figcaption></figcaption></figure></div>

### Versions and labels

Every save creates a new version instead of overwriting the current one, and the panel on the left lists them all with the author and date. Each card also carries the labels on that version. Versions cannot be edited in place, which is what keeps the history trustworthy. New starts another version from the one you are viewing, and the commit message is what makes that history readable months later.

<div data-with-frame="true"><figure><img src="/files/kZNI4qWLogY3tl47iDnK" alt=""><figcaption></figcaption></figure></div>

`latest` is applied automatically and always points at the newest version. Every other label is yours to create and move: the label control on a version opens Context version labels, listing the labels already in the project with a field for adding a new one. Labels are how you control which version gets fetched without touching the code that fetches it, and they are also what assigns a version to an agent.&#x20;

### The detail view

Five tabs sit above the content.

* **Context** shows the item itself, rendered for its type.
* **Config** holds the arbitrary JSON attached to this version.
* **Linked Generations** lists the observations that used this version, with the same filters, columns, and export controls as Observability. This is how you tell whether a version is actually being exercised in production, and how it performs when it is.
* **Use Context** gives you a ready-made Python snippet for fetching the item, either by label or pinned to a version number. Every context type is fetched with `get_prompt` and its full path, as in `macros/handoff`.
* **Label History** is an audit log of label movement: which label changed, whether it was added or removed, the version it landed on, who moved it, and when.

**Metrics**, in the top right, swaps the versions panel for a table comparing every version side by side: median latency, median input and output tokens, median cost, how many generations used it, and when it was first and last used. It is the fastest way to catch a version that got slower or more expensive before you promote it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.interactive.ai/context/macros.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
