Normandy.Components.SystemPromptGenerator (normandy v2.2.0)

View Source

Generates structured system prompts for agents from prompt specifications.

Summary

Functions

generate_prompt/1 in two parts, {static, context}: the Role, How to work and Output sections, and the Context section of the specification's context providers (nil without one). A provider's text can change from call to call; BaseAgent sends it after everything else in the system prompt, so the rest stays cached (AX-20).

Uses an instance of Normandy.Components.PromptSpecification to generate a system prompt for the agent.

Functions

generate_parts(prompt_specification)

@spec generate_parts(Normandy.Components.PromptSpecification.t()) ::
  {String.t(), String.t() | nil}

generate_prompt/1 in two parts, {static, context}: the Role, How to work and Output sections, and the Context section of the specification's context providers (nil without one). A provider's text can change from call to call; BaseAgent sends it after everything else in the system prompt, so the rest stays cached (AX-20).

generate_prompt(prompt_specification)

@spec generate_prompt(Normandy.Components.PromptSpecification.t()) :: String.t()

Uses an instance of Normandy.Components.PromptSpecification to generate a system prompt for the agent.

Tools are not listed here: adapters send them through the API tools parameter.

Example

spec = %PromptSpecification{
  background: ["you are a helpful assistant", "you assist me in assisting"],
  steps: ["step 1", "step 2", "step 3"],
  output_instructions: ["print the result", "as a result"]
}

Normandy.Components.SystemPromptGenerator.generate_prompt(spec)