A Guide to Dynamic Prompt Architecture
At first view, the Pega GenAI Connect™ rule seems straight forward: Add a step in your Case Lifecycle to call a Large Language Model with a prompt, and map the response to your data model.
The rule type allows you to take values from existing properties in your data model as input as well, using them as field value parameters, so you can create prompts like:
“Summarize the following user message into three main bullet points: {.UserMessage}.”
The response is then mapped to one or more fields in your Data Model.
This is an effective and quick way to add GenAI capabilities to your Case. It also gives a lot of control on exactly what is sent to the LLM at which step in the Case Life Cycle, making the Connect GenAI rule ideal for more predictable situations in which we know what we want to happen.
But this approach uses rather static prompts, which limits reusability and can lead to the creation of many slightly different GenAI Connect rules.
To build more scalable and enterprise-grade solutions, we can adopt dynamic prompting patterns.
This guide details three foundational patterns for parameterizing your Pega GenAI Connect prompts.
This technique involves parameterizing part of the prompt itself. Instead of hard-coded instructions, your prompt becomes a template that is dynamically assembled at runtime.
This lets you dynamically ‘load’ parts of the prompt depending on the case context or user selections.
The GenAI Connect rule allows us to do this by populating fields in the Case Data Model with the appropriate prompt snippets, and then include these as field value parameters in the final prompt.
Architectural Patterns for implementation
Here are three concrete patterns for implementing dynamic instruction insertion in your Pega applications.
Pattern A: Case context drives prompt instructions
This pattern uses case context to select the right prompt instructions at the right time.
-
How it works: Use a decision shape or decision table in the case flow to determine the required instruction text. A Data Transform then populates a text property (e.g., .DynamicInstructions) which is referenced in the GenAI Connect rule’s prompt.
-
Best for: Scenarios where the AI’s task changes based on case type, status, or other structured data within the case, but where key parts of the prompt remains the same between scenarios. For example, summarizing a customer email differently for a “Complaint” case versus an “Inquiry” case.
**
Pattern B: Modular / Smart Shape Architecture approach**
This pattern is ideal for creating reusable GenAI capabilities that can be consumed by multiple implementation applications.
- How it works: The core GenAI Connect rule is built in a reusable Module or Smart Shape, with a pre-set library of Prompt instructions. A Low-Code developer in App Studio using this functionality in an implementation application would use Config Sets or parameter settings to select which Prompt parts are included in that specific implementation.
- Best for: Giving low-code developers a safe and controlled way to leverage powerful GenAI functions in their apps. Suitable when providing multiple options for more common GenAI functions (e.g., “Summarize,” “Sentiment Analysis”, or “Rewrite”) that can be deployed across multiple applications.
Pattern C: Business Control over parts of the prompt
This pattern allows Business Managers or Low-Code Developer to change specific parts of prompt instructions without the need to change any rules.
- How it works: The main framework and guardrails of the GenAI Connect rules remain under control of the LSA. Specific parts of the prompt are sources from a Configuration Setting or a Data Property managed through a dedicated instruction management Case Type.
- Best for: Delegating the maintenance of parts of the prompt instructions to business managers. Changing the instructions will impact the outcomes of the GenAI Connect step, and so changes should be carefully assessed.
These patterns are just examples; other implementation patterns are possible as well.
Why Adopt This Dynamic Approach?
Moving from static to dynamic prompts offers three significant architectural advantages:
-
Maximize Reusability: A single, robust GenAI Connect rule can serve dozens of slightly different use cases. This eliminates rule duplication and prevents overly complex, conditional logic inside the prompt itself, which would carry additional GenAI interpretation risk.
-
Enable Modular Design: Package your core GenAI Connect logic as a reusable component. Implementation-layer developers can then set their specific instructions using parameters, without needing to modify the centrally governed base rule.
-
Empower Business Users: Delegate control of specific prompt instructions to business or low-code users. By sourcing instructions from a delegated data type or configuration set, you allow the business to refine AI behavior without requiring a new development cycle.


