> ## 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 (model-level)

> Sets context for the Omni Agent that is applicable for the entire model.

export const endGoal_0 = "standardize AI outputs across the model"

Free text that provides context to the [Omni Agent](/ai/chat) for all topics in the model.

When a branch or workbook layer extends a model with `ai_context`, Omni uses patch-based merging to preserve parent context while allowing layer-specific modifications. This prevents child layers from overwriting parent context when making edits.

Refer to the [Optimizing models for AI](/modeling/develop/ai-optimization) guide for more information on best practices.

## Syntax

```yaml title="Value is on one line" theme={null}
ai_context: "<value>"
```

```yaml title="Value can contain linebreaks" theme={null}
ai_context: |
  <value>
```

## 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.
  * **`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.
</ParamField>

<ParamField path="ai_context_patch" type="object">
  **Server-managed field** that stores how a branch or workbook layer modifies its parent's `ai_context`. Omni automatically generates patches when you edit `ai_context` in a non-base layer.

  You can delete a patch by omitting the `ai_context_patch:` field from your YAML in **Model** mode, but you cannot manually create or edit patch contents. Omni automatically chooses the appropriate patch type.

  The literal `ai_context` is always persisted alongside the patch as the source of truth and fallback.
</ParamField>

## Layer behavior

<Note>
  The patch-based merging described in this section only applies to model-level `ai_context`.
</Note>

When you edit the model-level `ai_context` in a branch or workbook layer in:

<Steps>
  <Step title="Combined mode" noAnchor>
    Omni compares your edited context to the resolved parent context and automatically generates an `ai_context_patch`. Both the literal `ai_context` and the patch are stored.
  </Step>

  <Step title="Model mode" noAnchor>
    You see only the patch content (your layer's contribution) when a patch exists. The literal `ai_context` is hidden but still persisted in the background.
  </Step>
</Steps>

When Omni resolves a model across layers (**Shared > Branch > Workbook**):

1. If a layer has an `ai_context_patch`, Omni attempts to apply it against the resolved parent context
2. If the patch applies successfully, the result becomes the resolved context for that layer
3. If a diff patch cannot apply cleanly, such as due to parent changes, Omni falls back to the layer's literal `ai_context`
4. Append patches always apply successfully, making them ideal for layers that only add context

## Examples

### Behavioral prompting

```yaml title="Behavioral prompting" wrap theme={null}
ai_context: |
  You are an analyst for an eCommerce retailer called BlobsRUs. After generating a query, always provide a summary of the data both English and Brazilian Portuguese.
```

### Personalized context using user attributes

```yaml title="Personalized context using user attributes" wrap theme={null}
ai_context: |
  You are an analyst for a {{omni_attributes.company_type}} company. Focus on metrics relevant to the {{omni_attributes.region}} region.
```

<h3 id="model-specific">
  Model-specific instructions
</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.smartest }}
  Before calling 'GenerateQuery', explain your reasoning for field selection in detail (9-10 sentences) under "Reasoning for field selection", then provide 3-4 sentences on alternative approaches under "Alternative approaches considered".

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

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

```yaml title="" wrap theme={null}
ai_context: |
  {{^ omni_llm.smartest }}
  Proceed directly to generating the query without intermediate explanation steps.

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

### Branch layer appending to parent context

```yaml title="Branch layer appending to parent context" theme={null}
# In the SHARED layer:
ai_context: |
  You are an analyst for BlobsRUs eCommerce.

# In a BRANCH layer, adding region-specific context:
ai_context: |
  You are an analyst for BlobsRUs eCommerce.
  
  Focus on the European market and use metric names in euros.
ai_context_patch:
  append: |
    
    Focus on the European market and use metric names in euros.
```

### Workbook layer modifying parent context

```yaml title="Workbook layer modifying parent context" theme={null}
# In the SHARED layer:
ai_context: |
  You are an analyst for BlobsRUs. Provide detailed explanations.

# In a WORKBOOK layer, changing tone:
ai_context: |
  You are an analyst for BlobsRUs. Keep responses concise.
ai_context_patch:
  diff: |
    @@ -1 +1 @@
    -You are an analyst for BlobsRUs. Provide detailed explanations.
    +You are an analyst for BlobsRUs. Keep responses concise.
```
