Text Generation
Transformers
Safetensors
English
Chinese
qwen3_5_text
Merge
ties
della
model-stock
geodella
qwen
qwen3.5
causal-lm
deltanet
linear-attention
agentic
reasoning
code
swe-bench
conversational
Instructions to use pragmaticcs/PentaCoder-9B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pragmaticcs/PentaCoder-9B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="pragmaticcs/PentaCoder-9B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("pragmaticcs/PentaCoder-9B") model = AutoModelForCausalLM.from_pretrained("pragmaticcs/PentaCoder-9B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pragmaticcs/PentaCoder-9B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pragmaticcs/PentaCoder-9B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pragmaticcs/PentaCoder-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/pragmaticcs/PentaCoder-9B
- SGLang
How to use pragmaticcs/PentaCoder-9B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "pragmaticcs/PentaCoder-9B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pragmaticcs/PentaCoder-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "pragmaticcs/PentaCoder-9B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pragmaticcs/PentaCoder-9B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use pragmaticcs/PentaCoder-9B with Docker Model Runner:
docker model run hf.co/pragmaticcs/PentaCoder-9B
Upload tokenizer_config.json with huggingface_hub
Browse files- tokenizer_config.json +286 -0
tokenizer_config.json
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_prefix_space": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"248044": {
|
| 6 |
+
"content": "<|endoftext|>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"248045": {
|
| 14 |
+
"content": "<|im_start|>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"248046": {
|
| 22 |
+
"content": "<|im_end|>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"248047": {
|
| 30 |
+
"content": "<|object_ref_start|>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"248048": {
|
| 38 |
+
"content": "<|object_ref_end|>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"248049": {
|
| 46 |
+
"content": "<|box_start|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"248050": {
|
| 54 |
+
"content": "<|box_end|>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"248051": {
|
| 62 |
+
"content": "<|quad_start|>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"248052": {
|
| 70 |
+
"content": "<|quad_end|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"248053": {
|
| 78 |
+
"content": "<|vision_start|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"248054": {
|
| 86 |
+
"content": "<|vision_end|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"248055": {
|
| 94 |
+
"content": "<|vision_pad|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"248056": {
|
| 102 |
+
"content": "<|image_pad|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"248057": {
|
| 110 |
+
"content": "<|video_pad|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"248058": {
|
| 118 |
+
"content": "<tool_call>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": false
|
| 124 |
+
},
|
| 125 |
+
"248059": {
|
| 126 |
+
"content": "</tool_call>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": false
|
| 132 |
+
},
|
| 133 |
+
"248060": {
|
| 134 |
+
"content": "<|fim_prefix|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": false
|
| 140 |
+
},
|
| 141 |
+
"248061": {
|
| 142 |
+
"content": "<|fim_middle|>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"248062": {
|
| 150 |
+
"content": "<|fim_suffix|>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"248063": {
|
| 158 |
+
"content": "<|fim_pad|>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"248064": {
|
| 166 |
+
"content": "<|repo_name|>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"248065": {
|
| 174 |
+
"content": "<|file_sep|>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
},
|
| 181 |
+
"248066": {
|
| 182 |
+
"content": "<tool_response>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": false
|
| 188 |
+
},
|
| 189 |
+
"248067": {
|
| 190 |
+
"content": "</tool_response>",
|
| 191 |
+
"lstrip": false,
|
| 192 |
+
"normalized": false,
|
| 193 |
+
"rstrip": false,
|
| 194 |
+
"single_word": false,
|
| 195 |
+
"special": false
|
| 196 |
+
},
|
| 197 |
+
"248068": {
|
| 198 |
+
"content": "<think>",
|
| 199 |
+
"lstrip": false,
|
| 200 |
+
"normalized": false,
|
| 201 |
+
"rstrip": false,
|
| 202 |
+
"single_word": false,
|
| 203 |
+
"special": false
|
| 204 |
+
},
|
| 205 |
+
"248069": {
|
| 206 |
+
"content": "</think>",
|
| 207 |
+
"lstrip": false,
|
| 208 |
+
"normalized": false,
|
| 209 |
+
"rstrip": false,
|
| 210 |
+
"single_word": false,
|
| 211 |
+
"special": false
|
| 212 |
+
},
|
| 213 |
+
"248070": {
|
| 214 |
+
"content": "<|audio_start|>",
|
| 215 |
+
"lstrip": false,
|
| 216 |
+
"normalized": false,
|
| 217 |
+
"rstrip": false,
|
| 218 |
+
"single_word": false,
|
| 219 |
+
"special": true
|
| 220 |
+
},
|
| 221 |
+
"248071": {
|
| 222 |
+
"content": "<|audio_end|>",
|
| 223 |
+
"lstrip": false,
|
| 224 |
+
"normalized": false,
|
| 225 |
+
"rstrip": false,
|
| 226 |
+
"single_word": false,
|
| 227 |
+
"special": true
|
| 228 |
+
},
|
| 229 |
+
"248072": {
|
| 230 |
+
"content": "<tts_pad>",
|
| 231 |
+
"lstrip": false,
|
| 232 |
+
"normalized": false,
|
| 233 |
+
"rstrip": false,
|
| 234 |
+
"single_word": false,
|
| 235 |
+
"special": true
|
| 236 |
+
},
|
| 237 |
+
"248073": {
|
| 238 |
+
"content": "<tts_text_bos>",
|
| 239 |
+
"lstrip": false,
|
| 240 |
+
"normalized": false,
|
| 241 |
+
"rstrip": false,
|
| 242 |
+
"single_word": false,
|
| 243 |
+
"special": true
|
| 244 |
+
},
|
| 245 |
+
"248074": {
|
| 246 |
+
"content": "<tts_text_eod>",
|
| 247 |
+
"lstrip": false,
|
| 248 |
+
"normalized": false,
|
| 249 |
+
"rstrip": false,
|
| 250 |
+
"single_word": false,
|
| 251 |
+
"special": true
|
| 252 |
+
},
|
| 253 |
+
"248075": {
|
| 254 |
+
"content": "<tts_text_bos_single>",
|
| 255 |
+
"lstrip": false,
|
| 256 |
+
"normalized": false,
|
| 257 |
+
"rstrip": false,
|
| 258 |
+
"single_word": false,
|
| 259 |
+
"special": true
|
| 260 |
+
},
|
| 261 |
+
"248076": {
|
| 262 |
+
"content": "<|audio_pad|>",
|
| 263 |
+
"lstrip": false,
|
| 264 |
+
"normalized": false,
|
| 265 |
+
"rstrip": false,
|
| 266 |
+
"single_word": false,
|
| 267 |
+
"special": true
|
| 268 |
+
}
|
| 269 |
+
},
|
| 270 |
+
"additional_special_tokens": [
|
| 271 |
+
"<|im_start|>",
|
| 272 |
+
"<|im_end|>"
|
| 273 |
+
],
|
| 274 |
+
"bos_token": null,
|
| 275 |
+
"chat_template": "{%- set template_version = \"qwen3.5-3.6-kat-qwopus-agentworld-ornith-merged-v3-agentic\" %}\n{#- =========================================================================================\n QWEN HYBRID AGENTIC CHAT TEMPLATE (KAT-Coder + Qwopus + AgentWorld + Ornith)\n Supported tool formats:\n - 'qwen3_coder' (default): Official XML syntax (<function=...><parameter=...>)\n - 'json': Official Qwen / Qwopus JSON syntax (<tool_call>{\"name\":...,\"arguments\":...}</tool_call>)\n Agentic Features:\n - Runtime protocol collision suppression (_suppress_tools / [TOOL_REQUEST])\n - 3-tier consecutive failure warning escalation (anti-loop circuit breaker)\n - MCP / ToolCall argument normalization (.arguments, .parameters, .input)\n - Non-destructive JSON response truncation protection\n - Dynamic thinking pruning on multi-turn trajectories\n ========================================================================================= -#}\n\n{%- set _tool_format = tool_call_format if tool_call_format is defined else 'qwen3_coder' %}\n{%- set enable_thinking = (enable_thinking not in (false, 'false', 'False', 0, '0', 'off', 'none')) if enable_thinking is defined else true %}\n{%- set auto_disable_thinking_with_tools = (auto_disable_thinking_with_tools in (true, 'true', 'True', 1, '1', 'on')) if auto_disable_thinking_with_tools is defined else false %}\n\n{%- if preserve_reasoning is defined and preserve_reasoning is not none %}\n {%- set _preserve_thinking = (preserve_reasoning not in (false, 'false', 'False', 0, '0', 'off', 'none')) %}\n{%- elif preserve_thinking is defined and preserve_thinking is not none %}\n {%- set _preserve_thinking = (preserve_thinking not in (false, 'false', 'False', 0, '0', 'off', 'none')) %}\n{%- else %}\n {%- set _preserve_thinking = true %}\n{%- endif %}\n\n{%- set max_tool_arg_chars = (max_tool_arg_chars | int) if (max_tool_arg_chars is defined and max_tool_arg_chars is not none) else 0 %}\n{%- set max_tool_response_chars = (max_tool_response_chars | int) if (max_tool_response_chars is defined and max_tool_response_chars is not none) else 0 %}\n{%- set _has_tools = (tools is defined and tools and tools is iterable and tools is not mapping) %}\n\n{# --- Dynamic Reasoning Effort Mapping --- #}\n{%- set _effort_raw = (reasoning_effort | string | lower) if reasoning_effort is defined and reasoning_effort is not none else 'medium' %}\n{%- set _initial_thinking = enable_thinking %}\n{%- set _initial_effort = 'medium' %}\n{%- if _effort_raw in ('none', 'off') %}\n {%- set _initial_thinking = false %}\n {%- set _initial_effort = 'medium' %}\n{%- elif _effort_raw in ('minimal', 'low') %}\n {%- set _initial_effort = 'low' %}\n{%- elif _effort_raw in ('high', 'xhigh', 'max', 'ultracode', 'extreme', 'deep', 'long') %}\n {%- set _initial_thinking = true %}\n {%- set _initial_effort = 'xhigh' %}\n{%- else %}\n {%- set _initial_effort = 'medium' %}\n{%- endif %}\n\n{%- set ns_state = namespace(thinking=_initial_thinking, effort=_initial_effort) %}\n{%- if auto_disable_thinking_with_tools and _has_tools %}\n {%- set ns_state.thinking = false %}\n{%- endif %}\n\n{# --- In-Prompt Thinking Directive Scanning --- #}\n{%- for msg in messages %}\n {%- if msg.role == 'system' or msg.role == 'developer' or msg.role == 'user' %}\n {%- if msg.content is string %}\n {%- if '<|think_off|>' in msg.content %}\n {%- set ns_state.thinking = false %}\n {%- elif '<|think_on|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- elif '<|think_xhigh|>' in msg.content or '<|think_high|>' in msg.content or '<|think_ultracode|>' in msg.content or '<|think_extreme|>' in msg.content or '<|think_max|>' in msg.content or '<|think_deep|>' in msg.content or '<|think_long|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'xhigh' %}\n {%- elif '<|think_low|>' in msg.content or '<|think_minimal|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'low' %}\n {%- elif '<|think_medium|>' in msg.content %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'medium' %}\n {%- endif %}\n {%- elif msg.content is iterable and msg.content is not mapping %}\n {%- for item in msg.content %}\n {%- if item is string %}\n {%- set _item_text = item %}\n {%- elif item is mapping and 'text' in item and item.text is string %}\n {%- set _item_text = item.text %}\n {%- elif item is mapping and 'content' in item and item.content is string %}\n {%- set _item_text = item.content %}\n {%- else %}\n {%- set _item_text = '' %}\n {%- endif %}\n {%- if _item_text %}\n {%- if '<|think_off|>' in _item_text %}\n {%- set ns_state.thinking = false %}\n {%- elif '<|think_on|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- elif '<|think_xhigh|>' in _item_text or '<|think_high|>' in _item_text or '<|think_ultracode|>' in _item_text or '<|think_extreme|>' in _item_text or '<|think_max|>' in _item_text or '<|think_deep|>' in _item_text or '<|think_long|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'xhigh' %}\n {%- elif '<|think_low|>' in _item_text or '<|think_minimal|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'low' %}\n {%- elif '<|think_medium|>' in _item_text %}\n {%- set ns_state.thinking = true %}\n {%- set ns_state.effort = 'medium' %}\n {%- endif %}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n\n{%- set reasoning_instructions = '' %}\n{%- if ns_state.thinking %}\n {%- if ns_state.effort == 'xhigh' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think rigorously through the task, explore alternative hypotheses, validate edge cases, and prioritize architectural soundness, consistency, and correctness in the final answer.' %}\n {%- elif ns_state.effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking concise, focused, and move directly to execution or tool calls without unnecessary elaboration.' %}\n {%- endif %}\n{%- endif %}\n\n{# --- Content Render Macro (Enforces Pure-Text CausalLM) --- #}\n{%- macro render_content(content, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if item is mapping %}\n {%- if item.type == 'image' or 'image' in item or 'image_url' in item %}\n {{- raise_exception('This model is a pure text CausalLM (vision tower removed). Image inputs are not supported.') }}\n {%- elif item.type == 'video' or 'video' in item %}\n {{- raise_exception('This model is a pure text CausalLM (vision tower removed). Video inputs are not supported.') }}\n {%- elif 'text' in item %}\n {{- (item.text | string) if item.text is not none else '' }}\n {%- elif 'content' in item and item.content is string %}\n {{- item.content }}\n {%- else %}\n {{- item | tojson }}\n {%- endif %}\n {%- else %}\n {{- item | string }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n\n{# --- Head Extraction (System/Developer Messages) --- #}\n{%- set head = namespace(count=0, seen_non_system=false) %}\n{%- for message in messages %}\n {%- set _is_sys = (message.role == 'system' or message.role == 'developer') %}\n {%- if _is_sys and not head.seen_non_system %}\n {%- set head.count = head.count + 1 %}\n {%- else %}\n {%- set head.seen_non_system = true %}\n {%- endif %}\n{%- endfor %}\n\n{%- set sys_state = namespace(content='') %}\n{%- for message in messages[:head.count] %}\n {%- set _part = render_content(message.content, true) | trim %}\n {%- if '<|think_off|>' in _part %}{%- set _part = _part.split('<|think_off|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_on|>' in _part %}{%- set _part = _part.split('<|think_on|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_xhigh|>' in _part %}{%- set _part = _part.split('<|think_xhigh|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_high|>' in _part %}{%- set _part = _part.split('<|think_high|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_ultracode|>' in _part %}{%- set _part = _part.split('<|think_ultracode|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_extreme|>' in _part %}{%- set _part = _part.split('<|think_extreme|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_max|>' in _part %}{%- set _part = _part.split('<|think_max|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_deep|>' in _part %}{%- set _part = _part.split('<|think_deep|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_long|>' in _part %}{%- set _part = _part.split('<|think_long|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_medium|>' in _part %}{%- set _part = _part.split('<|think_medium|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_low|>' in _part %}{%- set _part = _part.split('<|think_low|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_minimal|>' in _part %}{%- set _part = _part.split('<|think_minimal|>') | join('') | trim %}{%- endif %}\n {%- if _part %}\n {%- if sys_state.content %}\n {%- set sys_state.content = sys_state.content ~ '\\n\\n' ~ _part %}\n {%- else %}\n {%- set sys_state.content = _part %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n\n{%- set _sc = sys_state.content %}\n{%- set _msgs = messages[head.count:] %}\n\n{# --- Optional Terse Directive --- #}\n{%- set _terse_on = (terse in (true, 'true', 'True', 1, '1', 'on')) if terse is defined else false %}\n{%- if _terse_on %}\n {%- if ns_state.thinking %}\n {%- set _terse_lead = 'Answer directly, after thinking. Lead with the answer, then only what it needs to be correct and usable.' %}\n {%- else %}\n {%- set _terse_lead = 'Answer directly and concisely. Give the answer with only what it needs to be correct and usable.' %}\n {%- endif %}\n {%- set _terse_core %}\nNever: open with preamble or pleasantries; restate the question; add filler transitions; hedge with niceties; or repeat a point you have already made.\nAlways: keep essential steps, caveats, uncertainties, and specifics \u2014 never drop correctness or a needed warning for brevity. Keep the final answer lean. Use the least structure that conveys it (plain prose when short; lists or code only when they earn their place). If genuinely uncertain, say so and explain why \u2014 never omit uncertainty for the sake of brevity.\nIf a user request is genuinely ambiguous, ask a sharp question, do not guess.\n {%- endset %}\n {%- set _terse = _terse_lead ~ '\\n' ~ (_terse_core | trim) %}\n {%- if not _sc %}\n {%- set _sc = _terse | trim %}\n {%- else %}\n {%- set _sc = (_sc | trim) ~ '\\n\\n' ~ (_terse | trim) %}\n {%- endif %}\n{%- endif %}\n\n{# --- Frontend Runtime Protocol Collision Detection (Borrowed from Donor 1) --- #}\n{%- set _runtime_tool_protocol = (_sc is defined and _sc and ('[TOOL_REQUEST]' in _sc or '[AVAILABLE_TOOLS]' in _sc or '<tool_protocol>' in _sc)) %}\n{%- set _suppress_tools = (suppress_tool_instructions in (true, 'true', 'True', 1, '1', 'on')) if suppress_tool_instructions is defined else _runtime_tool_protocol %}\n\n{# --- Tool System Prompt Injection --- #}\n{%- if _has_tools and not _suppress_tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if reasoning_instructions %}\n {{- reasoning_instructions + '\\n\\n' }}\n {%- endif %}\n {{- '# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>' }}\n {%- for tool in tools %}\n {{- '\\n' }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- '\\n</tools>' }}\n {%- if _tool_format == 'json' %}\n {#- Canonical Qwen / Qwopus JSON invocation format (Borrowed from Donor 2) -#}\n {{- '\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n' }}\n {%- if ns_state.thinking %}\n {{- '<think>\\nBrief explanation of next step or parameter rationale\\n</think>\\n' }}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": \"example_function_name\", \"arguments\": {\"example_parameter_1\": \"value_1\", \"example_parameter_2\": \"value_2\"}}\\n</tool_call>\\n\\n<IMPORTANT>\\n' }}\n {%- if ns_state.thinking %}\n {{- '- All planning, hypothesis testing, and error reflection MUST be placed strictly inside the <think></think> block.\\n' }}\n {{- '- Output the <tool_call> block IMMEDIATELY after thinking with NO conversational text before it.\\n' }}\n {%- else %}\n {{- '- Output the <tool_call> block IMMEDIATELY with NO conversational text before it.\\n' }}\n {%- endif %}\n {{- '- The <tool_call> tag MUST be at the very beginning of a new line, with NO indentation.\\n' }}\n {{- '- For multiple calls in parallel, output a separate <tool_call></tool_call> block for EACH function. Do NOT nest calls.\\n' }}\n {{- '- Keep tool calls purposeful: issue only the calls required for the immediate next step.\\n' }}\n {{- '- Once all necessary data is gathered, provide your final answer directly without calling further tools.\\n</IMPORTANT>' }}\n {%- else %}\n {#- Official Qwen3-Coder XML syntax (<function=...><parameter=...>) -#}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n' }}\n {%- if ns_state.thinking %}\n {{- '<think>\\nBrief explanation of next step or parameter rationale\\n</think>\\n' }}\n {%- endif %}\n {{- '<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nvalue_2\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\n' }}\n {%- if ns_state.thinking %}\n {{- '- All planning, hypothesis testing, and error reflection MUST be placed strictly inside the <think></think> block.\\n' }}\n {{- '- Output the <tool_call> block IMMEDIATELY after thinking with NO conversational text before it.\\n' }}\n {%- else %}\n {{- '- Output the <tool_call> block IMMEDIATELY with NO conversational text before it.\\n' }}\n {%- endif %}\n {{- '- Function calls MUST follow the specified format: an inner <function=...></function> block nested within <tool_call></tool_call> tags.\\n' }}\n {{- '- The <tool_call> and <function> tags MUST be at the very beginning of a new line, with NO spaces or indentation before them.\\n' }}\n {{- '- For multiple calls, output a separate, completely closed <tool_call></tool_call> block for EACH function. Do NOT nest blocks.\\n' }}\n {{- '- Keep tool calls purposeful: issue only the calls required for the immediate next step.\\n' }}\n {{- '- Once all necessary data is gathered, provide your final answer directly without calling further tools.\\n</IMPORTANT>' }}\n {%- endif %}\n {%- if _sc %}\n {{- '\\n\\n' + _sc }}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if _sc %}\n {{- '<|im_start|>system\\n' + (reasoning_instructions + '\\n\\n' if reasoning_instructions else '') + _sc + '<|im_end|>\\n' }}\n {%- elif reasoning_instructions %}\n {{- '<|im_start|>system\\n' + reasoning_instructions + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n\n{# --- Multi-Turn Trajectory Analysis (Scanning for Root User Query) --- #}\n{%- set ns = namespace(found_query=false, last_query_index=0) %}\n{%- for message in _msgs[::-1] %}\n {%- set index = (_msgs | length - 1) - loop.index0 %}\n {%- if not ns.found_query and message.role == 'user' %}\n {%- set _rc = render_content(message.content) | trim %}\n {%- if not (_rc.startswith('<tool_response>') and _rc.endswith('</tool_response>')) %}\n {%- set ns.found_query = true %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n\n{# Fallback when entire context consists of autonomous tool loops (Borrowed from Donor 1) #}\n{%- if not ns.found_query and _msgs | length > 0 %}\n {%- set ns.last_query_index = (_msgs | length - 1) %}\n{%- endif %}\n\n{# --- Conversation Render Loop --- #}\n{%- set ns2 = namespace(prev_role='', consecutive_failures=0) %}\n{%- for message in _msgs %}\n {%- set is_system = (message.role == \"system\" or message.role == \"developer\") %}\n {%- set content = render_content(message.content, is_system) | trim %}\n {%- if is_system or message.role == 'user' %}\n {%- if '<|think_off|>' in content %}{%- set content = content.split('<|think_off|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_on|>' in content %}{%- set content = content.split('<|think_on|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_xhigh|>' in content %}{%- set content = content.split('<|think_xhigh|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_high|>' in content %}{%- set content = content.split('<|think_high|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_ultracode|>' in content %}{%- set content = content.split('<|think_ultracode|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_extreme|>' in content %}{%- set content = content.split('<|think_extreme|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_max|>' in content %}{%- set content = content.split('<|think_max|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_deep|>' in content %}{%- set content = content.split('<|think_deep|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_long|>' in content %}{%- set content = content.split('<|think_long|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_medium|>' in content %}{%- set content = content.split('<|think_medium|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_low|>' in content %}{%- set content = content.split('<|think_low|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_minimal|>' in content %}{%- set content = content.split('<|think_minimal|>') | join('') | trim %}{%- endif %}\n {%- endif %}\n {%- if is_system %}\n {{- '<|im_start|>system\\n' + content + '<|im_end|>\\n' }}\n {%- elif message.role == 'user' %}\n {%- set ns2.consecutive_failures = 0 %}\n {{- '<|im_start|>user\\n' + content + '<|im_end|>\\n' }}\n {%- elif message.role == 'assistant' %}\n {%- set reasoning_content = '' %}\n {%- set _explicit_reasoning = '' %}\n {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n {%- if message.reasoning_content is string %}\n {%- set _explicit_reasoning = message.reasoning_content %}\n {%- elif message.reasoning_content is mapping and 'text' in message.reasoning_content %}\n {%- set _explicit_reasoning = message.reasoning_content.text | string %}\n {%- else %}\n {%- set _explicit_reasoning = message.reasoning_content | string %}\n {%- endif %}\n {%- elif message.thinking is defined and message.thinking is not none %}\n {%- if message.thinking is string %}\n {%- set _explicit_reasoning = message.thinking %}\n {%- elif message.thinking is mapping and 'text' in message.thinking %}\n {%- set _explicit_reasoning = message.thinking.text | string %}\n {%- else %}\n {%- set _explicit_reasoning = message.thinking | string %}\n {%- endif %}\n {%- elif message.reasoning is defined and message.reasoning is not none %}\n {%- if message.reasoning is string %}\n {%- set _explicit_reasoning = message.reasoning %}\n {%- elif message.reasoning is mapping and 'text' in message.reasoning %}\n {%- set _explicit_reasoning = message.reasoning.text | string %}\n {%- else %}\n {%- set _explicit_reasoning = message.reasoning | string %}\n {%- endif %}\n {%- endif %}\n {%- if _explicit_reasoning %}\n {%- set _lead_end = '' %}\n {%- if '</think>' in content %}\n {%- set _lead_end = '</think>' %}\n {%- elif '</thinking>' in content %}\n {%- set _lead_end = '</thinking>' %}\n {%- endif %}\n {%- if _lead_end %}\n {%- set _parts = content.split(_lead_end) %}\n {%- set content = (_parts[1:] | join(_lead_end)).lstrip('\\n') %}\n {%- endif %}\n {%- set reasoning_content = _explicit_reasoning %}\n {%- else %}\n {%- set _think_end = '' %}\n {%- if '</think>' in content %}\n {%- set _think_end = '</think>' %}\n {%- elif '</thinking>' in content %}\n {%- set _think_end = '</thinking>' %}\n {%- endif %}\n {%- if _think_end %}\n {%- set _think_start = '<thinking>' if 'thinking' in _think_end else '<think>' %}\n {%- set _parts = content.split(_think_end) %}\n {%- set reasoning_content = _parts[0].rstrip('\\n') %}\n {%- if _think_start in reasoning_content %}\n {%- set reasoning_content = reasoning_content.split(_think_start)[-1].lstrip('\\n') %}\n {%- endif %}\n {%- set content = (_parts[1:] | join(_think_end)).lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content | trim %}\n\n {# Emit Assistant Thought and Content #}\n {%- if reasoning_content and (_preserve_thinking or loop.index0 >= ns.last_query_index) %}\n {{- '<|im_start|>assistant\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>assistant\\n' + content }}\n {%- endif %}\n\n {# Emit Tool Calls (Guarded against double emission if <tool_call> is already in content) #}\n {%- if message.tool_calls is defined and message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping and '<tool_call>' not in content %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined and tool_call.function is not none %}\n {%- set tc = tool_call.function %}\n {%- else %}\n {%- set tc = tool_call %}\n {%- endif %}\n {%- set tc_name = tc.name if (tc.name is defined and tc.name is not none) else '' %}\n\n {# Resolve Arguments across OpenAI, Anthropic/Claude, and MCP schemas (.arguments, .parameters, .input) #}\n {%- set tc_args_raw = none %}\n {%- if tc.arguments is defined and tc.arguments is not none %}\n {%- set tc_args_raw = tc.arguments %}\n {%- elif tc.parameters is defined and tc.parameters is not none %}\n {%- set tc_args_raw = tc.parameters %}\n {%- elif tc.input is defined and tc.input is not none %}\n {%- set tc_args_raw = tc.input %}\n {%- endif %}\n\n {%- if _tool_format == 'json' %}\n {%- if loop.first %}\n {%- if content | trim %}\n {{- '\\n\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n' }}\n {%- endif %}\n {%- set _args = '{}' %}\n {%- if tc_args_raw is not none %}\n {%- if tc_args_raw is mapping %}\n {%- set _args = tc_args_raw | tojson %}\n {%- elif tc_args_raw is string %}\n {%- set _trimmed_args = tc_args_raw | trim %}\n {%- if _trimmed_args | length > 0 %}\n {%- if _trimmed_args | first == '{' and _trimmed_args | last == '}' %}\n {%- set _args = _trimmed_args %}\n {%- else %}\n {%- set _args = tc_args_raw | tojson %}\n {%- endif %}\n {%- endif %}\n {%- else %}\n {%- set _args = tc_args_raw | tojson %}\n {%- endif %}\n {%- endif %}\n {{- '<tool_call>\\n{\"name\": ' }}{{- tc_name | tojson }}{{- ', \"arguments\": ' }}{{- _args }}{{- '}\\n</tool_call>' }}\n {%- else %}\n {%- if loop.first %}\n {%- if content | trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tc_name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tc_name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tc_name + '>\\n' }}\n {%- endif %}\n {%- if tc_args_raw is not none %}\n {%- if tc_args_raw is mapping %}\n {%- for args_name, args_value in tc_args_raw.items() %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- if args_value is string %}\n {%- set _av = args_value %}\n {%- else %}\n {%- set _av = args_value | tojson %}\n {%- endif %}\n {%- if max_tool_arg_chars > 0 and _av | length > max_tool_arg_chars %}\n {{- _av[:max_tool_arg_chars] + '\\n[TRUNCATED - original length ' ~ (_av | length | string) ~ ' chars]' }}\n {%- else %}\n {{- _av }}\n {%- endif %}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- else %}\n {%- if tc_args_raw is string %}\n {%- set _raw_args = tc_args_raw %}\n {%- else %}\n {%- set _raw_args = tc_args_raw | tojson %}\n {%- endif %}\n {%- if _raw_args %}\n {%- if max_tool_arg_chars > 0 and _raw_args | length > max_tool_arg_chars %}\n {{- _raw_args[:max_tool_arg_chars] + '\\n[TRUNCATED - original length ' ~ (_raw_args | length | string) ~ ' chars]' }}\n {%- else %}\n {{- _raw_args }}\n {%- endif %}\n {%- endif %}\n {%- endif %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == 'tool' %}\n {# --- Multi-Turn Tool Response & Escalating Circuit Breaker --- #}\n {%- set _content_lower = content | lower %}\n {%- set _content_head = _content_lower[:150] %}\n {%- set _is_code_or_grep = ('throw new ' in _content_lower or 'throw error' in _content_lower or 'console.error' in _content_lower or 'logger.error' in _content_lower or 'logging.error' in _content_lower or 'import ' in _content_head or 'def ' in _content_head or 'function ' in _content_head) %}\n {%- set _exit_code_zero = ('exit code: 0' in _content_head or 'process exited with code 0' in _content_head) %}\n {%- set _error_field_ok = ('\"error\": null' in _content_head or '\"error\":null' in _content_head or '\"error\": false' in _content_head or '\"error\":false' in _content_head or '\"error\": \"\"' in _content_head or '\"error\":\"\"' in _content_head) %}\n {%- set _strong_error = (('\"error\":' in _content_head and not _error_field_ok) or '\"status\": \"error\"' in _content_head or '\"status\":\"error\"' in _content_head or '\"success\": false' in _content_head or '\"success\":false' in _content_head or 'traceback (most recent call last):' in _content_head or 'command not found' in _content_head or 'invalid syntax' in _content_head or 'fatal:' in _content_head or 'permission denied' in _content_head or 'no such file or directory' in _content_head or '404 not found' in _content_head or 'rate limit' in _content_head or 'connection refused' in _content_head or 'timed out' in _content_head or (('exit code: ' in _content_head or 'process exited with code' in _content_head) and not _exit_code_zero) or _content_head.startswith('exception:') or _content_head.startswith('failed to ')) %}\n {%- set _weak_error = ('error:' in _content_head or 'err!' in _content_head) %}\n {%- set _weak_suppressed = ('$ ' in _content_head or 'took ' in _content_head or content | length >= 600) %}\n\n {%- if not _is_code_or_grep and (_strong_error or (_weak_error and not _weak_suppressed)) %}\n {%- set ns2.consecutive_failures = ns2.consecutive_failures + 1 %}\n {%- else %}\n {%- set ns2.consecutive_failures = 0 %}\n {%- endif %}\n\n {%- if ns2.prev_role != 'tool' %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n\n {# Truncate non-JSON outputs safely, alert if JSON was clipped (Borrowed from Donor 1) #}\n {%- set _is_json_payload = (content | trim | length > 0 and (content | trim)[:1] in ('{', '[')) %}\n {%- if max_tool_response_chars > 0 and content | length > max_tool_response_chars %}\n {%- if _is_json_payload %}\n {%- set content = content[:max_tool_response_chars] + '\\n[TRUNCATED: Output exceeded ' ~ max_tool_response_chars ~ ' chars. Remaining JSON payload clipped]' %}\n {%- else %}\n {%- set content = content[:max_tool_response_chars] + '\\n[TRUNCATED - original length ' ~ (content | length | string) ~ ' chars]' %}\n {%- endif %}\n {%- endif %}\n\n {{- '\\n<tool_response>\\n' + content }}\n\n {# 3-Tier Failure Escalation (Anti-Loop Circuit Breaker) #}\n {%- if ns2.consecutive_failures >= 3 %}\n {{- '\\n\\n\u26a0\ufe0f SYSTEM WARNING: ' ~ ns2.consecutive_failures ~ ' consecutive tool errors detected. CRITICAL AGENTIC LOOP. Do NOT repeat the failed command or variations of it. If a dependency, tool, or path is missing, immediately PIVOT to an alternative diagnostic tool or report the blocker directly.' }}\n {%- elif ns2.consecutive_failures == 2 %}\n {{- '\\n\\n\u26a0\ufe0f SYSTEM WARNING: 2 consecutive tool errors detected. Your previous technical approach is fundamentally incorrect. You MUST diagnose root cause and use a completely different approach or command.' }}\n {%- elif ns2.consecutive_failures == 1 %}\n {{- '\\n\\n\u26a0\ufe0f SYSTEM WARNING: The previous tool call returned an error. Diagnose the failure and retry with corrected arguments.' }}\n {%- endif %}\n\n {{- '\\n</tool_response>' }}\n\n {%- if loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- else %}\n {%- set _next_role = _msgs[loop.index0 + 1].role %}\n {%- if _next_role != 'tool' %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n {%- else %}\n {{- '<|im_start|>user\\n[' + message.role + ']: ' + content + '<|im_end|>\\n' }}\n {%- endif %}\n {%- set ns2.prev_role = message.role %}\n{%- endfor %}\n\n{# --- Generation Prompt --- #}\n{%- set _add_gen = (add_generation_prompt in (true, 'true', 'True', 1, '1', 'on')) if add_generation_prompt is defined else false %}\n{%- if _add_gen %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if not ns_state.thinking %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- else %}\n {{- '<think>\\n' }}\n {%- endif %}\n{%- endif %}",
|
| 276 |
+
"clean_up_tokenization_spaces": false,
|
| 277 |
+
"eos_token": "<|im_end|>",
|
| 278 |
+
"errors": "replace",
|
| 279 |
+
"model_max_length": 262144,
|
| 280 |
+
"padding_side": "left",
|
| 281 |
+
"pad_token": "<|endoftext|>",
|
| 282 |
+
"pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
|
| 283 |
+
"split_special_tokens": false,
|
| 284 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 285 |
+
"unk_token": null
|
| 286 |
+
}
|