Introduction
At DB Results, our R&D team is always looking for ways to push what’s possible in Low-Code. Since Agentic AI is becoming a huge part of the enterprise world, we’ve been focusing on the real-world challenges of making it scale. In this deep dive, we’re looking at the Prompt Assembler, which is a pattern we developed to decouple AI prompts from the core logic in OutSystems ODC.
During a recent internal Hackathon, I set out to build an AI agent designed to automate project estimation. Spoiler alert: I didn’t win the competition. But while I walked away without the trophy, the experience forced me to confront a bottleneck that was much more valuable to solve than the hackathon challenge itself.
The goal was to use RAG to retrieve past Jira tickets and apply business rules to generate effort estimates. The architecture was solid, but I quickly hit a frustrating wall.
Every time I needed to tweak the system prompt, whether refining how the AI interpreted data or adjusting its tone, I had to republish the entire application. I found myself staring at a deployment progress bar just to change a few words in the instructions. It was a massive waste of time.
That’s when it clicked: I was treating prompts like code, but they are actually content. They need to evolve much faster than the standard application lifecycle allows.
I wanted a solution native to OutSystems Developer Cloud (ODC), something that gave me control without adding external API calls. So, I built Prompt Assembler: a tool that centralizes AI prompts and serves them dynamically.
The Architecture
To solve the republishing problem, I needed to decouple the prompt logic from the application logic. I used a Service-Oriented architecture to keep things clean and modular.
Prompt Assembler is a standalone ODC App that owns all the data entities: Projects, Groups, Templates, and Roles. It exposes its functionality to other ODC apps strictly through Service Actions.
This creates a “Headless” architecture composed of two parts:
- The Admin UI: A front-end where Product Owners can manage Projects and Templates without touching a single line of code.
- The Consumer Apps: Your chatbots or agents never store the prompt text locally. They simply request it when needed.
How the Flow Works
- The Request: The consumer app calls a Service Action (e.g., Assemble_Prompt), passing a specific Key (like Project_Estimation) and any dynamic variables required.
- The Assembly: Prompt Assembler looks up the Key, fetches the latest template, substitutes the variables, and returns the fully formatted string.
- The Result: The consumer app receives the prompt and immediately sends it to the LLM.
This setup allows me to rewrite an entire system prompt in the Admin UI and click “Save.” The consumer app picks up the new behaviour instantly on the next run, with no republishing required.
It also enables reusability. Multiple agents can share the same base persona or “System Prompts” without duplicating text across different modules.
Under the Hood: How Assemble_Prompt Works
The core of the system is the Assemble_Prompt Service Action. I designed it to be flexible enough to handle both simple strings and complex, multi-message agent instructions without the consumer app needing to know the difference.
1. Smart Keys
The action accepts a list of Keys (an array). This allows the consumer app to mix and match different prompt components dynamically.
- Composability: You can pass multiple keys (e.g., [“Global_System_Persona”, “Specific_Task_Instructions”]) and the assembler will stitch them together in order.
- Group Abstraction: A key can still refer to a “Group” (like Estimation_Flow), which expands into multiple templates on the backend.
2. Regex-Based Variable Injection
I didn’t want to rely on simple Replace() functions, which can become brittle as complexity grows. Instead, I used a Regex pattern to identify placeholders dynamically:
$<<([^\<\>]+)>>$
This pattern captures any token enclosed in double chevrons, such as <<Task>> or <<Platform>>. At runtime, the action follows a strict three-step logic:
- Extract: It scans the stored text and finds all placeholders matching the pattern.
- Validate: It ensures the Variables list passed by the consumer contains values for every required placeholder.
- Substitute: It injects the values and returns the final string.
Example Usage
Here is how a consumer app requests a prompt. Note that the app only provides raw data, not instructions
Abstract Representation (JSON):
JSON
Assemble_Prompt(
Keys: ["vica_chatassistant_user"],
Variables: [
{ "PlaceHolderKey": "ChatHistory", "Values": ["User: I need help with my policy..."] },
{ "PlaceHolderKey": "CallSummary", "Values": ["Customer is asking about renewal."] },
{ "PlaceHolderKey": "Transcript", "Values": ["00:01 Agent: Hello..."] },
{ "PlaceHolderKey": "....", "Values": ["...."] }
]
)
Real-world Implementation (ODC Studio):
The screenshot below shows this in action within an ODC consumer application flow.
In this example flow, the logic first decides if RAG context is needed. It then calls the Assemble_Prompt action (highlighted as User_Prompt).
Looking at the properties panel on the right:
- The Key: The app requests the prompt associated with the key “vica_chatassistant_user”.
- The Variables: The developer maps local variables (like ChatMessage, CallSummary, and Transcript) to the specific placeholders requested by that prompt template.
The beauty of this is what you don’t see: hardcoded text. The developer of this flow doesn’t need to know what the prompt says, only what data it requires.
Output:
You are an AI assistant… Here is the conversation history: [ChatMessage content]… And the call summary: [CallSummary content]…
Why This Architecture Wins
After using this tool in my Hackathon project (and now in daily work), I realized the biggest benefit wasn’t just technical, it was process.
1. The Two-Speed Lifecycle
In a traditional setup, prompts are buried in code, locking the Prompt Engineer to the software release cycle. With Prompt Assembler, we decouple these completely:
- The Developer only needs to know the Key (e.g., Estimation_Agent) to build the logic. They can build the entire flow using placeholder text.
- The Product Owner can refine the actual prompt text, adjust the tone, or fix edge cases in the Admin UI. They can do this simultaneously without ever blocking the dev team.
2. Zero-Deployment Iteration
Prompts are never “finished” at launch; they are live content. Users will always ask things you didn’t anticipate. This tool allows us to treat prompts as dynamic data. If we notice the AI is being too verbose in Production, we can fix it instantly in the Prompt Assembler. No hot-fix deployment, no downtime, and no “waiting for the next sprint” just to change a sentence.
3. Environment-Aware Tuning
I can configure prompts to behave differently based on the environment.
- In Development: I inject “verbose” instructions to help me debug the AI’s reasoning chain.
- In Production: I switch to a “concise” version to save tokens and reduce latency. This happens automatically at runtime, without changing a single line of logic in the consumer app.
4. Collision Detection (Safety Nets)
One major headache with complex prompt chains is accidentally reusing variable names. I added logic that scans the entire group of templates (System + Context + User) and warns me if I’ve defined the same placeholder twice. This prevents “silent overwrites” where one variable clobbers another at runtime. This is a safety net you simply don’t get with hardcoded strings.
Governance: Treat Prompts Like Code
This tool grants the power to change application behavior instantly. However, that power requires safeguards.
Just because we can edit a prompt in Production doesn’t mean we should do so loosely. I found that applying software engineering discipline to prompt management is essential for governance.
1. Testing Policy
A prompt should never be created directly in Production. It must be authored in a non-prod environment, tested against a regression set (e.g., ensuring the agent still calculates estimates correctly), and only then promoted.
2. Production Locking
We need policies that restrict editing prompts in the Production environment. Hot-fixes should be reserved strictly for critical issues, such as severe hallucinations or safety jailbreaks.
3. Auditability
Since a prompt change alters the software’s behavior, every edit in the Admin UI must be logged. We need to know exactly who changed the “System Persona” on Friday night and why.
The Catch: The JSON Contract
There is one critical architectural risk to watch out for with this “Headless” pattern: The Data Structure.
The Friction: Text vs. Records
Fundamentally, LLMs output unstructured text, but ODC requires structured Records to execute logic (like saving to a database). To bridge this gap, we instruct the AI to output JSON. This acts as the translation layer: the AI generates a string like “{ “Cost”: 100 }”, and ODC parses that string into a strict Structure (e.g., Integer Cost).
The Hidden Dependency
Whether you use the manual JSON Deserialize widget or the native Agent Structured Output, ODC relies on a rigid schema defined at design time.
This creates a tight coupling between your prompt text and your compiled code:
- The Mismatch: If the Prompt Assembler instructs the AI to output {“EstimatedCost”: 100}, but your ODC Agent Action is configured to expect {“Cost”: 100}, the native parser will fail.
- The Consequence: The application logic breaks (or returns empty values) because the semantic definition in the prompt no longer matches the technical definition in the code.
How to Mitigate This
We cannot let Prompt Engineers change the output structure wildly.
- Treat JSON as an API Contract: The content of the prompt (“You are a helpful assistant…”) can change freely. However, the JSON Schema (the keys and data types) must be treated with the same rigidity as a database schema or REST API contract.
- Use Versioning: If you need to change the structure (e.g., adding a new Rationale field), do not overwrite the existing prompt. Create a new Prompt Key (e.g., Estimation_Agent_v2) and update the ODC Agent Action to handle the new structure before switching over.
Conclusion
We often champion “Low-Code” for building apps, but we need to apply that same mindset to our AI operations. Hardcoding prompts is the “High-Code” way of doing things. It is rigid, slow, and fragile.
By treating prompts as data and serving them via a native ODC “Prompt Assembler,” we gain speed, governance, and flexibility.
I am currently working on extending this tool to support Vector Enrichment (for native RAG support) and Prompt Versioning so we can roll back instantly if a new prompt performs poorly.
If you are building AI in ODC, stop hardcoding. Build yourself an assembler.
The Prompt Assembler is just one example of how we are evolving the Agentic SDLC for our clients. If you’re looking to implement advanced AI patterns or want to discuss how to bring better governance to your ODC environment, reach out today!
Connect with us