-
Notifications
You must be signed in to change notification settings - Fork 489
Description
Description
The curly template formatter ({{var}} syntax) raises a TemplateFormatError reporting unreplaced variables when a substituted input value happens to contain {{...}} patterns — even if all template variables were successfully replaced.
Steps to reproduce
from agenta.sdk.types import PromptTemplate
prompt = PromptTemplate(
user_prompt="Hello {{name}}",
template_format="curly",
)
# This raises TemplateFormatError: "Unreplaced variables in curly template: ['name']"
result = prompt.format(name="I am {{name}}")Expected behavior
The template should substitute {{name}} with the literal string "I am {{name}}", producing "Hello I am {{name}}". The {{name}} in the output is user data, not an unresolved template variable.
Actual behavior
TemplateFormatError is raised because the post-substitution validation (compute_truly_unreplaced) re-scans the rendered output for {{...}} patterns and finds {{name}} in the substituted value, falsely treating it as an unreplaced placeholder.
Root cause
The validation logic in _format_with_template (in both sdk/agenta/sdk/types.py and sdk/agenta/sdk/workflows/handlers.py) works in two phases:
- Replace all
{{expr}}placeholders with resolved values viaapply_replacements - Re-scan the output for any remaining
{{...}}patterns and intersect with the original placeholder set (compute_truly_unreplaced)
Step 2 is the problem: it cannot distinguish between {{...}} patterns that were in the original template (genuinely unreplaced) and {{...}} patterns that were injected by substituted values.
Affected code paths
PromptTemplate._format_with_templateinsdk/agenta/sdk/types.py_format_with_templateinsdk/agenta/sdk/workflows/handlers.py
Impact
Any user whose input data contains {{...}} patterns (e.g., template examples, documentation text, code snippets) will get spurious errors when using the curly template format.