Back to insights

Prompt Builder, AI Engineering & Governance

A Prompt Builder template is executable configuration—not copy

JSBC Labs8 min read

The prompt body is only the visible layer

A team edits two sentences in a Prompt Builder template to make a generated case summary sound more decisive. Preview looks better, so the new version is activated. In production, the wording overstates uncertain facts, a downstream Flow stores the text on the record and an Agentforce action presents it as evidence. What appeared to be copy editing changed system behaviour across several consumers.

The JSBC Labs position is that a production prompt template is executable configuration. Salesforce resolves merge fields, related data, Flow, Apex, retrievers or files into the prompt, sends it through platform controls and returns model output to an application. The template therefore has inputs, dependencies, permissions, cost, latency and failure modes. Its prose matters, but governing only the prose ignores the architecture that makes it consequential.

Write an output contract before instructions

Define what the consumer can safely do with the response. Is it a draft for a person, a classification, a structured payload, an internal summary or text that will be committed to a customer record? Specify required fields, allowed values, maximum length, language, tone, evidence expectations and abstention behaviour. A request to “summarise this account” is not a contract when different callers expect different semantics.

Separate factual accuracy from stylistic quality. Identify claims that must come from supplied grounding, calculations that should remain deterministic and decisions that require human authority. A model may produce fluent text without satisfying any of those conditions. Where a field or action affects money, eligibility, compliance or external communication, validate the response outside the model and preserve a review step proportional to the risk.

Keep instructions separate from untrusted data

Customer emails, case descriptions, uploaded files and retrieved articles can contain text that looks like instructions. Concatenating that content into the same undifferentiated block as system intent makes it harder for the model to distinguish policy from data. Salesforce Well-Architected guidance explicitly recommends separating instructions from record-sourced content and treating external content as untrusted because persistent prompt-injection material can enter through grounding sources.

Structure the template so authoritative instructions, input data and expected output are clearly delimited. Minimise raw text, preprocess high-risk sources where appropriate and constrain what each invocation needs. Do not ask the prompt to enforce permissions or decide whether data may be disclosed. The caller and grounding mechanisms must apply Salesforce access controls before content reaches the template, and the response must be checked before it reaches another trust boundary.

Treat grounding as a dependency graph

Prompt Builder can ground templates with record merge fields, related lists, flows, Apex, uploaded files and other configured resources. Each dependency changes the resolved prompt and can fail, return no data, expose a different shape or add latency. A prompt that is stable in source control can behave differently after an administrator changes a field, a Flow activates a new version or a retriever's indexed corpus changes.

Inventory every grounding source with an owner, schema, freshness expectation, access model and failure response. Decide whether missing data should stop generation, produce an explicit “insufficient evidence” result or fall back to a narrower answer. Pass only the fields required by the use case. More context is not automatically better: it increases token use, broadens the disclosure surface and can bury the evidence that actually determines the response.

Test the resolved prompt, not just the response

Prompt Builder exposes the resolved prompt so builders can inspect how sample records and resources are merged before an LLM generates a response. Use that view to find blank fields, accidental labels, repeated data, sensitive values and contradictory instructions. A good-looking final response can hide a malformed prompt because the model compensated during one preview. The resolved input is the more reliable place to verify composition.

Build a test corpus covering common records, sparse data, extreme lengths, multiple languages, stale or conflicting facts, hostile input and permission boundaries. Run each case several times where variability matters. Score contract compliance, factual support, safety and usefulness separately. Preview is necessary but not sufficient: Salesforce notes that a template can work in Prompt Builder and fail when an agent supplies different runtime inputs, so test through every real entry point.

Version activation as a release decision

Salesforce lets teams maintain multiple prompt-template versions and makes one version active at a time. Once a version has been activated it is immutable, even after deactivation; changes require a new version. That is a valuable release boundary. Record the requirement, test evidence, model selection, grounding dependencies, risk owner and expected behavioural change for every production activation.

Deployment needs equal discipline. Salesforce documents that template activation behaviour varies by deployment method and settings, and referenced flows do not automatically become active merely because the template was deployed. Verify dependencies and target-org model configuration before activation. Use a controlled promotion sequence, confirm the intended version after deployment and retain the previous active version as a known rollback target rather than editing production until output improves.

Design every invocation as an API call

Activated templates can be invoked through Salesforce features, Flow, Apex and REST-based integrations. Every caller must supply the expected input type and handle empty generations, service errors, timeouts, malformed structured output and policy refusal. Do not let five callers parse the same free-form response differently. Put validation and mapping behind a shared application boundary, with a stable business result that is independent of one template's wording.

Classify operations as advisory or consequential. A draft summary may tolerate retry and user review; a bulk process writing generated values needs idempotency, per-record outcomes, rate control and reconciliation. Preserve the template identity, active version, caller, record reference and correlation ID with the business transaction where policy permits. That evidence lets operators distinguish a model-quality issue from bad grounding, a caller defect or an outdated template.

Operate quality, security and cost together

Separate the Prompt Template Manager capability from the end-user Execute Prompt Templates permission, and review assignments like other privileged configuration. The Einstein Trust Layer can mask selected sensitive data before model invocation, but Salesforce documents limitations and does not claim perfect detection. Verify masking with representative data, minimise inputs and never treat masking as a replacement for classification, least privilege or output controls.

Use Prompt Builder performance insights to observe response time, token usage and masked values during testing, then monitor production volume, latency, errors, abstentions, human edits and downstream rejection. Establish budgets per use case and investigate drift after data, model or dependency changes. The standard is not that a prompt once produced an impressive answer. It is that a governed version repeatedly honours its contract, uses approved data and remains safe, measurable and reversible as the surrounding system evolves.

Official references

Continue reading