---
schema_version: "1"
id: b7a0cc12be9a5f07824f6085dd0ba3ecf463e07c9e21d9118476977043fe58ce
title: Prompt Template Run-time Execution
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ai/264-0-0/prompt_builder_runtime.md
canonical_url: https://help.salesforce.com/s/articleView?id=ai.prompt_builder_runtime.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 644245235ef074a9bf7ed12c23b39a4645252a405a8493cb791b0f224e25fe4a
description: Invoking a prompt template at run time sets off a chain of events. The run-time life cycle of a prompt template begins with loading the prompt template with input and concludes with forwarding the LLM-generated response to the calling agent or app.
products:
  - Agentforce
  - Cross Cloud
release: "264"
---
# Prompt Template Run-time Execution

Invoking a prompt template at run time sets off a chain of events. The run-time life cycle of a prompt template begins with loading the prompt template with input and concludes with forwarding the LLM-generated response to the calling agent or app.

## Design-time Preview

When you design a prompt template, Prompt Builder’s preview feature allows you to simulate a complete run-time experience. You preview the prompt template, provide input, preview the resolved prompt, and then get the generated response returned from the LLM.

## Prompt Execution at Run Time

When an agent or app invokes an activated prompt template at run time, it triggers the same chain of events. Let’s break it down into more detailed steps.

**Prompt Template Execution Steps**

![Illustration showing the series of steps involved with prompt template execution.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ai-generative_ai-264-0-0-production-enus/f8ef6498-d7b2-44e3-9b34-ffd5a850aae9/generative_ai/images/prompt_builder_runtime.png)

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:11.11111111111111%">
          <col style="width:88.88888888888889%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d115225e57">Step</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d115225e60">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Step" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e57 ">1</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e60 ">The prompt template gets invoked with input from an agent, a flow, Apex, or an
              app.</td>

          </tr>
          <tr class="">
            <td data-label="Step" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e57 ">2</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e60 ">
              <p>Prompt resolution begins with secure data retrievals. Values for merge fields
                (records, flows, Apex) are added to the prompt. Access to merge data is governed by
                the permissions of the executing user. </p>
              <p style="margin-bottom:0;">For dynamic grounding, relevant
                information from structured and unstructured data in Data Cloud is retrieved using
                features like search retrievers, flows, and SOQL queries.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Step" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e57 ">3</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e60 ">
              <p>The resolved prompt then undergoes further protections using enabled features
                in the <a href="https://help.salesforce.com/s/articleView?id=ai.generative_ai_trust_layer.htm&amp;release=264.0.0&amp;type=5" title="Trusting generative AI with your company secrets and your customer data while balancing the benefits of generative AI is still a challenge today. The Einstein Trust Layer is a secure AI architecture, built into the Salesforce platform. It’s a set of agreements, security technology, and data and privacy controls used to keep your company safe while you explore generative AI solutions.">Einstein Trust Layer</a>.
                Pattern-based <a href="https://help.salesforce.com/s/articleView?id=ai.generative_ai_audit_data_mask.htm&amp;release=264.0.0&amp;type=5" title="After you have configured data masking to in the Einstein Trust Layer Setup, you'll want to verify that sensitive data is masked and also monitor it over time.">data masking</a> is applied automatically, while field-based data masking is
                applied if enabled. </p>
              <p style="margin-bottom:0;">The Einstein Trust Layer applies prompt defense measures
                using Salesforce system policies. </p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Step" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e57 ">4</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e60 ">
              <p>The secured prompt is submitted to the LLM via the LLM gateway. The LLM returns
                its generated response via the LLM gateway. </p>
              <ul>
                <li>The generated response can include <a href="https://help.salesforce.com/s/articleView?id=ai.generative_ai_trust_citations.htm&amp;release=264.0.0&amp;type=5" title="Citations link AI-generated responses to the grounding sources that are relevant to the response. Use citations to see what information the large language model (LLM) used to generate the response, and to verify the validity of the source data. Citations help you identify potential inaccuracies or hallucinations in the generated responses, increasing your confidence in using AI tools.">citations</a> to original sources that the LLM used when generating the
                  response. </li>

                <li>The generated response can be in the user’s language (default) or in a <a href="https://help.salesforce.com/s/articleView?id=ai.prompt_builder_multi_languages.htm&amp;release=264.0.0&amp;type=5" title="Select, manage, and test which languages a template supports to generate output in Prompt Builder">requested
                    language</a>.</li>

              </ul>
              <p style="margin-bottom:0;">For external model providers, our zero data retention policy ensures that data
                sent to the LLM from Salesforce isn’t retained but is deleted after a response is
                sent back to Salesforce. </p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Step" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e57 ">5</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e60 ">The LLM-generated response is logged for <a href="https://help.salesforce.com/s/articleView?id=ai.generative_ai_feedback.htm&amp;release=264.0.0&amp;type=5" title="Collect and store Einstein generative AI audit and feedback data in Data 360 and enhance your generative AI applications with feedback analytics, prompt adjustments, and LLM tuning.">audit and
                feedback</a>. </td>

          </tr>
          <tr class="">
            <td data-label="Step" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e57 ">6</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e60 ">The Einstein Trust Layer applies system policies to the LLM-generated response.
              If enabled, features like toxicity detection help decrease the likelihood of
              unintended or harmful outputs. If data masking is enabled, the Einstein Trust Layer
              demasks any masked data, replacing placeholders with their underlying values.
            </td>

          </tr>
          <tr class="">
            <td data-label="Step" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e57 ">7</td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d115225e60 ">The generated response is returned to the requesting agent or app in a raw or
              structured format.</td>

          </tr>
        </tbody>
      </table>

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ai-generative_ai-264-0-0-production-enus/f8ef6498-d7b2-44e3-9b34-ffd5a850aae9/images/icon_note.png)

Note Prompt resolution is sometimes called "hydration" or "prompt grounding". We refer to it as "resolution" in the context of executing prompt templates built with Prompt Builder.