Skip to content

agentix.prompts

prompts

Lightweight prompt registry & versioning.

Keep named prompts under version control in-process so you can roll back a prompt change that regressed. Each register adds a new version (the latest becomes active); get returns the active (or a pinned) version; rollback re-points the active version to an earlier one.

prompts = PromptRegistry()
prompts.register("assistant", "You are a helpful assistant.")        # v1
prompts.register("assistant", "You are a terse, helpful assistant.") # v2 (active)

agent = Agent(model=..., system_prompt=prompts.get("assistant"))     # uses v2
prompts.rollback("assistant", 1)                                     # back to v1

Pair with eval (agentix.evals) to compare versions, and to_dict/from_dict to persist the registry (e.g. via a Store).

PromptRegistry

PromptRegistry()

register

register(name: str, template: str) -> int

Add a new version of name and make it active. Returns its version number. A no-op (identical to the current active text) returns the existing version without creating a duplicate.

get

get(name: str, *, version: int | None = None) -> str

Return the active version's text (or a specific version).

render

render(
    name: str,
    /,
    *,
    version: int | None = None,
    **values: Any,
) -> str

get + str.format(**values). (Escape literal braces as {{}}.)

rollback

rollback(name: str, version: int) -> None

Re-point the active version to an earlier (existing) one.