PromptRegistry treats prompts as first-class, versioned artifacts backed by your existing StateStore. You can pin a route to a specific version, diff two versions line-by-line, and roll forward or backward entirely independently of code changes.
Setup
Create aPromptRegistry backed by any StateStore:
For tests or one-off scripts, pass a
MemoryStateStore instead — it requires no file I/O or native dependencies.Registering prompts
Callregistry.register(name, template, note?) to append a new immutable version. Version numbers start at 1 and increment automatically.
register returns a PromptVersion object:
Retrieving prompts
registry.get(name, version?)
Returns the latest version when version is omitted, or the specific version if provided. Returns undefined if the prompt or version does not exist.
registry.list(name)
Returns all versions for a named prompt as a PromptVersion[] array, oldest first.
registry.names()
Returns an array of all prompt names registered in the store.
Diffing versions
registry.diff(name, from, to) returns a line-level diff between two versions. Use this in a deploy pipeline or admin UI to review prompt changes before promoting them.
PromptDiff fields:
Rendering templates
renderPrompt(template, vars) fills {{varName}} placeholders in a template string with values from a plain object. Missing variables are replaced with empty strings.
{{ varName }} and {{varName}} are both valid.
Using a registry in an agent
Fetch the prompt template at startup, render it with runtime variables, and pass it as the agent’ssystem prompt.
1
Register your prompt (once, at setup time)
2
Fetch and render the prompt in your agent definition
3
Roll back without redeploying
Pin a different version number in
registry.get() and restart the process — no code change required.