Platform Engineering3 January 20277 min read

Build Lab: From Chain to Governed Agent — Part 2 of 8

Prompt templates are versioned components

A one-line prompt edit can change who gets escalated to a person, with no code change and no test run. Part 2 of Build Lab: From Chain to Governed Agent treats prompt templates as components with a version, an owner, a test set and a release path, and gives a change classification table for deciding which edits need which approval.

#AI Engineering#Prompt Management#LangChain#LangSmith#Release Management

Consider an illustrative change. A product owner reads transcripts from an interpretation workflow at a public service counter and finds the replies stiff. Someone edits the system prompt to make the tone warmer, tests it on five friendly examples and saves it. Nothing else changes: no code, no model, no schema. Two weeks later, the share of conversations handed to a person has dropped. That looks like an improvement until a reviewer notices why. The warmer prompt also softened one sentence about when to escalate, and the model now reassures people it should have referred.

No one made a bad decision on purpose. The prompt was treated as text, not as a component, so it had no version, no test set and no release path.

A prompt template is a component that changes the behaviour of a service: give it a version, an owner, a test set and a release path, and record which version produced every output.

This is Part 2 of Build Lab: From Chain to Governed Agent. Part 1 defined the output contract. This part governs the instructions that produce it.

A template separates what is fixed from what varies

A template is a prompt with named slots. The fixed part holds the instructions, boundaries and examples. The slots hold what changes per request: the person's message, the conversation so far, the retrieved sources. LangChain's reference documentation for ChatPromptTemplate, opened on 25 November 2026, shows variables written in braces, a from_messages constructor that accepts several message formats, and a ("placeholder", "{conversation}") shorthand for inserting earlier messages.

That separation matters for governance as much as for convenience. The fixed part is what you review, version and test. The slots are what you validate at run time. When the two are mixed, for example by pasting retrieved text into the instructions, a change to the data can quietly become a change to the instructions.

Illustrative; check against the current documentation.

from langchain_core.prompts import ChatPromptTemplate
from langsmith import Client

# Option A: template kept in a reviewed repository, with its version alongside
TEMPLATE_VERSION = "counter-intent/1.4.0"
prompt = ChatPromptTemplate.from_messages([
    ("system", "Answer only from the approved sources supplied. "
               "If none apply, set needs_person to true."),
    ("placeholder", "{conversation}"),
    ("human", "{request}"),
])

# Option B: pull the version that the production label points to
client = Client()
prompt = client.pull_prompt("counter-intent:production")

Either option works. What matters is that the running service can say exactly which version it used.

Labels in code, exact versions in the trace

LangSmith's page on managing prompts, opened on 25 November 2026, describes a prompt's history as a sequence of commits, each with a commit hash. Commit tags point at one commit and can be moved. The staging and production tags are reserved for environments and assigned through a promotion flow, and each environment keeps a rollback history. Code can pull a prompt by name and tag, or by name and commit hash, as the programmatic guide shows with client.pull_prompt.

The pattern is sound whatever tool holds the prompt. A prompt file in a reviewed repository, with a version number and a release tag, achieves the same thing without a registry. The design rule is:

  • code refers to a label, so a release does not need a code change;
  • the trace records the exact version, so a past output can be explained after the label has moved; and
  • rollback moves the label back to a version that has already passed, rather than editing the prompt under pressure.
A prompt template released like any other component. A change is drafted, reviewed and committed, which gives it an immutable version identifier. The committed version runs against a fixed evaluation set, including escalation and protected-term cases. If it passes, the staging label moves to it, and after owner approval the production label moves to it. The running service resolves the production label, and every trace records the exact version identifier it used. If a regression appears, rollback moves the production label back to the previous version, without a code deployment. A failed evaluation returns the change to draft.CHANGEAUTHORDraft changeIMMUTABLECommit: version IDFIXED CASESEvaluation setLABELStagingfail: back to draftRELEASEOWNER APPROVESProduction labelRUNNING SERVICEResolves the label,records the version IDTRACEOutput linked to prompt,model and schema versionsregression: move label backRollback is a label move to a version that already passed, not an emergency edit.Illustrative release path. Record who moved each label, when and why.
Code refers to a label. The trace records the exact version. Rollback moves the label back. CloudNala analysis; the pattern applies whether prompts live in a prompt registry or in a reviewed repository.

A registry adds a dependency to the request path. If the prompt is pulled at run time, decide what happens when the registry is unreachable: fail closed, or use a cached copy of a known version. Either is defensible. Not deciding is not.

Not every edit is equal

The decision tool for this part is a change classification table. Use it to decide, before a prompt edit is merged, what testing and approval it needs.

ChangeExampleMinimum testApprover
CosmeticFix a typo in an example that the model never sees as an instructionFixed evaluation set, no regressionComponent owner
Tone or styleMake replies warmer or shorterFull set, including escalation and refusal casesComponent owner and service owner
BehaviouralChange when the model sets needs_person, add or remove an intentFull set, plus new cases for the changed behaviour, compared against the current versionService owner
BoundaryChange which sources may be used, which topics are refused or which protected terms must survive translationFull set, adversarial cases, specialist reviewService owner and risk or language specialist
ContractChange the output schema the prompt asks forContract tests in every consumer, as in Part 1Owners of every consuming system

The illustrative change at the start of this article was classified as tone and treated as cosmetic. It was behavioural. A classification table does not prevent that mistake, but it forces someone to make the call explicitly and to run the escalation cases before the label moves.

The test set travels with the template

A prompt version is releasable only when it has passed a fixed set of cases. For an interpretation workflow, that set should include:

  • routine requests for each supported intent;
  • requests that must be escalated, and at least one that looks routine but is not;
  • requests in each supported language, including mixed-language messages;
  • protected terms, names, dates and numbers that must survive unchanged;
  • requests outside scope, which must be refused or routed; and
  • attempts to override the instructions from inside the request.

Keep the cases synthetic or approved for testing, and keep their expected outcomes in the same repository or registry as the template. Build the evaluation system before the agent explains why the evaluation comes first, and Part 7 connects evaluation results to traces.

Reusable means shared, and shared means coupled

Templates are tempting to reuse. A shared system preamble, a common refusal instruction or one escalation sentence used across several workflows saves effort and keeps wording consistent. It also couples every workflow that uses it. A change made for one service changes all of them.

Treat a shared template like a shared library:

  1. Give it an owner and a version, separate from the workflows that use it.
  2. List the workflows that depend on it.
  3. Run each dependent workflow's evaluation set before moving its label.
  4. Let workflows pin an older version while they test the new one.

That list of dependencies belongs in the inventory that An AI bill of materials describes, alongside models, tools and packages.

Do not hide policy in a prompt

One more boundary keeps templates manageable. An instruction such as "never confirm an appointment the system has not booked" is a policy. A prompt can state it, and the model will usually follow it. Usually is not enough for a rule with consequences. Policy that must always hold belongs in code or in a rules layer that checks the output, as Rules stop plausible errors becoming actions and Where should AI guardrails live? argue. The prompt then explains the rule to the model, and the check enforces it.

NalaTolika: one template per route

NalaTolika is a CloudNala concept and reference architecture for governed language interpretation. It has no customers, deployments, pilots, data or results. In its reference design, each language route has its own interpretation template, because protected terms, politeness conventions and escalation cues differ between languages. Each template has a version, a named owner, a bilingual reviewer for boundary changes and its own test cases. The escalation rule itself is enforced in code, so a tone change to one route cannot remove it.

The second section of the Chain-to-Governed-Agent Readiness Checklist covers prompt versioning, change classes and rollback.

Next in the series: Retrieval with evidence and source boundaries. All parts are on the series page.

Sources and limits: this article is CloudNala analysis. The prompt template and prompt management descriptions come from reference.langchain.com and docs.langchain.com, opened on 25 November 2026; features and names change, so check the current documentation. The code is illustrative, uses synthetic names and has not been run by CloudNala. A prompt registry is one option, named as a dated example, not a recommendation; a reviewed repository achieves the same control. The counter example is illustrative and names no department. NalaTolika is a concept with no deployments.

How CloudNala can help

CloudNala reviews how prompts are changed in a live or planned AI workflow. We inventory every template and shared fragment, classify recent changes, check that each version has an owner, a test set and a recorded release, and set up a release path in which code refers to a label, traces record the exact version and rollback is a tested step.


Work with CloudNala

CloudNala helps organisations move from technology ambition to practical execution across cloud, AI, data, platform engineering and digital services.

Whether you are exploring AI, modernising your cloud environment, building a public-sector digital service, or turning an idea into a working MVP, we can help you shape the roadmap and deliver the next step.

Book an AI Production Readiness Review or write to us at consult@cloudnala.co.za

Found this useful?

Share