llama.cpp autoparser workaround lambdas in chat-diff-analyzer.cpp
Parent: Mac local LLMs: Chat templates, reasoning and tool calling · Published reference · snapshot 2026-10-05
↓ Facts as markdownall context files
`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.
These notes link each claim to its source. A source may be a research report hosted on this site rather than the primary document. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
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]
- `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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- The Solar Open lambda keys on `<|begin|>assistant<|think|><|end|>` and sets `assistant_start` to `<|begin|>assistant`. [source]
- 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]
- 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]
- 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]
- The Bailing V3 lambda fires on the text `Bailing V3 chat template`, trims the argument value suffix and sets `tolerate_intertag_whitespace`. [source]
- 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]
Children
- No children recorded.