Skip to content

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

@alexdelorenzo

Description

@alexdelorenzo

Name and Version

❯ ./bin/llama-cli --version
ggml_cuda_init: found 1 ROCm devices:
  Device 0: AMD Radeon 780M Graphics, gfx1100 (0x1100), VMM: no, Wave Size: 32
ggml_vulkan: Found 1 Vulkan devices:
ggml_vulkan: 0 = AMD Radeon 780M Graphics (RADV PHOENIX) (radv) | uma: 1 | fp16: 1 | bf16: 0 | warp size: 64 | shared memory: 65536 | int dot: 1 | matrix cores: KHR_coopmat
version: 74 (94242a6)
built with GNU 15.2.1 for Linux x86_64

Operating systems

Linux

GGML backends

HIP

Hardware

AMD Ryzen 8840HS + 780M (as gfx1100 & gfx1103)

Models

Unsloth's Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf

Problem description & steps to reproduce

When tools are supplied to the Qwen3-Coder jinja template, it results in this error as reported below in the log output.

When no tools are supplied, template parsing works. When tools are supplied to the API, it results in a FilterExpression error.

First Bad Commit

Haven't done a bisect, but I suspect a recent jinja parser problem

Relevant log output

Logs
[41847] srv  log_server_r: response: {"error":{"code":500,"message":"\n------------\nWhile executing FilterExpression at line 57, column 53 in source:\n...{%- for json_key in param_fields.keys() | reject(\"in\", handled_keys) %}↵        ...\n                                           ^\nError: selectattr: unknown test 'in'","type":"server_error"}}
srv    operator(): http: streamed chunk: {"error":{"code":500,"message":"\n------------\nWhile executing FilterExpression at line 57, column 53 in source:\n...{%- for json_key in param_fields.keys() | reject(\"in\", handled_keys) %}↵        ...\n                                           ^\nError: selectattr: unknown test 'in'","type":"server_error"}}
srv    operator(): http: stream ended
Example error response
{
  "error": {
    "name": "AI_APICallError",
    "url": "http://127.0.0.1:8081/v1/chat/completions",
    "requestBodyValues": {
      "model": "Qwen3-Coder-30B-A3B-Instruct-Q4_K_M",
      "max_tokens": 32000,
      "top_p": 1,
      "messages": [
        {
          "role": "system",
          "content": "<snip>"
        },
        {
          "role": "user",
          "content": "example"
        }
      ],
      "tools": [
        {
            "type": "function",
            "function": {
              "name": "todoread",
              "description": "Use this tool to read your todo list",
              "parameters": {
                "$schema": "https://json-schema.org/draft/2020-12/schema",
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            }
          }
      ],
      "tool_choice": "auto",
      "stream": true,
      "stream_options": {
        "include_usage": true
      }
    },
    "statusCode": 500,
    "responseHeaders": {
      "connection": "close, close",
      "content-type": "application/json; charset=utf-8",
      "server": "llama.cpp",
      "transfer-encoding": "chunked"
    },
    "responseBody": "{\"error\":{\"code\":500,\"message\":\"\\n------------\\nWhile executing FilterExpression at line 57, column 53 in source:\\n...{%- for json_key in param_fields.keys() | reject(\\\"in\\\", handled_keys) %}↵        ...\\n                                           ^\\nError: selectattr: unknown test 'in'\",\"type\":\"server_error\"}}",
    "isRetryable": true,
    "data": {
      "error": {
        "message": "\n------------\nWhile executing FilterExpression at line 57, column 53 in source:\n...{%- for json_key in param_fields.keys() | reject(\"in\", handled_keys) %}↵        ...\n                                           ^\nError: selectattr: unknown test 'in'",
        "type": "server_error",
        "code": 500
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomersjinja parserIssues related to the jinja parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions