LLM API Guide

LFM2.5-24B-A2B Tool Calling Not Working: Fixes

If LFM2.5-24B-A2B returns raw tool-call XML or no tool_calls, check the server's chat template and parser, then verify the endpoint returns finish_reason tool_calls.

Editorial illustration: LFM2.5-24B-A2B Tool Calling Not Working: Fixes
Photo-style image, AI-generated

Summary

  1. Raw tool-call XML usually means the server received content it could not parse as a native LFM2.5 call.
  2. Use the LFM2.5 template and check for tool_calls with finish_reason set to tool_calls.
On this page

Check the response before changing the prompt

Send one request with a small tool schema to the same endpoint your application uses. Liquid's documentation says LFM2.5 wraps calls in special tokens and emits Python-style calls by default. A successful OpenAI-compatible response should contain tool_calls and finish_reason set to tool_calls, as shown in the llama.cpp issue that documents the failure.

json
{
  "messages": [
    {
      "role": "user",
      "content": "Call the tool get_weather for Paris."
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get the weather for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string"
            }
          },
          "required": [
            "city"
          ]
        }
      }
    }
  ]
}

If the response puts <tool_call> in content, or returns an empty tool_calls array with finish_reason: "stop", the server treated the generated text as ordinary content. Your client cannot recover a call that the server never parsed. If your client is Cline, a separate guide covers entering a base URL, key and model ID.

Use the LFM2.5 chat template

LFM2.5 tool calls are delimited by <|tool_call_start|> and <|tool_call_end|>. The model normally writes a Python-style call such as [get_weather(city="Paris")]. Liquid's tool-use documentation says you can request JSON output by adding “Output function calls as JSON” to the system prompt.

The tool definitions must reach the model through the template. With Transformers, pass them through apply_chat_template() or include the JSON list in the system message:

python
tools_json = [{
    "name": "get_weather",
    "description": "Get the weather for a city",
    "parameters": {
        "type": "object",
        "properties": {
            "city": {
                "type": "string"
            }
        },
        "required": ["city"]
    }
}]

messages = [
    {"role": "system", "content": f"List of tools: {json.dumps(tools_json)}"},
    {"role": "user", "content": "What is the weather in Paris?"}
]

Do not replace the model's template with a Qwen3-Coder template. The open issue reports that this model can sometimes emit Qwen-style XML, while llama.cpp's LFM2.5 parser is waiting for the native control-token form.

Confirm the server selected LFM2.5 parsing

The llama.cpp report says the affected setup used both /v1/chat/completions and /v1/responses, with tools supplied. It also records that the native GGUF template parsed correctly on the same build for most turns. That gives you a useful split:

  • A normal native call from both endpoints points to intermittent model output drift or a client-side schema problem.
  • Raw XML from both endpoints points to model output that the parser does not recognise.
  • Correct output from one endpoint and missing calls from the other points to endpoint-specific response parsing in your server or SDK.

Log the complete assistant item before your application converts it into a message. For Chat Completions, inspect choices[0].message.tool_calls and choices[0].finish_reason. For Responses, inspect the function-call item instead of reading only the text field. The issue reports successful Responses calls as function_call items with a tool-call finish reason.

Keep the generation settings close to the model card

Liquid lists these generation parameters for LFM2.5-24B-A2B: temperature=0.1, top_k=50, and repetition_penalty=1.05. The model documentation also says the model always reasons before answering, so your output-token limit must leave room for that reasoning.

bash
llama-cli -hf LiquidAI/LFM2.5-24B-A2B-GGUF --temp 0.1 --top-k 50 --repeat-penalty 1.05

These values do not repair an incompatible parser. They make the serving configuration match Liquid's published starting point while you isolate the response format.

Parse the native call before executing it

Liquid's documented loop is: define tools, generate a call, execute the function, append a tool role message, then generate again. The tool-use example shows the assistant message containing the native call and the next message carrying the function result.

If your client expects OpenAI JSON only, add “Output function calls as JSON” to the system prompt and verify that the server still returns a structured tool-call field. Do not execute XML found in ordinary content as if it were a trusted function call. First decide whether your server has a documented recovery parser; otherwise return the raw response for inspection and stop the tool loop. For a separate OpenAI-compatible image API, see the Moondream image API guide.

When the issue is upstream of your client

The public llama.cpp issue reports that the XML drift appeared after repeated tool-schema errors. In that report, the client had rejected several edit-tool calls, after which the model switched to Qwen-style XML. Check the tool schema and the previous assistant and tool messages before blaming the API client.

Keep tool definitions short and send only the tools needed for the request. Liquid notes that tool definitions consume context tokens and recommends removing unused tools. A malformed schema, an incorrect tool message, or a missing tool result can change the next turn even when the first request was valid.

Not confirmed yet

Liquid's pages document the native format and local serving paths, but they do not promise that every OpenAI-compatible server will recover alternate XML forms. The llama.cpp report is still an open issue and asks whether such a recovery path should be added. Treat native control-token output as the supported format until your serving project's documentation states otherwise.

Sources and checks

  1. LFM2.5-24B-A2B: Built for Fast On-Device Agents
  2. LFM2.5-24B-A2B - Liquid Docs
  3. Tool Use - Liquid Docs
  4. Eval bug: LFM2.5-24B-A2B emits Qwen3-Coder-style tool-call XML as content