Skip to content

jinja : add missing 'in' test to template engine (#19004)#19239

Merged
ngxson merged 2 commits intoggml-org:masterfrom
sidmohan0:fix/jinja-in-test
Feb 2, 2026
Merged

jinja : add missing 'in' test to template engine (#19004)#19239
ngxson merged 2 commits intoggml-org:masterfrom
sidmohan0:fix/jinja-in-test

Conversation

@sidmohan0
Copy link
Contributor

@sidmohan0 sidmohan0 commented Feb 1, 2026

Hey all!

Note: Fixes #19004

Context:

The jinja template parser was missing the 'in' test from global_builtins(), causing templates using reject("in", ...), select("in", ...), or 'x is in(y)' to fail with selectattr: unknown test 'in'

This broke tool-calling for Qwen3-Coder and would break for any other model whose chat template uses the in test.

What I did:

  • Added test_is_in supporting array, string, and object containment checks, mirroring the existing 'in' operator logic in runtime.cpp.
  • Includes test cases for all three containment types plus reject/select filter usage.

Local Test environment:

  • Windows 11 26200 (x64), Intel i7-10700K, 64GB RAM
  • MSVC 17.14.25 (VS Build Tools 2022)
  • CMake 4.2.0-rc4
  • All 279 jinja tests pass (1241 assertions, 0 failures, 0 exceptions)

Comments:

  • Shouldn't impact existing entries as we're just adding a new entry; the only way this code runs is if a template explicitly uses the in test

AI Disclosure

Built with Claude (AI-assisted). Fully tested locally. I understand what the code does.

Appreciate the look - let me know if you have any questions!

The jinja template parser was missing the 'in' test from
global_builtins(), causing templates using reject("in", ...),
select("in", ...), or 'x is in(y)' to fail with
"selectattr: unknown test 'in'".

This broke tool-calling for Qwen3-Coder and any other model
whose chat template uses the 'in' test.

Added test_is_in supporting array, string, and object containment
checks, mirroring the existing 'in' operator logic in runtime.cpp.

Includes test cases for all three containment types plus
reject/select filter usage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ngxson
Copy link
Contributor

ngxson commented Feb 1, 2026

This PR appears to contain AI-generated code without proper disclosure or watermarking. Per our contribution guidelines, we cannot accept it in its current form.

@sidmohan0
Copy link
Contributor Author

This PR appears to contain AI-generated code without proper disclosure or watermarking. Per our contribution guidelines, we cannot accept it in its current form.

Thank you for flagging - just updated the PR description. Sincere apologies for the oversight - genuinely did not mean to mislead.

@ngxson ngxson merged commit 0dfcd3b into ggml-org:master Feb 2, 2026
69 of 78 checks passed
shaofeiqi pushed a commit to qualcomm/llama.cpp that referenced this pull request Feb 6, 2026
…ml-org#19239)

* jinja : add missing 'in' test to template engine (ggml-org#19004)

The jinja template parser was missing the 'in' test from
global_builtins(), causing templates using reject("in", ...),
select("in", ...), or 'x is in(y)' to fail with
"selectattr: unknown test 'in'".

This broke tool-calling for Qwen3-Coder and any other model
whose chat template uses the 'in' test.

Added test_is_in supporting array, string, and object containment
checks, mirroring the existing 'in' operator logic in runtime.cpp.

Includes test cases for all three containment types plus
reject/select filter usage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* reuse test_is_in in binary op

---------

Co-authored-by: Sid Mohan <sidmohan0@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
liparetejas pushed a commit to liparetejas/llama.cpp that referenced this pull request Feb 23, 2026
…ml-org#19239)

* jinja : add missing 'in' test to template engine (ggml-org#19004)

The jinja template parser was missing the 'in' test from
global_builtins(), causing templates using reject("in", ...),
select("in", ...), or 'x is in(y)' to fail with
"selectattr: unknown test 'in'".

This broke tool-calling for Qwen3-Coder and any other model
whose chat template uses the 'in' test.

Added test_is_in supporting array, string, and object containment
checks, mirroring the existing 'in' operator logic in runtime.cpp.

Includes test cases for all three containment types plus
reject/select filter usage.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* reuse test_is_in in binary op

---------

Co-authored-by: Sid Mohan <sidmohan0@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jinja parser Issues related to the jinja parser testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval bug: Qwen3-Coder template parsing error when tools are enabled

2 participants