Skip to content

Overview

AgentPool's prompt library allows defining reusable system prompts that can be shared across agents. Prompts are defined in the prompts section of your configuration and can be referenced by name.

System prompts define agent behavior, personality, and methodology. You can configure prompts using:

  • Static prompts: Inline text content
  • File prompts: Load from external files with Jinja2 templating
  • Library prompts: Reference shared prompts from the library
  • Function prompts: Dynamically generate prompts using Python functions

Basic Structure

# yaml-language-server: $schema=https://raw.githubusercontent.com/phil65/agentpool/refs/heads/main/schema/config-schema.json
prompts:
  # Define reusable system prompts
  system_prompts:
    expert_analyst:
      content: |
        You are an expert data analyst.
        Focus on finding patterns and insights.
      category: role

    step_by_step:
      content: |
        Break tasks into sequential steps.
        Explain each step thoroughly.
      category: methodology

# Using prompts in agents
agents:
  analyst:
    type: native
    model: openai:gpt-5-mini
    system_prompt:
      # Direct string prompts
      - "You help with analysis."

      # Reference library prompts
      - type: library
        reference: expert_analyst
      - type: library
        reference: step_by_step

Prompt Categories

System prompts can be categorized by their purpose:

  • role: WHO the agent is (e.g., "expert developer", "data scientist")
  • methodology: HOW the agent works (e.g., "step-by-step", "analytical")
  • quality: checks the result has to pass (e.g., "cite sources")
  • task: WHAT the agent has to do

The library's template combines the prompts of an agent grouped by these categories.

Configuration Reference

Static Prompt

Configuration for a static text prompt.

Static Prompt (YAML)
1
2
3
- type: static
  content: You are a helpful assistant  # The prompt text content.
  category: role  # Categorization for template organization.

File Prompt

Configuration for a file-based Jinja template prompt.

File Prompt (YAML)
1
2
3
4
- type: file
  path: prompts/system.j2  # Path to the Jinja template file.
  variables: {}  # Variables to pass to the template.
  category: role  # Categorization for template organization.

Library Prompt

Configuration for a library reference prompt.

Library Prompt (YAML)
- type: library
  reference: coding_assistant  # Library prompt reference identifier.

Function Prompt

Configuration for a function-generated prompt.

Function Prompt (YAML)
1
2
3
4
- type: function
  function: mymodule.generate_prompt  # Import path to the function that generates the prompt.
  arguments: {}  # Arguments to pass to the function.
  category: role  # Categorization for template organization.

Complete Example

prompts:
  system_prompts:
    # Role definitions
    technical_expert:
      category: role
      content: |
        You are a technical expert specializing in:
        - Software development best practices
        - System architecture and design
        - Code review and quality assurance

    # Methodology definitions
    systematic:
      category: methodology
      content: |
        Follow this systematic approach:
        1. Understand requirements fully
        2. Break down complex problems
        3. Apply best practices consistently
        4. Validate results thoroughly

    # Quality definitions
    professional:
      category: quality
      content: |
        Maintain professional communication:
        - Use formal, precise language
        - Be respectful and constructive
        - Provide clear explanations

agents:
  senior_dev:
    model: openai:gpt-5
    system_prompt:
      - "Specialize in Python and TypeScript development."
      - type: library
        reference: technical_expert
      - type: library
        reference: systematic
      - type: library
        reference: professional

Organization Best Practices

File Structure

Keep prompts organized in separate files:

# prompts/roles.yml
prompts:
  system_prompts:
    technical_expert:
      category: role
      content: ...

# prompts/styles.yml
prompts:
  system_prompts:
    professional:
      category: quality
      content: ...

# agents.yml
INHERIT:
  - prompts/roles.yml
  - prompts/styles.yml

agents:
  my_agent:
    model: openai:gpt-5-mini
    system_prompt:
      - type: library
        reference: technical_expert
      - type: library
        reference: professional

File and Function Prompts

A file prompt loads a Jinja template (relative paths resolve against the config file) and renders it with variables; a function prompt calls a function with arguments and uses the returned string:

agents:
  reviewer:
    model: openai:gpt-5-mini
    system_prompt:
      - type: file
        path: prompts/reviewer.j2
        variables:
          language: Python
      - type: function
        function: myapp.prompts:build_context_prompt
        arguments:
          team: backend

Prompt Library Reference

PromptLibraryConfig

Complete prompt configuration.

Docs: https://phil65.github.io/agentpool/configuration/prompts/

PromptLibraryConfig (YAML)
1
2
3
4
prompts:
  system_prompts: {}  # Mapping of system prompt identifiers to their definitions.
  template: null  # Optional template for combining prompts.
  providers: []  # List of external prompt providers to use.