Skip to content

Dynamic Prompt

The "playground" refers to OpenAI's web-based Prompt Playground at https://platform.openai.com/playground/prompts . This is a visual interface where you can create, test, and manage prompt templates that work with OpenAI's Responses API .

What is the Playground Prompt System

The Playground allows you to create prompt templates with variables using double curly brace syntax like {{variable_name}} . In the example code, you would create a system prompt template containing "Write a poem in {{poem_style}}" where poem_style is a variable that gets replaced at runtime .

Each prompt template gets assigned a unique ID (like pmpt_686a4b884b708193b5e81a4ce03c707f0422d8b0bac332ce in the example) that you reference in your code.

Benefits and Use Cases

The prompt template system provides several key benefits:

1. External Configuration: You can modify agent behavior without changing code. The prompt field allows you to "dynamically configure the instructions, tools and other config for an agent outside of your code".

2. Variable Substitution: Templates support dynamic variables that get populated at runtime, enabling personalized or context-aware prompts .

3. Version Control: The playground provides versioning for prompts, allowing you to iterate and test different versions .

4. Team Collaboration: Non-technical team members can modify prompts without touching code .

Beyond Dynamic Prompts

The prompt system does more than just provide dynamic text. When the agent runs, get_prompt() converts your prompt configuration using PromptUtil.to_model_input() configuration is then passed directly to OpenAI's Responses API.

The prompt templates can potentially configure not just instructions but also "tools and other config" as mentioned in the documentation, though the specific extent of this configuration isn't detailed in the available code snippets.

Integration Pattern

The system supports both static and dynamic prompt usage: - Static: Pass a dictionary with id, version, and variables directly to the agent - Dynamic: Use a DynamicPromptFunction that generates the prompt configuration at runtime based on context

Notes

This prompt system is specifically designed for OpenAI's Responses API and won't work with the Chat Completions API. The playground-based approach represents a shift toward external prompt management, separating prompt engineering from application code.