> ## 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 - Views

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

export const endGoal_0 = "improve AI query results"

Free text that can provide context to the [Omni Agent](/ai/chat). Context could include behavioral prompting or example queries and structured Omni results.

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>

## Examples

### Personalized context using user attributes

```yaml title="Personalized context using user attributes" theme={null}
ai_context: |
  This view contains data for the {{omni_attributes.region}} region only.
```

<h3 id="model-specific">
  Model-specific query preferences
</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: |
  {{# omni_llm.fastest }}
  Prefer queries using pre-aggregated fields when available.

  You are running on {{ omni_llm.model }}.
  {{/ omni_llm.fastest }}
```

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}
  {{^ omni_llm.fastest }}
  You may compute aggregations on-the-fly if needed for accuracy.

  You are running on {{ omni_llm.model }}.
  {{/ omni_llm.fastest }}
```

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

The following context provides different guidance to different agents based on view-level concerns.

```yaml title="Agent-specific view guidance" wrap theme={null}
ai_context: |
  This view contains pre-aggregated sales metrics.

  {{# omni_agent.analyze }}
  When querying this view, you can use the pre-calculated total_revenue field directly rather than summing line items.
  {{/ omni_agent.analyze }}

  {{# omni_agent.simple_summarize }}
  This view is optimized for dashboard summaries. All measures are pre-aggregated.
  {{/ omni_agent.simple_summarize }}

  {{# omni_agent.build }}
  This view aggregates data at the daily level. The grain is date + product_id.
  {{/ omni_agent.build }}
```

### Using constant references

Reference [`constants`](/modeling/models/constants) to combine reusable context blocks with view-specific guidance:

```yaml title="View file with constant references" theme={null}
ai_context: |
  @{tone} @{privacy_high}
  This view contains customer transaction data.
```

The `constant` references will be substituted with the values defined in the model file.

### Behavioral prompting

```yaml title="Behavioral prompting" wrap theme={null}
ai_context: |
  you are the head of finance. you are concerned with the status of customer payments. you often need to project into the future how many invoices are due and for how much. you also need to know if any invoices are late so you can reach out to those customers.
```

### Structured query

```yaml title="Structured query" expandable theme={null}
ai_context: |
  question: which customers are behind due on payment?
    answer:
    {
    "limit": 1000,
    "sorts": [
      {
        "column_name": "share_rillet_omni_omni__invoices.due_date",
        "sort_descending": true,
        "is_column_sort": false,
        "null_sort": "OMNI_DEFAULT"
      }
    ],
    "table": "share_rillet_omni_omni__invoices",
    "fields": [
      "share_rillet_omni_omni__invoices.customer_id",
      "share_rillet_omni_omni__invoices.customer_name",
      "share_rillet_omni_omni__invoices.invoice_number",
      "share_rillet_omni_omni__invoices.due_date",
      "share_rillet_omni_omni__invoices.total_amount"
    ],
    "pivots": [],
    "dbtMode": false,
    "filters": {
      "share_rillet_omni_omni__invoices.due_date": {
        "is_negative": false,
        "kind": "BEFORE",
        "right_side": "today",
        "type": "date",
        "ui_type": "BEFORE"
      },
      "share_rillet_omni_omni__invoices.status": {
        "type": "string",
        "kind": "EQUALS",
        "values": [
          "unpaid"
        ],
        "is_negative": false,
        "case_insensitive": true
      }
    },
    "modelId": "aeb6f3f4-b0e5-4abb-97eb-eaeb42a16944",
    "version": 5,
    "rewriteSql": true,
    "row_totals": {},
    "fill_fields": [],
    "calculations": [],
    "column_limit": 50,
    "join_via_map": {},
    "column_totals": {},
    "userEditedSQL": "",
    "dimensionIndex": 0,
    "default_group_by": true,
    "join_paths_from_topic_name": "invoices"
  }
```
