Hermes Agent + chat template: tool calls fail silently (XML vs JSON format)

#46
by k-mktr - opened

If you are running Ornith with a qwen3.6-froggeric chat template through Hermes Agent and wondering why tool calling does not work - the model outputs XML but Hermes expects JSON.

Root cause

The chat template (qwen3.6-froggeric-v21.3) defaults to XML tool call format:

{%- set _tool_format = tool_call_format if tool_call_format is defined else "xml" %}

The model follows instructions and outputs XML like:

<function=web_search>
<parameter=query>current Bitcoin price</parameter>

But Hermes Agent expects standard OpenAI JSON tool calls. Result: finish_reason: stop instead of tool_calls. The agent never receives tool results and falls back to text-only responses.

Fix

In your Hermes config (~/.hermes/config.yaml), under the model: section, add:

model:
  chat_template_kwargs: '{"tool_call_format": "json"}'
  extra_body: '{"chat_template_kwargs": {"tool_call_format": "json"}}'

This tells the template engine to use JSON format instead of XML. The template supports this natively.

Alternative fix (server-side)

Change the default in chat_template.jinja itself from xml to json on line 2. This makes it work for all clients without client-side config.

Why this matters

This is a silent failure - no errors, no warnings. The model appears to work but never actually uses tools. If you see tool_turns=0 in Hermes agent logs despite tools being available, this is likely why.

The same mechanism works for other template parameters: enable_thinking, auto_disable_thinking_with_tools, preserve_thinking, max_tool_arg_chars, max_tool_response_chars.

This comment has been hidden (marked as Spam)
This comment has been hidden

Is this really the case though?

I have been using the hermes agent since May and been using the older v20 XML only froggeric chat template with both qwen3.6-27b/qwen3.6-35b-a3b via GGUF + the latest beta llama.cpp and have not run into problems.

the newest v21.3 froggeric that splits json/xml has been a nightmare though. i made edits and removed all reference to JSON and my hermes agent is just fine doing large 20-30+ toolcall oneshots for briefing crons with the standard v21.3 froggeric chat template using XML now. I've been running the v21.3 with my edits for a week now and only 1x time out of >42 briefing crons, each executing 5-30+ tool calls in a single one-shot cron session over a week (6+ crons per day), did i have a problem.

edit to clarify, i suppose this may only be a llama.cpp behavior which handles XML better. the whole point of that JSON addition to my recollection was to support vLLM.

Sign up or log in to comment