My App
AI SystemLLM System

Prompt Management

Prompts are managed outside the agent code, so a prompt can change without touching an agent.

  • Versions: every prompt has versions. A new version is a new file; the old versions stay, so they can be compared and a rollback is a one-line change.
  • Jinja files: each version is a Jinja file. It starts with a header that describes the prompt and gives its version, followed by the prompt text.
  • Variables and loops: Jinja lets the prompt text contain variables, and also loops and conditions. The SQL agent's prompt receives the database schema as a variable. The template for the retrieved pieces loops over the pieces and their events, and skips fields that were not logged. A variable that is missing raises an error instead of leaving a gap in the prompt.
  • Prompt manager: one small component finds and renders prompts. Given the task (for example, classify), the prompt type and the version, it reads the file, takes the text after the header, fills in the variables and returns the finished prompt. Agents, the pipeline and the evaluations all use it.
  • The version is chosen per call: the pipeline holds one version setting per prompt and passes it to the agent on every run. The agents do not hard-code a version.
  • Traceable: the versions used in a turn are attached to its Langfuse trace, so an answer can be traced back to the prompts that produced it.