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

# ai_context - Composite topics

> Free text that can provide context about a composite topic to the Omni Agent.

export const endGoal_0 = "improve AI query results"

Free text that can provide context to the [Omni Agent](/ai/chat). Refer to the [Optimizing models for AI](/modeling/develop/ai-optimization) guide for more information on best practices.

## Syntax

```yaml theme={null}
ai_context: "<context_text>"
```

Or for multiline context:

```yaml theme={null}
ai_context: |
  <multiline_context_text>
```

## Properties

<ParamField path="ai_context" type="string">
  Free text that provides context to the Omni Agent. Can include behavioral prompting, instructions for tone, or other guidance to {endGoal_0}.

  The following references are supported for this field:

  * [**User attributes**](/administration/users/attributes), referenced with `{{omni_attributes.<attribute_name>}}`. This allows you to personalize the context for each user.
  * **Model [`constants`](/modeling/models/constants)**, referenced using `@{constant_name}` syntax. This allows you to maintain reusable instruction blocks such as tone, privacy guidance, and domain context instead of duplicating them.
  * **`omni_llm` namespace,** which allows you to tailor context to specific AI model tiers:

    * `{{ omni_llm.model }}` — Substitutes the active model's family name, which will be one of: `smartest`, `standard`, or `fastest`
    * `{{# omni_llm.<family> }}...{{/ omni_llm.<family> }}` — Conditional sections for specific model tiers. `<family>` must be one of `smartest`, `standard`, or `fastest`
    * `{{^ omni_llm.<family> }}...{{/ omni_llm.<family> }}` — Inverse sections, which apply when the specified tier is **not** used. `<family>` must be one of `smartest`, `standard`, or `fastest`

    See the [Examples section](#model-specific) for more information.
  * **`omni_agent` namespace,** which allows you to scope context to specific AI agents:

    * `{{ omni_agent.name }}` — Substitutes the active agent's name, which will be one of: `analyze`, `build`, or `simple_summarize`
    * `{{# omni_agent.<agent> }}...{{/ omni_agent.<agent> }}` — Conditional sections for specific agents. `<agent>` must be one of `analyze`, `build`, or `simple_summarize`
    * `{{^ omni_agent.<agent> }}...{{/ omni_agent.<agent> }}` — Inverse sections, which apply when the specified agent is **not** used. `<agent>` must be one of `analyze`, `build`, or `simple_summarize`

    See the [Examples section](#agent-specific) for more information.
</ParamField>

## Behavior

When a composite topic is the active topic, the Omni Agent uses the composite topic's own `ai_context`. The `ai_context` of the member topics is not included.

Context defined on the model, on views, on fields, and on [shared dimensions](/modeling/composite-topics/parameters/shared-dimensions) is still included.

## Examples

### Personalized context using user attributes

```yaml title="Personalized context using user attributes" theme={null}
ai_context: |
  You are a marketing analyst. When someone asks about their region, always filter by region = {{omni_attributes.region}}.
```

<h3 id="model-specific">
  Model-specific analysis depth
</h3>

The following context will apply when the model tier is `smartest`.

```yaml title="Applies when the model tier is smartest" wrap theme={null}
ai_context: |
  This composite topic compares orders revenue with marketing spend by activity_date and region.

  {{# omni_llm.smartest }}
  For questions that span both topics, explain which topic each measure comes from and how the shared dimensions align them.
  {{/ omni_llm.smartest }}
```

The following context will apply when the model tier is **not** `smartest`.

```yaml title="Applies when the model tier is not smartest" wrap theme={null}
ai_context: |
  This composite topic compares orders revenue with marketing spend by activity_date and region.

  {{^ omni_llm.smartest }}
  Group by activity_date or region. Use one measure from each topic per query.
  {{/ omni_llm.smartest }}
```

<h3 id="agent-specific">
  Agent-specific context
</h3>

The following context provides query guidance to the `analyze` agent while providing field relationship guidance to the `build` agent.

```yaml title="Agent-specific query and field guidance" wrap theme={null}
ai_context: |
  This composite topic combines orders and marketing data.

  {{# omni_agent.analyze }}
  Always filter by activity_date before comparing revenue with spend. Both topics are large.
  {{/ omni_agent.analyze }}

  {{# omni_agent.build }}
  activity_date and region are shared dimensions. Revenue fields come from orders_topic. Spend fields come from marketing_topic.
  {{/ omni_agent.build }}
```

### Using constant references

Reference [`constants`](/modeling/models/constants) to combine reusable context blocks with composite topic guidance:

```yaml title="Composite topic file with constant references" theme={null}
ai_context: |
  @{tone} @{domain_marketing}
  This composite topic compares orders revenue with marketing spend. One row is one activity_date per region.
```

The `@{tone}` and `@{domain_marketing}` references will be substituted with the `constant` values defined in the model file.

### Behavioral prompting

```yaml title="Behavioral prompting" wrap theme={null}
ai_context: |
  you are the head of marketing. you want to know which campaigns drive revenue. you compare spend with revenue by month and by region, and you look for regions where spend went up but revenue did not.
```
