{%- set tools = tools | default(none) -%} {%- set add_generation_prompt = add_generation_prompt | default(false) -%} {%- set reasoning_effort = reasoning_effort | default('xhigh', true) -%} {%- set cutoff_date = cutoff_date | default('2026-01-04') -%} {%- set current_date = current_date | default(strftime_now('%Y-%m-%d') if strftime_now is defined else none) -%} {%- set reasoning_effort_map = {'low': 8, 'medium': 32, 'high': 256, 'xhigh': 512} -%} {%- if not (reasoning_effort is string and reasoning_effort in reasoning_effort_map) -%} {{- raise_exception('Unsupported reasoning_effort: ' ~ reasoning_effort ~ '. Expected one of: low, medium, high, xhigh.') -}} {%- endif -%} {%- set deferred_render_mode = deferred_render_mode | default('tool_name_and_description') -%} {#- Neutralise control sequences in caller-supplied text so it cannot be tokenized as structure. "<|" is broken because every special token has the form "<|...|>"; the bare media placeholders are broken because the multimodal processor rewrites them positionally and a literal one in text would desynchronise placeholders from the attached media. -#} {%- macro esc(value) -%} {{- value | string | replace('<|', '< |') | replace('', '< image>') | replace('