Repository navigation
Python: Fix Handlebars messages helper ignoring its argument - #14537
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits intoNov 2, 2026
Conversation
PRABHU KIRAN VANDRANKI (VANDRANKI)
requested a review
from a team
as a code owner
October 4, 2026 20:21
PRABHU KIRAN VANDRANKI (VANDRANKI)
temporarily deployed
to
github-app-auth
October 4, 2026 20:21 — with
GitHub Actions
Inactive
PRABHU KIRAN VANDRANKI (VANDRANKI)
temporarily deployed
to
github-app-auth
October 4, 2026 20:21 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The newly introduced no-argument fallback lacks integration coverage.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes the Handlebars messages helper to honor its argument while retaining context fallback behavior.
Changes:
- Uses the first helper argument when provided.
- Adds regression tests for argument selection.
| File | Description |
|---|---|
handlebars_system_helpers.py |
Corrects chat-history resolution. |
test_handlebars_prompt_template.py |
Tests explicit argument handling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
PRABHU KIRAN VANDRANKI (VANDRANKI)
temporarily deployed
to
github-app-auth
October 4, 2026 20:40 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
enabled auto-merge
October 27, 2026 08:50
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Oct 27, 2026
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Nov 2, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation and Context
The Handlebars
messageshelper ignores its argument.{{messages my_history}}always readschat_historyfrom the context, so it raisesKeyErrorwhen that variable is missing and renders the wrong history when both exist. The Jinja2messages(history)helper uses its argument.Fixes #14535
Description
_messagesinhandlebars_system_helpers.pynow uses the first positional argument. If no argument is given it falls back to thechat_historycontext variable, so existing{{messages chat_history}}templates behave the same. The unusedoptionsparameter was removed. For a non-block helper pybars passes the first argument in that slot, which is why the argument was never visible. A bare{{messages}}used to raiseTypeErrorand now works through the fallback.Added two tests (argument with a different variable name, and argument preferred over a
chat_historyvariable). Both fail onmain.tests/unit/prompt_template,tests/unit/kernelandtests/unit/functionspass. ruff check clean on the touched files, mypy clean on the helper module.Contribution Checklist