{"serveDecision":{"state":"UNKNOWN","authority":"live-serve-decision"},"downloadable":null,"downloadReady":null,"degraded":false,"stale":false,"schemaVersion":"hugging-bay.local-kit.v2","displayOnly":true,"authorizationRequired":true,"eligibilitySnapshotAt":"2026-10-31T15:13:04.189Z","generatedAt":"2026-10-31T15:13:22.354Z","status":"runnable-bundle-recipe","commandsAvailable":true,"commands":[{"tool":"lm-studio","label":"LM Studio (no terminal)","kind":"gui-walkthrough","guiProven":false,"command":"Open LM Studio, then drag the downloaded 'Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf' into My Models to load it.","note":"A walk-through for your machine, not a checked run path — these steps are guidance, never a promise it will run. LM Studio's own UI takes it from there.","prefilledFrom":{"file":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf","templateSha256":"79360a114f96c832fbb36d00e421c61a490651a32e09a26321fe4efbbf264e88","sha256":"384d38b7607ae0738857c8e0e56777fce2451ae204c645dbc9d557e7ce9c44b6"},"guideCheckedAt":"2026-09-22","guideCheckedBy":"hugging-bay-docs","guideVersion":5},{"tool":"ollama","label":"Ollama","note":"Builds a local Ollama model named \"qwen3.5-9b-c3sm-sdm-agentic-coder-q4_k_m\" from the file (Ollama imports the file's embedded chat template) and starts a chat.","prefilledFrom":{"file":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf","templateSha256":"79360a114f96c832fbb36d00e421c61a490651a32e09a26321fe4efbbf264e88","sha256":"384d38b7607ae0738857c8e0e56777fce2451ae204c645dbc9d557e7ce9c44b6"},"guideCheckedAt":"2026-09-22","guideCheckedBy":"hugging-bay-docs","guideVersion":5},{"tool":"llama.cpp","label":"llama.cpp (terminal)","kind":"terminal","proven":true,"note":"Runs the file directly with llama.cpp's command-line tool. -st (--single-turn) runs one turn with the model's embedded chat template and exits — tested on llama.cpp b10964-b29c606e2. The old -no-cnv flag was removed and is rejected by current builds.","runner":{"name":"llama.cpp","testedBuild":"b10964-b29c606e2","singleTurnFlag":"-st"},"prefilledFrom":{"file":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf","templateSha256":"79360a114f96c832fbb36d00e421c61a490651a32e09a26321fe4efbbf264e88","sha256":"384d38b7607ae0738857c8e0e56777fce2451ae204c645dbc9d557e7ce9c44b6"},"guideCheckedAt":"2026-09-22","guideCheckedBy":"hugging-bay-docs","guideVersion":5},{"tool":"python","label":"Python (llama-cpp-python)","command":"pip install llama-cpp-python && python -c 'from llama_cpp import Llama; llm = Llama(\"./Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf\", n_ctx=8192); print(llm.create_chat_completion(messages=[{'\\''role'\\'': '\\''user'\\'', '\\''content'\\'': '\\''Hello!'\\''}])['\\''choices'\\''][0]['\\''message'\\'']['\\''content'\\''])'","note":"For scripting the model from Python; create_chat_completion applies the embedded chat template.","prefilledFrom":{"file":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf","templateSha256":"79360a114f96c832fbb36d00e421c61a490651a32e09a26321fe4efbbf264e88","sha256":"384d38b7607ae0738857c8e0e56777fce2451ae204c645dbc9d557e7ce9c44b6"},"guideCheckedAt":"2026-09-22","guideCheckedBy":"hugging-bay-docs","guideVersion":5}],"runBlockKind":"hosted-file-recipe","chatContract":{"available":true,"source":"gguf-metadata:tokenizer.chat_template","sourceFileSha256":"384d38b7607ae0738857c8e0e56777fce2451ae204c645dbc9d557e7ce9c44b6","templateSha256":"79360a114f96c832fbb36d00e421c61a490651a32e09a26321fe4efbbf264e88","templateText":"{%- 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 — 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 — 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        {#- recorded 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⚠️ 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⚠️ 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⚠️ 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 %}","extractedAt":"2026-10-16","extractionStage":"ingest.template-extract/v1","architecture":"qwen35","contextLength":262144,"stop":["<|im_end|>"],"thinking":{"mode":"delimited","open":"<think>","close":"</think>"}},"artifact":{"id":"hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf","repo":"OliviaRossi/Qwen3.5-9B-C3SM-SDM-Agentic-Coder-GGUF","type":"llm","summary":"Model from Hugging Face for text generation: OliviaRossi/Qwen3.5-9B-C3SM-SDM-Agentic-Coder-GGUF · transformers","license":"apache-2.0","hostingStatus":"hosted","hostedFileCount":1,"hostedFileCountAuthority":"live-serve-decision","displayFileCount":1,"fileCount":5,"upstreamUrl":"https://huggingface.co/OliviaRossi/Qwen3.5-9B-C3SM-SDM-Agentic-Coder-GGUF"},"tool":"any","toolCompatibility":{"status":"unknown","reason":"recorded-evaluator-not-integrated"},"readiness":"unknown","requiredFiles":[{"path":".gitattributes","sizeBytes":1763,"sha256":"","format":"gitattributes","risk":"low","sourceKind":"external-hf","hosted":false,"readiness":"blocked","downloadReady":false,"reasonCodes":["NOT_SERVE_ELIGIBLE"],"reason":"This file is not available to download right now.","individuallyHashed":false,"fileOnly":true,"directDownloadAuthorized":false,"serveDecision":{"state":"BLOCKED","reasonCodes":["NOT_SERVE_ELIGIBLE"]},"downloadUrlResponse":{"status":302,"followRedirects":true},"downloadUrl":null,"chatTemplate":null,"serve_verdict":{"can_download":false,"bytes_verified":false,"signature":"unsigned","freshness":"stale","checked_at":null,"evidence_url":"/api/manifests/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf"},"signature_state":"unsigned"},{"path":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf","sizeBytes":5629134176,"sha256":"384d38b7607ae0738857c8e0e56777fce2451ae204c645dbc9d557e7ce9c44b6","format":"gguf","risk":"low","sourceKind":"mirrored-upstream","hosted":true,"readiness":"unknown","downloadReady":null,"reasonCodes":[],"reason":"Hosted on Hugging Bay and byte-verified — download is available now.","individuallyHashed":true,"fileOnly":true,"directDownloadAuthorized":true,"serveDecision":{"state":"UNKNOWN","reasonCodes":[]},"downloadUrlResponse":{"status":302,"followRedirects":true},"downloadUrl":"https://huggingbay.xyz/api/downloads/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf/Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf","chatTemplate":{"artifactId":"hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf","filePath":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q4_K_M.gguf","sha256":"384d38b7607ae0738857c8e0e56777fce2451ae204c645dbc9d557e7ce9c44b6","architecture":"qwen35","generalName":"Hf_Source","tokenizerModel":"gpt2","contextLength":262144,"bos":null,"eos":"<|im_end|>","stop":["<|im_end|>"],"thinking":{"mode":"delimited","open":"<think>","close":"</think>"},"chatTemplate":"{%- 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 — 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 — 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        {#- recorded 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⚠️ 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⚠️ 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⚠️ 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 %}","templateDigest":"sha256:79360a114f96c832fbb36d00e421c61a490651a32e09a26321fe4efbbf264e88","extractionReason":"embedded-template","extractorVersion":"hugging-bay.gguf-embedded-chat-contract.v1","extractedAt":"2026-10-16T03:55:00.272Z","hasEmbeddedTemplate":true},"serve_verdict":{"can_download":false,"bytes_verified":true,"signature":"unsigned","freshness":"stale","checked_at":null,"evidence_url":"/api/manifests/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf"},"signature_state":"unsigned"},{"path":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q5_K_M.gguf","sizeBytes":6467994976,"sha256":"2eddaf3e9e83790ddc19e5e9ebbba3daf2ad7bafa40525f62c1689fd2d95a34c","format":"gguf","risk":"low","sourceKind":"external-hf","hosted":false,"readiness":"blocked","downloadReady":false,"reasonCodes":["NOT_SERVE_ELIGIBLE"],"reason":"This file is not available to download right now.","individuallyHashed":true,"fileOnly":true,"directDownloadAuthorized":false,"serveDecision":{"state":"BLOCKED","reasonCodes":["NOT_SERVE_ELIGIBLE"]},"downloadUrlResponse":{"status":302,"followRedirects":true},"downloadUrl":null,"chatTemplate":null,"serve_verdict":{"can_download":false,"bytes_verified":false,"signature":"unsigned","freshness":"stale","checked_at":null,"evidence_url":"/api/manifests/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf"},"signature_state":"unsigned"},{"path":"Qwen3.5-9B-C3SM-SDM-Agentic-Coder-Q8_0.gguf","sizeBytes":9527526752,"sha256":"c709a42837f2ef87f39dd7187c78d74c382194a96bc35b03d4094e30ed6d01b4","format":"gguf","risk":"low","sourceKind":"external-hf","hosted":false,"readiness":"blocked","downloadReady":false,"reasonCodes":["NOT_SERVE_ELIGIBLE"],"reason":"This file is not available to download right now.","individuallyHashed":true,"fileOnly":true,"directDownloadAuthorized":false,"serveDecision":{"state":"BLOCKED","reasonCodes":["NOT_SERVE_ELIGIBLE"]},"downloadUrlResponse":{"status":302,"followRedirects":true},"downloadUrl":null,"chatTemplate":null,"serve_verdict":{"can_download":false,"bytes_verified":false,"signature":"unsigned","freshness":"stale","checked_at":null,"evidence_url":"/api/manifests/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf"},"signature_state":"unsigned"},{"path":"README.md","sizeBytes":11086,"sha256":"","format":"md","risk":"low","sourceKind":"external-hf","hosted":false,"readiness":"blocked","downloadReady":false,"reasonCodes":["NOT_SERVE_ELIGIBLE"],"reason":"This file is not available to download right now.","individuallyHashed":false,"fileOnly":true,"directDownloadAuthorized":false,"serveDecision":{"state":"BLOCKED","reasonCodes":["NOT_SERVE_ELIGIBLE"]},"downloadUrlResponse":{"status":302,"followRedirects":true},"downloadUrl":null,"chatTemplate":null,"serve_verdict":{"can_download":false,"bytes_verified":false,"signature":"unsigned","freshness":"stale","checked_at":null,"evidence_url":"/api/manifests/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf"},"signature_state":"unsigned"}],"warnings":["This description is temporarily unavailable."],"nextActions":[{"label":"Inspect recorded bundle state","url":"https://huggingbay.xyz/api/artifacts/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf/bundle","method":"GET"},{"label":"List individually hashed hosted files","url":"https://huggingbay.xyz/api/downloadable-files?artifactId=hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf&limit=100","method":"GET"},{"label":"Inspect trust bundle","url":"https://huggingbay.xyz/api/trust-bundles/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf","method":"GET"},{"label":"Open artifact","url":"https://huggingbay.xyz/artifact/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf","method":"GET"}],"docs":{"artifactUrl":"https://huggingbay.xyz/artifact/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf","downloadsUrl":"https://huggingbay.xyz/api/downloadable-files?artifactId=hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf&limit=100","bundleUrl":"https://huggingbay.xyz/api/artifacts/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf/bundle","trustBundleUrl":"https://huggingbay.xyz/api/trust-bundles/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf"},"note":{"summary":"Downloadable doesn't mean tested: this record says whether the exact file can be downloaded now, not that the model is complete or that it runs.","downloadable":true},"serve_verdict":{"can_download":false,"bytes_verified":false,"signature":"unsigned","freshness":"stale","checked_at":null,"evidence_url":"/api/manifests/hf-model-oliviarossi-qwen3-5-9b-c3sm-sdm-agentic-coder-gguf"}}