Production apps don't paste strings together. They use prompt templates with named slots, and fail fast when a variable is missing.
Implement render(template, variables):
{name} with str(variables[name]). Names are letters, digits and underscores.{{ and }} produce literal { and }, so you can include JSON examples in prompts.KeyError listing all the missing names, sorted, in the message.Also implement placeholders(template) returning the sorted list of distinct names used.
Write it yourself; don't call str.format.