Failing to parse Jinja template with tojson(ensure_ascii=false) #2676

Closed
opened 2026-02-16 17:36:47 -05:00 by yindo · 3 comments
Owner

Originally created by @chrismuzyn on GitHub (Nov 7, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

I am getting the following error from opencode while trying to leverage the GLM 4.6 model in llama.cpp:

ERROR 2025-11-07T18:19:53 +0ms service=session.prompt session=ses_5a0742951ffeiC5g5rd7Xb757C error=Unknown argument ensure_ascii for function tojson at row 11, column 37:
{% for tool in tools %}
{{ tool | tojson(ensure_ascii=False) }}
                                    ^
{% endfor %}
 at row 11, column 1:
{% for tool in tools %}
{{ tool | tojson(ensure_ascii=False) }}
^
{% endfor %}

I am running GLM 4.6 via ik_llama.cpp, which is using the default glm 4.6 template here: https://huggingface.co/zai-org/GLM-4.6/blob/main/chat_template.jinja

I think I'm missing a jinja dependency on my host running opencode, but I'm not sure what that is. I've tried installing the python3-jinja package in the rocky repos. If I run ik_llama.cpp with a custom template that has ensure_ascii=false removed, I am able to prompt with opencode successfully.

OpenCode version

1.0.41

Steps to reproduce

  1. prompt a model that has a jinja chat template that includes tojson(ensure_ascii=false)

Screenshot and/or share link

No response

Operating System

Rocky 9

Terminal

Gnome Terminal

Originally created by @chrismuzyn on GitHub (Nov 7, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description I am getting the following error from opencode while trying to leverage the GLM 4.6 model in llama.cpp: ``` ERROR 2025-11-07T18:19:53 +0ms service=session.prompt session=ses_5a0742951ffeiC5g5rd7Xb757C error=Unknown argument ensure_ascii for function tojson at row 11, column 37: {% for tool in tools %} {{ tool | tojson(ensure_ascii=False) }} ^ {% endfor %} at row 11, column 1: {% for tool in tools %} {{ tool | tojson(ensure_ascii=False) }} ^ {% endfor %} ``` I am running GLM 4.6 via ik_llama.cpp, which is using the default glm 4.6 template here: https://huggingface.co/zai-org/GLM-4.6/blob/main/chat_template.jinja I think I'm missing a jinja dependency on my host running opencode, but I'm not sure what that is. I've tried installing the python3-jinja package in the rocky repos. If I run ik_llama.cpp with a custom template that has ensure_ascii=false removed, I am able to prompt with opencode successfully. ### OpenCode version 1.0.41 ### Steps to reproduce 1. prompt a model that has a jinja chat template that includes `tojson(ensure_ascii=false)` ### Screenshot and/or share link _No response_ ### Operating System Rocky 9 ### Terminal Gnome Terminal
yindo added the bug label 2026-02-16 17:36:47 -05:00
yindo closed this issue 2026-02-16 17:36:47 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1890: Very similar Jinja template parsing issues with llama.cpp - discusses tool template crashes and "Value is not callable" errors when using Jinja templates
  • #3754: Another llama.cpp + Jinja template compatibility issue with similar error patterns

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Nov 7, 2025): This issue might be a duplicate of existing issues. Please check: - #1890: Very similar Jinja template parsing issues with llama.cpp - discusses tool template crashes and "Value is not callable" errors when using Jinja templates - #3754: Another llama.cpp + Jinja template compatibility issue with similar error patterns Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Nov 7, 2025):

I think some people in https://github.com/sst/opencode/issues/1890 were talking about a similar problem

@rekram1-node commented on GitHub (Nov 7, 2025): I think some people in https://github.com/sst/opencode/issues/1890 were talking about a similar problem
Author
Owner

@chrismuzyn commented on GitHub (Nov 11, 2025):

I have traced the issue to llama.cpp to minja.hpp and found it is being tracked here: https://github.com/google/minja/issues/82. I will close this, thank you.

To anyone else who finds this, I am copy and pasting minja.hpp from the official maintainer's implementation to compile llama.cpp and ik_llama.cpp: https://github.com/ochafik/minja

@chrismuzyn commented on GitHub (Nov 11, 2025): I have traced the issue to llama.cpp to minja.hpp and found it is being tracked here: https://github.com/google/minja/issues/82. I will close this, thank you. To anyone else who finds this, I am copy and pasting minja.hpp from the official maintainer's implementation to compile llama.cpp and ik_llama.cpp: https://github.com/ochafik/minja
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2676