{ "add_prefix_space": false, "audio_bos_token": "<|audio_start|>", "audio_eos_token": "<|audio_end|>", "audio_token": "<|audio_pad|>", "backend": "tokenizers", "bos_token": null, "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "image_token": "<|image_pad|>", "is_local": true, "local_files_only": false, "model_max_length": 262144, "model_specific_special_tokens": { "audio_bos_token": "<|audio_start|>", "audio_eos_token": "<|audio_end|>", "audio_token": "<|audio_pad|>", "image_token": "<|image_pad|>", "video_token": "<|video_pad|>", "vision_bos_token": "<|vision_start|>", "vision_eos_token": "<|vision_end|>" }, "pad_token": "<|endoftext|>", "padding_side": "left", "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+", "processor_class": "Qwen3VLProcessor", "split_special_tokens": false, "tokenizer_class": "TokenizersBackend", "unk_token": null, "video_token": "<|video_pad|>", "vision_bos_token": "<|vision_start|>", "vision_eos_token": "<|vision_end|>", "added_tokens_decoder": { "248044": { "content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248045": { "content": "<|im_start|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248046": { "content": "<|im_end|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248047": { "content": "<|object_ref_start|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248048": { "content": "<|object_ref_end|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248049": { "content": "<|box_start|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248050": { "content": "<|box_end|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248051": { "content": "<|quad_start|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248052": { "content": "<|quad_end|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248053": { "content": "<|vision_start|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248054": { "content": "<|vision_end|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248055": { "content": "<|vision_pad|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248056": { "content": "<|image_pad|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248057": { "content": "<|video_pad|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248058": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248059": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248060": { "content": "<|fim_prefix|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248061": { "content": "<|fim_middle|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248062": { "content": "<|fim_suffix|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248063": { "content": "<|fim_pad|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248064": { "content": "<|repo_name|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248065": { "content": "<|file_sep|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248066": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248067": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248068": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248069": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": false }, "248070": { "content": "<|audio_start|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248071": { "content": "<|audio_end|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248072": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248073": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248074": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248075": { "content": "", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true }, "248076": { "content": "<|audio_pad|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": false, "special": true } }, "chat_template": "{%- set template_version = \"qwen3.8-froggeric-v22.1\" %}\n{%- set _tool_format = tool_call_format if tool_call_format is defined else 'xml' %}\n{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- set add_vision_id = add_vision_id if add_vision_id is defined else false %}\n{%- set enable_thinking = enable_thinking if enable_thinking is defined else true %}\n{%- set auto_disable_thinking_with_tools = auto_disable_thinking_with_tools if auto_disable_thinking_with_tools is defined else false %}\n{%- if preserve_reasoning is defined and preserve_reasoning is not none %}\n {%- set _preserve_thinking = preserve_reasoning %}\n{%- elif preserve_thinking is defined and preserve_thinking is not none %}\n {%- set _preserve_thinking = preserve_thinking %}\n{%- else %}\n {%- set _preserve_thinking = true %}\n{%- endif %}\n{%- set max_tool_arg_chars = max_tool_arg_chars if max_tool_arg_chars is defined else 0 %}\n{%- set max_tool_response_chars = max_tool_response_chars if max_tool_response_chars is defined else 0 %}\n{%- set _has_tools = (tools is defined and tools and tools is iterable and tools is not 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 == 'none' %}\n {%- set _initial_thinking = false %}\n {%- set _initial_effort = 'medium' %}\n{%- elif _effort_raw == 'minimal' or _effort_raw == 'low' %}\n {%- set _initial_effort = 'low' %}\n{%- elif _effort_raw == 'high' or _effort_raw == 'xhigh' or _effort_raw == 'max' %}\n {%- set _initial_effort = 'xhigh' %}\n{%- else %}\n {%- set _initial_effort = 'medium' %}\n{%- endif %}\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{%- 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 %}\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 {%- 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 %}\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{%- 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 carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}\n {%- elif ns_state.effort == 'low' %}\n {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}\n {%- endif %}\n{%- endif %}\n{%- macro render_content(content, do_vision_count, 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 {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif item.type == 'video' or 'video' in item %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\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{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- set _first_role = messages[0].role %}\n{%- if _first_role == 'system' or _first_role == 'developer' %}\n {%- set _sys_msg = messages[0] %}\n {%- set _msgs = messages[1:] %}\n{%- else %}\n {%- set _sys_msg = none %}\n {%- set _msgs = messages %}\n{%- endif %}\n{%- set _sc = '' %}\n{%- if _sys_msg is not none %}\n {%- set _sc = render_content(_sys_msg.content, false, true) | trim %}\n {%- if '<|think_off|>' in _sc %}{%- set _sc = _sc.split('<|think_off|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_on|>' in _sc %}{%- set _sc = _sc.split('<|think_on|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_xhigh|>' in _sc %}{%- set _sc = _sc.split('<|think_xhigh|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_high|>' in _sc %}{%- set _sc = _sc.split('<|think_high|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_medium|>' in _sc %}{%- set _sc = _sc.split('<|think_medium|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_low|>' in _sc %}{%- set _sc = _sc.split('<|think_low|>') | join('') | trim %}{%- endif %}\n {%- if '<|think_minimal|>' in _sc %}{%- set _sc = _sc.split('<|think_minimal|>') | join('') | trim %}{%- endif %}\n{%- endif %}\n{%- if _has_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' }}\n {%- for tool in tools %}\n {{- '\\n' }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- '\\n' }}\n {%- if _tool_format == 'json' %}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n\\nBrief explanation of tool call\\n\\n\\n{\"name\": \"example_function_name\", \"arguments\": {\"example_parameter_1\": \"value_1\", \"example_parameter_2\": \"This is the value for the second parameter\"}}\\n\\n\\n\\nReminder:\\n- You can use the block to plan your next tool call OR to synthesize data and formulate your final response to the user.\\n- ALL explanation and reasoning MUST be placed strictly inside the block.\\n- Function calls MUST follow the specified format: a single JSON object with \"name\" and \"arguments\" keys inside XML tags.\\n- If you choose to call a tool, you MUST output the block IMMEDIATELY after thinking, with NO conversational text before it.\\n- The tag MUST be at the very beginning of a new line, with NO spaces or indentation before it.\\n- To call multiple functions, output a separate, completely closed block for EACH function. Do NOT nest blocks.\\n- If you have all necessary data, provide your final answer directly to the user without any tool call.\\n' }}\n {%- else %}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n\\nBrief explanation of tool call\\n\\n\\n\\n\\nvalue_1\\n\\n\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n\\n\\n\\n\\n\\nReminder:\\n- You can use the block to plan your next tool call OR to synthesize data and formulate your final response to the user.\\n- ALL explanation and reasoning MUST be placed strictly inside the block.\\n- Function calls MUST follow the specified format: an inner block must be nested within XML tags.\\n- If you choose to call a tool, you MUST output the block IMMEDIATELY after thinking, with NO conversational text before it.\\n- The and tags MUST be at the very beginning of a new line, with NO spaces or indentation before them.\\n- To call multiple functions, output a separate, completely closed block for EACH function. Do NOT nest blocks.\\n- If you have all necessary data, provide your final answer directly to the user without any tool call.\\n' }}\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{%- set _last_idx = _msgs | length - 1 %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=_last_idx) %}\n{%- for message in _msgs[::-1] %}\n {%- set index = (_msgs | length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == 'user' %}\n {%- set _rc = render_content(message.content, false) | trim %}\n {%- if not (_rc.startswith('') and _rc.endswith('')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {%- if _last_idx > 50 %}\n {%- set ns.last_query_index = _last_idx %}\n {%- else %}\n {%- set ns.last_query_index = 0 %}\n {%- endif %}\n{%- endif %}\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, true, 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_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 {%- if message.reasoning_content is defined and message.reasoning_content is not none %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- set reasoning_content = 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 reasoning_content = message.thinking %}\n {%- else %}\n {%- set reasoning_content = message.thinking | string %}\n {%- endif %}\n {%- else %}\n {%- set _think_end = '' %}\n {%- if content.startswith('') %}\n {%- set _think_end = '' %}\n {%- elif content.startswith('') %}\n {%- set _think_end = '' %}\n {%- elif '\\n' in content %}\n {%- set _think_end = '\\n' %}\n {%- elif '\\n' in content %}\n {%- set _think_end = '\\n' %}\n {%- elif '\\n' in content %}\n {%- set _think_end = '\\n' %}\n {%- elif '\\n' in content %}\n {%- set _think_end = '\\n' %}\n {%- endif %}\n {%- if _think_end %}\n {%- if 'thinking' in _think_end %}\n {%- set _think_start = '' %}\n {%- else %}\n {%- set _think_start = '' %}\n {%- endif %}\n {%- set reasoning_content = content.split(_think_end)[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 = content.split(_think_end)[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content | trim %}\n {%- if (_preserve_thinking or loop.index0 > ns.last_query_index) and reasoning_content %}\n {{- '<|im_start|>assistant\\n\\n' + reasoning_content + '\\n\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>assistant\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls is defined and message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\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 {%- if _tool_format == 'json' %}\n {%- if not loop.first or content | trim %}\n {{- '\\n\\n' }}\n {%- endif %}\n {%- set _args = '{}' %}\n {%- if tc.arguments is defined and tc.arguments is not none %}\n {%- if tc.arguments is mapping %}\n {%- set _args = tc.arguments | tojson %}\n {%- elif tc.arguments is string and tc.arguments %}\n {%- set _args = tc.arguments %}\n {%- endif %}\n {%- endif %}\n {{- '\\n{\"name\": ' }}{{- tc_name | tojson }}{{- ', \"arguments\": ' }}{{- _args }}{{- '}\\n' }}\n {%- else %}\n {%- if loop.first %}\n {%- if content | trim %}\n {{- '\\n\\n\\n\\n' }}\n {%- else %}\n {{- '\\n\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n\\n\\n\\n' }}\n {%- endif %}\n {%- if tc.arguments is defined and tc.arguments is not none %}\n {%- if tc.arguments is mapping %}\n {%- for args_name, args_value in tc.arguments.items() %}\n {{- '\\n' }}\n {%- if args_value is mapping or (args_value is sequence and args_value is not string) %}\n {%- set _av = args_value | tojson %}\n {%- else %}\n {%- set _av = args_value | string %}\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\\n' }}\n {%- endfor %}\n {%- elif tc.arguments is string and tc.arguments %}\n {{- tc.arguments }}\n {%- endif %}\n {%- endif %}\n {{- '\\n' }}\n {%- endif %}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == 'tool' %}\n {%- set _content_lower = content | lower %}\n {%- set _content_head = _content_lower[:80] %}\n {%- if content | length < 500 and '$ ' not in content and 'took ' not in _content_lower and ('\"error\":' in _content_head or 'error:' in _content_head or 'err!' in _content_head or 'fatal:' in _content_head or 'exception:' in _content_head or 'traceback' in _content_head or 'command not found' in _content_head or 'invalid syntax' in _content_head or 'failed to' in _content_head) %}\n {%- set ns2.consecutive_failures = ns2.consecutive_failures + 1 %}\n {%- else %}\n {%- set ns2.consecutive_failures = 0 %}\n {%- endif %}\n {%- if ns2.prev_role != 'tool' %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {%- if max_tool_response_chars > 0 and content | length > max_tool_response_chars %}\n {%- set content = content[:max_tool_response_chars] + '\\n[TRUNCATED - original length ' ~ (content | length | string) ~ ' chars]' %}\n {%- endif %}\n {{- '\\n\\n' + content }}\n {%- if ns2.consecutive_failures >= 2 %}\n {{- '\\n\\n⚠️ SYSTEM WARNING: ' ~ ns2.consecutive_failures ~ ' consecutive tool errors detected. Your previous approach is incorrect. You MUST use a fundamentally different approach or corrected arguments.' }}\n {%- elif ns2.consecutive_failures == 1 %}\n {{- '\\n\\n⚠️ SYSTEM WARNING: The previous tool call returned an error. Diagnose the failure and retry with completely corrected arguments.' }}\n {%- endif %}\n {{- '\\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{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if not ns_state.thinking %}\n {{- '\\n\\n\\n\\n' }}\n {%- else %}\n {{- '\\n' }}\n {%- endif %}\n{%- endif %}" }