Error in chat template?

#9
by WebWeaverWraith - opened

I'm running Devstral-Small-2-24B-Instruct-2512-UD-Q4_K_XL.gguf using llama-server and connect things like Mistral-Vibe or Claude Code to it and sometimes this happens randomly. But every time I have to restart the server and it picks up from a timeout, I get this and have to abandon the session and reset my context to clear the issue. Does anyone know how to fix this?

llama-server[121886]: [34763] srv operator(): got exception: {"error":{"code":500,"message":"After the optional system message, conversation roles must alternate user and assistant roles except for tool calls and results. at row 189, column 164:\n {%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}\n {{- raise_exception('After the optional system message, conversation roles must alternate user and assistant roles except for tool calls and results.') }}\n ^\n {%- endif %}\n at row 189, column 13:\n {%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}\n {{- raise_exception('After the optional system message, conversation roles must alternate user and assistant roles except for tool calls and results.') }}\n ^\n {%- endif %}\n at row 188, column 69:\n {%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}\n {%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}\n ^\n {{- raise_exception('After the optional system message, conversation roles must alternate user and assistant roles except for tool calls and results.') }}\n at row 188, column 9:\n {%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}\n {%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}\n ^\n {{- raise_exception('After the optional system message, conversation roles must alternate user and assistant roles except for tool calls and results.') }}\n at row 187, column 176:\n{%- for message in loop_messages %}\n {%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}\n ^\n {%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}\n at row 187, column 5:\n{%- for message in loop_messages %}\n {%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}\n ^\n {%- if (message['role'] == 'user') != (ns.index % 2 == 0) %}\n at row 186, column 36:\n{%- set ns = namespace(index=0) %}\n{%- for message in loop_messages %}\n ^\n {%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}\n at row 186, column 1:\n{%- set ns = namespace(index=0) %}\n{%- for message in loop_messages %}\n^\n {%- if message.role == 'user' or (message.role == 'assistant' and (message.tool_calls is not defined or message.tool_calls is none or message.tool_calls | length == 0)) %}\n at row 1, column 30:\n{#- Unsloth template fixes #}\n ^\n{%- set yesterday_day = strftime_now("%d") %}\n","type":"server_error"}}

I've been running into the exact same problem using LM Studio as my backend.

I'm certain it's a minor issue with the template that can be fixed, but in the meantime I am using a rewrite from Claude Opus. If you're interested in a temporary fix to get things up and running, try setting this as your Jinja template: https://share.burke.su/devstral-small-2-jinja-fix.txt

Looking forward to seeing this resolved!

I've been running into the exact same problem using LM Studio as my backend.

I'm certain it's a minor issue with the template that can be fixed, but in the meantime I am using a rewrite from Claude Opus. If you're interested in a temporary fix to get things up and running, try setting this as your Jinja template: https://share.burke.su/devstral-small-2-jinja-fix.txt

Looking forward to seeing this resolved!

Running to similar issues. Just wanted to share that the link worked for me. Thanks for posting.

Sign up or log in to comment