Skip to content

security(giskard-agents)!: opt-in Jinja parsing for Workflow.chat#2346

Merged
kevinmessiaen merged 7 commits intomainfrom
feature/eng-1488-securitygiskard-agents-remove-automatic-conversion-to
Apr 3, 2026
Merged

security(giskard-agents)!: opt-in Jinja parsing for Workflow.chat#2346
kevinmessiaen merged 7 commits intomainfrom
feature/eng-1488-securitygiskard-agents-remove-automatic-conversion-to

Conversation

@kevinmessiaen
Copy link
Copy Markdown
Member

Plain strings passed to chat() are appended as literal Message content by default, avoiding server-side template injection when user input is forwarded to the model. Use as_template=True or MessageTemplate for Jinja-rendered strings.

BREAKING CHANGE: str arguments to ChatWorkflow.chat() and BaseGenerator.chat() are no longer parsed as Jinja2 templates unless as_template=True.

Refs: ENG-1488

Also sync uv.lock with current workspace package versions.

Plain strings passed to chat() are appended as literal Message content by default, avoiding server-side template injection when user input is forwarded to the model. Use as_template=True or MessageTemplate for Jinja-rendered strings.

BREAKING CHANGE: str arguments to ChatWorkflow.chat() and BaseGenerator.chat() are no longer parsed as Jinja2 templates unless as_template=True.

Refs: ENG-1488

Also sync uv.lock with current workspace package versions.

Made-with: Cursor
@linear
Copy link
Copy Markdown

linear Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the chat() method to treat strings as literal text by default, introducing an as_template parameter to explicitly enable Jinja2 templating. This change is applied to both BaseGenerator and ChatWorkflow classes and is accompanied by documentation updates and test adjustments. Feedback suggests enhancing the docstrings for these methods by adding missing parameter descriptions for role and as_template to ensure consistency and completeness.

Comment thread libs/giskard-agents/src/giskard/agents/generators/base.py
Comment thread libs/giskard-agents/src/giskard/agents/workflow.py
Add a Parameters section to ChatWorkflow.chat. Document role in BaseGenerator.chat for consistency.

Made-with: Cursor
role : Role, default "user"
The role for the message, used when ``message`` is a string.
as_template : bool, default False
When True, parse a string ``message`` as a Jinja2 template.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's warn about the security implications of this in the docstring.

Copy link
Copy Markdown
Member

@davidberenstein1957 davidberenstein1957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be merged, but these changes should also be represented in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants