<!-- llms-explorer concept facts · https://llms-explorer.com/tree/llama-cpp-autoparser-workaround-lambdas-in-chat/ · pack 2026-10-05 · ~1374 tokens -->

# llama.cpp autoparser workaround lambdas in chat-diff-analyzer.cpp

> `workarounds` holds 12 lambdas, in this order: old Qwen/DeepSeek reasoning, Granite 3.3, Cohere Command R+, Functionary 3.1, DeepSeek-R1-Distill-Qwen, Nemotron Nano v2, Fireworks v2, Solar Open, Apriel 1.6, JSON name/parameters tool instruction, Laguna, Bailing V3.

Parent: [Mac local LLMs: Chat templates, reasoning and tool calling](https://llms-explorer.com/tree/mac-local-llms-chat-templates-reasoning-and-tool-calling/) · 1 facets · 15 facts · page: https://llms-explorer.com/tree/llama-cpp-autoparser-workaround-lambdas-in-chat/

## Facts

- `workarounds` holds 12 lambdas, in this order: old Qwen/DeepSeek reasoning, Granite 3.3, Cohere Command R+, Functionary 3.1, DeepSeek-R1-Distill-Qwen, Nemotron Nano v2, Fireworks v2, Solar Open, Apriel 1.6, JSON name/parameters tool instruction, Laguna, Bailing V3. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- `analyze_template` applies the workarounds after `collect_preserved_tokens()` and before the debug dump, in vector order, so a later lambda sees an earlier lambda's edits. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The old Qwen/DeepSeek lambda fires when the source contains `content.split('</think>')`, lacks `reasoning_content` and `<SPECIAL_12>`, and the analysis found reasoning mode NONE; it then sets TAG_BASED reasoning with `<think>` and `</think>` and preserves both tokens. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Granite 3.3 lambda keys on the instruction `Write your thoughts between <think></think> and write your response between <response></response>`, sets TAG_BASED reasoning and content mode WRAPPED_WITH_REASONING with `<response>` and `</response>`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Cohere lambda fires on `<|CHATBOT_TOKEN|>` and `<|END_OF_TURN_TOKEN|>` when `content.start` is empty, sets ALWAYS_WRAPPED content with those tokens and sets `user_start` to `<|START_OF_TURN_TOKEN|><|USER_TOKEN|>`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Functionary lambda keys on `set has_code_interpreter = tools | selectattr("type", "equalto", "code_interpreter") | list | length > 0`, sets PLAIN content, empties the tool section delimiters, sets per-call `<function=` and `</function>`, and replaces the preserved tokens with `<|eot_id|>`, `<|eom_id|>`, `<function=`, `>` and `</function>`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The DeepSeek-R1-Distill-Qwen lambda keys on the `<｜Assistant｜><｜tool▁calls▁begin｜><｜tool▁call▁begin｜>` template fragment and sets the tool section, per-call, name-prefix `<｜tool▁sep｜>` and close `` ``` `` markers. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Nemotron Nano v2 lambda fires when the source has `<SPECIAL_10>`, `<SPECIAL_11>`, `<SPECIAL_12>` and `<TOOL_RESPONSE>`, and sets JSON_NATIVE tool format with `<TOOLCALL>` and `</TOOLCALL>` wrapped in an array, PLAIN content, TAG_BASED reasoning with start `<think>` followed by a newline, `assistant_start` `<SPECIAL_11>Assistant` and `user_start` `<SPECIAL_11>User`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Fireworks v2 lambda keys on a `system_prompt_suffix` line in the template and sets only `assistant_start` and `user_start` to the Llama-3 style header strings. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Solar Open lambda keys on `<|begin|>assistant<|think|><|end|>` and sets `assistant_start` to `<|begin|>assistant`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Apriel 1.6 lambda keys on `if not loop.last and '[BEGIN FINAL RESPONSE]' in asst_text` and sets `user_start` `<|begin_user|>` and `assistant_start` `<|begin_assistant|>`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The JSON name/parameters lambda fires when the template contains `Respond in the format {"name": function name` and `Do not use variables.`, and sets `tools.format.openai_wrapper_trigger = true`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Laguna lambda fires on `laguna_glm_thinking`, trims whitespace from the reasoning start and end and from the tool-argument value prefix, suffix and separator, sets `tolerate_intertag_whitespace`, and pushes the literal stop `</assistant>` to `additional_stops`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- The Bailing V3 lambda fires on the text `Bailing V3 chat template`, trims the argument value suffix and sets `tolerate_intertag_whitespace`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
- Of the 12 lambdas, only the Laguna lambda adds to `additional_stops`, and only Cohere, Nemotron Nano v2, Fireworks v2 and Apriel 1.6 set `user_start`. — [source](https://raw.githubusercontent.com/ggml-org/llama.cpp/master/common/chat-diff-analyzer.cpp)
