Skip to content

Conversation

@Akika404
Copy link

@Akika404 Akika404 commented Dec 15, 2025

PR Description

This PR introduces an option to preserve missing template variables as their original placeholders (e.g. {var}) instead of letting StringTemplate render them as empty strings.

This behavior is only available when validationMode is set to NONE. The feature is disabled by default and does not affect existing usage; it is only enabled when keepMissingVariables(true) is explicitly configured on the renderer.


Why Do We Need It?

This is useful for:

  • Multi-stage template processing, where some variables are intentionally left for later passes.
  • Debugging templates while keeping unresolved placeholders visible.

In the context of building agents, especially multi-agent systems and Agentic RAG systems, a common pattern is to feed the output of one agent into the prompt of another. The original output or example prompts often contain JSON blocks or other structures with braces, for example:

{
  "sections": [
    { "index": 1, "title": "Intro" }
  ]
}

The existing StTemplateRenderer and NoOpTemplateRenderer cannot fully address this scenario when parts of the prompt are meant to remain unchanged across stages. Since this is a high-frequency usage pattern, it is helpful to enhance StTemplateRenderer with an option that preserves unresolved placeholders instead of silently stripping them.


Behavior

When keepMissingVariables(true) is set (with validationMode = NONE), any variables that are referenced in the template but not provided in the variables map are rendered as their original placeholder text (e.g. {var}) instead of being rendered as empty strings.

For example:

{input_data} // This should be replaced
---
{
  "sections": [
    { "index": 1, "title": "Intro" }
  ]
} // This part should be preserved as-is

If only input_data is provided in the variables map, the rendered result will keep the JSON block unchanged while replacing {input_data} with its value.

@Akika404 Akika404 force-pushed the feature/keep-missing-template-variables branch from 8d02a6a to 9d31959 Compare December 15, 2025 10:40
@Akika404 Akika404 force-pushed the feature/keep-missing-template-variables branch from cb3211b to a153485 Compare December 15, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants