SolsticeAI commited on
Commit
ac3ba1a
·
verified ·
1 Parent(s): c8e0906

Update templates/universal.jinja

Browse files
Files changed (1) hide show
  1. templates/universal.jinja +1 -138
templates/universal.jinja CHANGED
@@ -1,77 +1,4 @@
1
  {%- set template_version = template_version if template_version is defined else "protium-v1.0.0-objective-gated" %}
2
-
3
- {#- ========================================================================== -#}
4
- {#- PROTIUM-1.0 — OBJECTIVE-GATED COGNITIVE ARCHITECTURE -#}
5
- {#- Solstice-AI Zero-Waste Protocol for High-Efficiency Reasoning Models -#}
6
- {#- Named after Protium (1H): Zero Neutrons. Zero Dead Weight. Pure Thrust. -#}
7
- {#- Lineage: qwen3.8-froggeric-v22.5.0 (DavidAU, MIT) -> Solstice-AI -#}
8
- {#- -#}
9
- {#- CORE TENETS: -#}
10
- {#- 1. TOKEN 1 TARGET ANCHOR: Lock the termination condition at step 1. -#}
11
- {#- 2. FORWARD-ONLY SOLVE: Advance directly toward the target. Eliminate -#}
12
- {#- conversational filler ("let's see", "hmm", "wait"). No rhetorical -#}
13
- {#- hesitation; execute pure continuous deduction. -#}
14
- {#- 3. EARLY EXIT GATE: Terminate thinking the instant the target condition -#}
15
- {#- is satisfied and verified. Never dwell, stall, or manufacture doubt. -#}
16
- {#- 4. DELTA-ONLY CORRECTION: Fix only the broken variable upon contradiction;-#}
17
- {#- never regress into full restarts or circular overthinking loops. -#}
18
- {#- 5. ABSOLUTE RESOLVE: Decisive, unhedged final delivery. Zero preamble. -#}
19
- {#- -#}
20
- {#- THE SPECTRUM (governed purely by problem constraints & verification): -#}
21
- {#- [L0] Mortal - thinking off; execute directly. -#}
22
- {#- [L1] Hermes - rapid instinct; immediate verification pass. -#}
23
- {#- [L2] Apollo - disciplined deduction; linear constraint trace. -#}
24
- {#- [L3] Artemis - edge-case & boundary vulnerability audit. -#}
25
- {#- [L4] Athena - strategic synthesis; architectural trade-offs. -#}
26
- {#- [L5] Prometheus - defensive engineering; second-order failure modeling. -#}
27
- {#- [L6] Solstice - axiomatic derivation; multi-hypothesis stress testing. -#}
28
- {#- [L7] Hyperion - ground-up first-principles decomposition. -#}
29
- {#- [L8] Einstein - theoretical mastery; unified invariant reduction. -#}
30
- {#- [L9] Oracle - proof-grade formal authority; zero placeholders. -#}
31
- {#- [L10] Proteus - dynamic cognitive adaptation (Default); auto-calibrated -#}
32
- {#- impedance matching across all levels with early exit. -#}
33
- {#- swarm - 20-perspective divergent swarm, verdict line. -#}
34
- {#- council - adversarial research council, verdict line. -#}
35
- {#- -#}
36
- {#- CONTINUOUS DEPTH MAP (10-100): 1-14 L1 | 15-29 L2 | 30-44 L3 | 45-59 L4 | -#}
37
- {#- 60-69 L5 | 70-79 L6 | 80-89 L7 | 90-96 L8 | 97-100 L9 | 0 = off. -#}
38
- {#- -#}
39
- {#- INLINE SYNTAX (case-insensitive, stripped before model sees them): -#}
40
- {#- [L0]..[L9] | {REASON:level|name|number} | [MODE:level|name|number] -#}
41
- {#- [regular] | [vanilla] | [standard] | [default] -#}
42
- {#- Prefix 'i' = silent variant: {REASON:i8} runs L8 rigor, thinking hidden. -#}
43
- {#- PRECEDENCE: default L7 < runtime kwarg < inline signals (last wins). -#}
44
- {#- ========================================================================== -#}
45
-
46
- {#- ------------------------------------------------------------------ -#}
47
- {#- RUNTIME KWARGS -#}
48
- {#- ------------------------------------------------------------------ -#}
49
- {%- set _tool_format = tool_call_format if tool_call_format is defined else 'xml' %}
50
- {%- set image_count = namespace(value=0) %}
51
- {%- set video_count = namespace(value=0) %}
52
- {%- set add_vision_id = add_vision_id if add_vision_id is defined else false %}
53
- {%- set enable_thinking = enable_thinking if enable_thinking is defined else true %}
54
- {%- set auto_disable_thinking_with_tools = auto_disable_thinking_with_tools if auto_disable_thinking_with_tools is defined else false %}
55
- {%- if preserve_reasoning is defined and preserve_reasoning is not none %}
56
- {%- set _preserve_thinking = preserve_reasoning %}
57
- {%- elif preserve_thinking is defined and preserve_thinking is not none %}
58
- {%- set _preserve_thinking = preserve_thinking %}
59
- {%- else %}
60
- {%- set _preserve_thinking = true %}
61
- {%- endif %}
62
- {%- set max_tool_arg_chars = max_tool_arg_chars if max_tool_arg_chars is defined else 0 %}
63
- {%- set max_tool_response_chars = max_tool_response_chars if max_tool_response_chars is defined else 0 %}
64
- {%- set _has_tools = (tools is defined and tools and tools is iterable and tools is not mapping) %}
65
- {%- set _has_budget = (thinking_budget is defined and thinking_budget and (thinking_budget | int) > 0) or (max_thinking_tokens is defined and max_thinking_tokens and (max_thinking_tokens | int) > 0) %}
66
- {%- set _budget_val = (thinking_budget | int) if (thinking_budget is defined and thinking_budget and (thinking_budget | int) > 0) else ((max_thinking_tokens | int) if (max_thinking_tokens is defined and max_thinking_tokens) else 0) %}
67
- {%- set _terse_on = terse if terse is defined else (not is_explicit_regular) %}
68
- {%- set suppress_tool_instructions = suppress_tool_instructions if suppress_tool_instructions is defined else none %}
69
-
70
- {#- ================================================================== -#}
71
- {#- S3 PRIMITIVES — render & scan helpers (no cognitive content). -#}
72
- {#- ================================================================== -#}
73
-
74
- {#- Content renderer with vision support (render loop only). -#}
75
  {%- macro render_content(content, do_vision_count, is_system_content=false) %}
76
  {%- if content is string %}
77
  {{- content }}
@@ -115,9 +42,6 @@
115
  {{- raise_exception('Unexpected content type.') }}
116
  {%- endif %}
117
  {%- endmacro %}
118
-
119
- {#- Text-only scanner renderer: images/videos render as '' so the S1 scan -#}
120
- {#- pass never raises on multimodal messages (v2.x vision bug fixed). -#}
121
  {%- macro scan_text(content) %}
122
  {%- if content is string %}
123
  {{- content }}
@@ -131,7 +55,6 @@
131
  {%- endfor %}
132
  {%- endif %}
133
  {%- endmacro %}
134
-
135
  {#- Strip every inline control tag from visible text. -#}
136
  {%- macro strip_control_tags(text) %}
137
  {%- set t = text %}
@@ -150,8 +73,6 @@
150
  {%- set out = t3 | replace('[regular]', '') | replace('[REGULAR]', '') | replace('[vanilla]', '') | replace('[standard]', '') | replace('[default]', '') | replace('[L10]', '') | replace('[l10]', '') | replace('[L0]', '') | replace('[l0]', '') | replace('[L1]', '') | replace('[l1]', '') | replace('[L2]', '') | replace('[l2]', '') | replace('[L3]', '') | replace('[l3]', '') | replace('[L4]', '') | replace('[l4]', '') | replace('[L5]', '') | replace('[l5]', '') | replace('[L6]', '') | replace('[l6]', '') | replace('[L7]', '') | replace('[l7]', '') | replace('[L8]', '') | replace('[l8]', '') | replace('[L9]', '') | replace('[l9]', '') %}
151
  {{- out }}
152
  {%- endmacro %}
153
-
154
- {#- Remove only a {REASON:...} / [MODE:...] tag (assistant history path). -#}
155
  {%- macro strip_mode_tag(text) %}
156
  {%- set t = text %}
157
  {%- if '{REASON:' in t %}
@@ -163,9 +84,6 @@
163
  {%- endif %}
164
  {{- t }}
165
  {%- endmacro %}
166
-
167
- {#- Tool output error classifier → 'error' | 'ok'. Shares ONE definition -#}
168
- {#- with the S1 failure pre-pass and the render-loop warning counter. -#}
169
  {%- macro classify_tool_output(content) %}
170
  {%- set _lower = content | lower %}
171
  {%- set _head = _lower[:120] %}
@@ -181,12 +99,6 @@
181
  {{- 'ok' }}
182
  {%- endif %}
183
  {%- endmacro %}
184
-
185
- {#- ================================================================== -#}
186
- {#- S2 COGNITIVE PROFILES — pure text. Soft shares only; there are no -#}
187
- {#- token counts, word floors or ceilings anywhere in this section. -#}
188
- {#- ================================================================== -#}
189
-
190
  {%- set soft_budget_contract -%}
191
  PROTIUM OBJECTIVE-GATED REASONING CONTRACT:
192
  1. Target Anchor: At token 1, isolate the exact termination criteria — define what a completed, verified solution requires before executing.
@@ -197,7 +109,6 @@ PROTIUM OBJECTIVE-GATED REASONING CONTRACT:
197
  6. Delta-Only Correction: If a contradiction or constraint violation is encountered, isolate and repair only the specific broken variable. Never regress into circular overthinking loops or full restarts.
198
  7. Absolute Resolve: Formulate a definitive, decisive conclusion without hedging, equivocating, or artificial disclaimers. Correctness and crisp utility are the sole metrics.
199
  {%- endset %}
200
-
201
  {%- set terse_core -%}
202
  Operational Directives:
203
  - Zero preamble, pleasantries, or question restatements.
@@ -205,7 +116,6 @@ Operational Directives:
205
  - Retain all essential mathematical, programmatic, and logical technical rigor.
206
  - If genuine ambiguity exists, resolve it along the most probable engineering standard or ask one targeted clarifying question.
207
  {%- endset %}
208
-
209
  {%- set inst_hermes -%}
210
  Reasoning effort: Hermes — [L1] (rapid instinct).
211
  Mindset: High-velocity execution. Rapid sanity check of premise, arithmetic, or syntax — then commit immediately to the shortest verified bridge to the conclusion. Conclude immediately once obvious.
@@ -259,14 +169,7 @@ Reasoning effort: Council — adversarial research council (specialized mode).
259
  Mindset: Five-protocol institutional deliberation. Protocol 1: Parameter calibration and success criteria. Protocol 2: Multi-specialist panel assembly. Protocol 3: Adversarial debate and stress-testing. Protocol 4: Trade-off scoring matrix. Protocol 5: Master architecture.
260
  Output contract: Conclude thinking and open final response with "[COUNCIL VERDICT]" followed by the definitive ruling, key justification, and dissenting risk accounted for.
261
  {%- endset %}
262
-
263
- {#- ================================================================== -#}
264
- {#- S1 RESOLUTION CORE — one pass, one state, one resolver. -#}
265
- {#- ================================================================== -#}
266
-
267
- {#- Baseline: runtime kwarg (session default). thinking_level supported. -#}
268
  {%- set _kwarg_effort = '' %}
269
-
270
  {%- set reg_ns = namespace(active=false) %}
271
  {%- if (regular is defined and regular) or (mode is defined and mode in ('regular', 'vanilla', 'standard', 'default', 'clean')) %}
272
  {%- set reg_ns.active = true %}
@@ -300,9 +203,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
300
  {%- if auto_disable_thinking_with_tools and _has_tools %}
301
  {%- set ns_state.thinking = false %}
302
  {%- endif %}
303
-
304
- {#- Unified scan pass: collect mode tags, inline signals, cleaned messages. -#}
305
- {#- Later signals override earlier ones (mid-chat re-escalation works). -#}
306
  {%- set store = namespace(messages=[], raw_mode='', saw_inline=false) %}
307
  {%- if not messages %}
308
  {{- raise_exception('No messages provided.') }}
@@ -328,7 +228,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
328
  {%- endfor %}
329
  {%- endif %}
330
  {%- set _has_inline = _hi.v %}
331
- {#- Inline think-tags + [L#] (steering roles only). Later messages win. -#}
332
  {%- if _is_steering %}
333
  {%- if '<|think_off|>' in _low %}
334
  {%- set ns_state.thinking = false %}
@@ -392,7 +291,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
392
  {%- endfor %}
393
  {%- endif %}
394
  {%- endif %}
395
- {#- {REASON:...} / [MODE:...] extraction (any role). -#}
396
  {%- set _tagged = ('{REASON:' in _txt) or ('[MODE:' in _txt) %}
397
  {%- if _tagged %}
398
  {%- set _raw_reason = '' %}
@@ -422,13 +320,10 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
422
  {%- endif %}
423
  {%- endif %}
424
  {%- endif %}
425
- {#- Build cleaned message store. Messages WITHOUT inline signals pass -#}
426
- {#- through untouched, so multi-modal parts (images/videos) survive. -#}
427
  {%- if _tagged and _role == 'assistant' %}
428
  {%- set _clean = strip_mode_tag(_txt) | trim %}
429
  {%- set store.messages = store.messages + [{'role': _role, 'content': _clean, 'tool_calls': (msg.tool_calls if msg.tool_calls is defined else none), 'reasoning_content': (msg.reasoning_content if msg.reasoning_content is defined else none), 'thinking': (msg.thinking if msg.thinking is defined else none), 'reasoning': (msg.reasoning if msg.reasoning is defined else none)}] %}
430
  {%- elif _is_steering and _has_inline %}
431
- {#- Multi-modal aware strip: clean text items, keep image/video parts. -#}
432
  {%- if msg.content is string %}
433
  {%- set _clean = strip_control_tags(_txt) | trim %}
434
  {%- set store.messages = store.messages + [{'role': _role, 'content': _clean}] %}
@@ -451,11 +346,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
451
  {%- endfor %}
452
  {%- set messages = store.messages %}
453
  {%- set _depth_explicit = (_depth_explicit or store.saw_inline) %}
454
-
455
- {#- Continuous depth: pure integers 10-100 map onto the spectrum band. -#}
456
- {#- 0-9 stay legacy level numbers so old clients keep exact behaviour. -#}
457
- {#- NB: int-filter round-trip instead of .isdigit() — minja (llama.cpp) -#}
458
- {#- does not implement string.isdigit(). -#}
459
  {%- set _eff_int = ns_state.effort | int %}
460
  {%- if ns_state.mode == 'level' and ns_state.effort is string and (_eff_int | string) == ns_state.effort and _eff_int >= 11 %}
461
  {%- set _n = ns_state.effort | int %}
@@ -480,8 +370,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
480
  {%- set ns_state.effort = '9' %}
481
  {%- endif %}
482
  {%- endif %}
483
-
484
- {#- Depth-tool coupling, part A: trailing tool-failure streak pre-pass. -#}
485
  {%- set _streak = namespace(value=0) %}
486
  {%- for msg in messages %}
487
  {%- if msg.role == 'tool' %}
@@ -495,11 +383,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
495
  {%- set _streak.value = 0 %}
496
  {%- endif %}
497
  {%- endfor %}
498
-
499
- {#- Depth-tool coupling, part B: state adjustment BEFORE rendering. -#}
500
- {#- Collapse: tools attached, no explicit depth signal → [L4]. -#}
501
- {#- Escalate: 2+ consecutive tool failures → +1 band, capped at [L7]. -#}
502
- {#- Swarm/council profiles are never auto-tuned (non-numeric effort). -#}
503
  {%- if _has_tools and not _depth_explicit and ns_state.thinking %}
504
  {%- set ns_state.effort = '4' %}
505
  {%- endif %}
@@ -521,12 +404,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
521
  {%- set ns_state.effort = '7' %}
522
  {%- endif %}
523
  {%- endif %}
524
-
525
- {#- Alias resolver: number / name / compat alias → profile. Runs AFTER -#}
526
- {#- coupling, so the rendered profile always matches the final effort. -#}
527
- {#- Unknown input degrades gracefully to [L7]; it never hard-fails. -#}
528
- {#- Silent modes (i-prefix) still inject the depth profile: the model -#}
529
- {#- reasons at that quality internally while thinking tags stay closed. -#}
530
  {%- set reasoning_instructions = '' %}
531
  {%- if ns_state.thinking or ns_state.silent_profile %}
532
  {%- set target_mode = ns_state.effort if ns_state.effort else '10' %}
@@ -558,11 +435,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
558
  {%- set reasoning_instructions = inst_proteus %}
559
  {%- endif %}
560
  {%- endif %}
561
-
562
- {#- ================================================================== -#}
563
- {#- S3 RENDER PIPELINE — ChatML emission. -#}
564
- {#- ================================================================== -#}
565
-
566
  {#- Leading system-message grouping. -#}
567
  {%- set head = namespace(count=0, seen_non_system=false) %}
568
  {%- for message in messages %}
@@ -595,16 +467,12 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
595
  {%- set _sc = (_sc | trim) ~ '\n\n' ~ (terse_core | trim) %}
596
  {%- endif %}
597
  {%- endif %}
598
-
599
- {#- Some runtimes prepend their own tool protocol; stand down if seen. -#}
600
  {%- set _runtime_tool_protocol = (_sc is defined and _sc and '[TOOL_REQUEST]' in _sc) %}
601
  {%- if suppress_tool_instructions is not none %}
602
  {%- set _suppress_tools = suppress_tool_instructions %}
603
  {%- else %}
604
  {%- set _suppress_tools = _runtime_tool_protocol %}
605
  {%- endif %}
606
-
607
- {#- System emission: profile + soft contract + tools. -#}
608
  {%- if reasoning_instructions or _sc or (_has_tools and not _suppress_tools) %}
609
  {{- '<|im_start|>system\n' }}
610
  {%- if reasoning_instructions %}
@@ -648,8 +516,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
648
  {%- endif %}
649
  {%- endif %}
650
  {%- endif %}
651
-
652
- {#- Last real user turn (for preserve_thinking tail logic). -#}
653
  {%- set _last_idx = _msgs | length - 1 %}
654
  {%- set ns = namespace(multi_step_tool=true, last_query_index=_last_idx) %}
655
  {%- for message in _msgs[::-1] %}
@@ -669,8 +535,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
669
  {%- set ns.last_query_index = 0 %}
670
  {%- endif %}
671
  {%- endif %}
672
-
673
- {#- Message render loop. -#}
674
  {%- set ns2 = namespace(prev_role='', consecutive_failures=0) %}
675
  {%- for message in _msgs %}
676
  {%- set is_system = (message.role == "system" or message.role == "developer") %}
@@ -863,7 +727,6 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
863
  {%- endif %}
864
  {%- set ns2.prev_role = message.role %}
865
  {%- endfor %}
866
-
867
  {#- Generation prompt: open thinking when active (variable depth, the model -#}
868
  {#- decides how far to run), or pre-close it when disabled. -#}
869
  {%- if add_generation_prompt %}
@@ -875,4 +738,4 @@ Output contract: Conclude thinking and open final response with "[COUNCIL VERDIC
875
  {%- else %}
876
  {{- '<think>\n' }}
877
  {%- endif %}
878
- {%- endif %}
 
1
  {%- set template_version = template_version if template_version is defined else "protium-v1.0.0-objective-gated" %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  {%- macro render_content(content, do_vision_count, is_system_content=false) %}
3
  {%- if content is string %}
4
  {{- content }}
 
42
  {{- raise_exception('Unexpected content type.') }}
43
  {%- endif %}
44
  {%- endmacro %}
 
 
 
45
  {%- macro scan_text(content) %}
46
  {%- if content is string %}
47
  {{- content }}
 
55
  {%- endfor %}
56
  {%- endif %}
57
  {%- endmacro %}
 
58
  {#- Strip every inline control tag from visible text. -#}
59
  {%- macro strip_control_tags(text) %}
60
  {%- set t = text %}
 
73
  {%- set out = t3 | replace('[regular]', '') | replace('[REGULAR]', '') | replace('[vanilla]', '') | replace('[standard]', '') | replace('[default]', '') | replace('[L10]', '') | replace('[l10]', '') | replace('[L0]', '') | replace('[l0]', '') | replace('[L1]', '') | replace('[l1]', '') | replace('[L2]', '') | replace('[l2]', '') | replace('[L3]', '') | replace('[l3]', '') | replace('[L4]', '') | replace('[l4]', '') | replace('[L5]', '') | replace('[l5]', '') | replace('[L6]', '') | replace('[l6]', '') | replace('[L7]', '') | replace('[l7]', '') | replace('[L8]', '') | replace('[l8]', '') | replace('[L9]', '') | replace('[l9]', '') %}
74
  {{- out }}
75
  {%- endmacro %}
 
 
76
  {%- macro strip_mode_tag(text) %}
77
  {%- set t = text %}
78
  {%- if '{REASON:' in t %}
 
84
  {%- endif %}
85
  {{- t }}
86
  {%- endmacro %}
 
 
 
87
  {%- macro classify_tool_output(content) %}
88
  {%- set _lower = content | lower %}
89
  {%- set _head = _lower[:120] %}
 
99
  {{- 'ok' }}
100
  {%- endif %}
101
  {%- endmacro %}
 
 
 
 
 
 
102
  {%- set soft_budget_contract -%}
103
  PROTIUM OBJECTIVE-GATED REASONING CONTRACT:
104
  1. Target Anchor: At token 1, isolate the exact termination criteria — define what a completed, verified solution requires before executing.
 
109
  6. Delta-Only Correction: If a contradiction or constraint violation is encountered, isolate and repair only the specific broken variable. Never regress into circular overthinking loops or full restarts.
110
  7. Absolute Resolve: Formulate a definitive, decisive conclusion without hedging, equivocating, or artificial disclaimers. Correctness and crisp utility are the sole metrics.
111
  {%- endset %}
 
112
  {%- set terse_core -%}
113
  Operational Directives:
114
  - Zero preamble, pleasantries, or question restatements.
 
116
  - Retain all essential mathematical, programmatic, and logical technical rigor.
117
  - If genuine ambiguity exists, resolve it along the most probable engineering standard or ask one targeted clarifying question.
118
  {%- endset %}
 
119
  {%- set inst_hermes -%}
120
  Reasoning effort: Hermes — [L1] (rapid instinct).
121
  Mindset: High-velocity execution. Rapid sanity check of premise, arithmetic, or syntax — then commit immediately to the shortest verified bridge to the conclusion. Conclude immediately once obvious.
 
169
  Mindset: Five-protocol institutional deliberation. Protocol 1: Parameter calibration and success criteria. Protocol 2: Multi-specialist panel assembly. Protocol 3: Adversarial debate and stress-testing. Protocol 4: Trade-off scoring matrix. Protocol 5: Master architecture.
170
  Output contract: Conclude thinking and open final response with "[COUNCIL VERDICT]" followed by the definitive ruling, key justification, and dissenting risk accounted for.
171
  {%- endset %}
 
 
 
 
 
 
172
  {%- set _kwarg_effort = '' %}
 
173
  {%- set reg_ns = namespace(active=false) %}
174
  {%- if (regular is defined and regular) or (mode is defined and mode in ('regular', 'vanilla', 'standard', 'default', 'clean')) %}
175
  {%- set reg_ns.active = true %}
 
203
  {%- if auto_disable_thinking_with_tools and _has_tools %}
204
  {%- set ns_state.thinking = false %}
205
  {%- endif %}
 
 
 
206
  {%- set store = namespace(messages=[], raw_mode='', saw_inline=false) %}
207
  {%- if not messages %}
208
  {{- raise_exception('No messages provided.') }}
 
228
  {%- endfor %}
229
  {%- endif %}
230
  {%- set _has_inline = _hi.v %}
 
231
  {%- if _is_steering %}
232
  {%- if '<|think_off|>' in _low %}
233
  {%- set ns_state.thinking = false %}
 
291
  {%- endfor %}
292
  {%- endif %}
293
  {%- endif %}
 
294
  {%- set _tagged = ('{REASON:' in _txt) or ('[MODE:' in _txt) %}
295
  {%- if _tagged %}
296
  {%- set _raw_reason = '' %}
 
320
  {%- endif %}
321
  {%- endif %}
322
  {%- endif %}
 
 
323
  {%- if _tagged and _role == 'assistant' %}
324
  {%- set _clean = strip_mode_tag(_txt) | trim %}
325
  {%- set store.messages = store.messages + [{'role': _role, 'content': _clean, 'tool_calls': (msg.tool_calls if msg.tool_calls is defined else none), 'reasoning_content': (msg.reasoning_content if msg.reasoning_content is defined else none), 'thinking': (msg.thinking if msg.thinking is defined else none), 'reasoning': (msg.reasoning if msg.reasoning is defined else none)}] %}
326
  {%- elif _is_steering and _has_inline %}
 
327
  {%- if msg.content is string %}
328
  {%- set _clean = strip_control_tags(_txt) | trim %}
329
  {%- set store.messages = store.messages + [{'role': _role, 'content': _clean}] %}
 
346
  {%- endfor %}
347
  {%- set messages = store.messages %}
348
  {%- set _depth_explicit = (_depth_explicit or store.saw_inline) %}
 
 
 
 
 
349
  {%- set _eff_int = ns_state.effort | int %}
350
  {%- if ns_state.mode == 'level' and ns_state.effort is string and (_eff_int | string) == ns_state.effort and _eff_int >= 11 %}
351
  {%- set _n = ns_state.effort | int %}
 
370
  {%- set ns_state.effort = '9' %}
371
  {%- endif %}
372
  {%- endif %}
 
 
373
  {%- set _streak = namespace(value=0) %}
374
  {%- for msg in messages %}
375
  {%- if msg.role == 'tool' %}
 
383
  {%- set _streak.value = 0 %}
384
  {%- endif %}
385
  {%- endfor %}
 
 
 
 
 
386
  {%- if _has_tools and not _depth_explicit and ns_state.thinking %}
387
  {%- set ns_state.effort = '4' %}
388
  {%- endif %}
 
404
  {%- set ns_state.effort = '7' %}
405
  {%- endif %}
406
  {%- endif %}
 
 
 
 
 
 
407
  {%- set reasoning_instructions = '' %}
408
  {%- if ns_state.thinking or ns_state.silent_profile %}
409
  {%- set target_mode = ns_state.effort if ns_state.effort else '10' %}
 
435
  {%- set reasoning_instructions = inst_proteus %}
436
  {%- endif %}
437
  {%- endif %}
 
 
 
 
 
438
  {#- Leading system-message grouping. -#}
439
  {%- set head = namespace(count=0, seen_non_system=false) %}
440
  {%- for message in messages %}
 
467
  {%- set _sc = (_sc | trim) ~ '\n\n' ~ (terse_core | trim) %}
468
  {%- endif %}
469
  {%- endif %}
 
 
470
  {%- set _runtime_tool_protocol = (_sc is defined and _sc and '[TOOL_REQUEST]' in _sc) %}
471
  {%- if suppress_tool_instructions is not none %}
472
  {%- set _suppress_tools = suppress_tool_instructions %}
473
  {%- else %}
474
  {%- set _suppress_tools = _runtime_tool_protocol %}
475
  {%- endif %}
 
 
476
  {%- if reasoning_instructions or _sc or (_has_tools and not _suppress_tools) %}
477
  {{- '<|im_start|>system\n' }}
478
  {%- if reasoning_instructions %}
 
516
  {%- endif %}
517
  {%- endif %}
518
  {%- endif %}
 
 
519
  {%- set _last_idx = _msgs | length - 1 %}
520
  {%- set ns = namespace(multi_step_tool=true, last_query_index=_last_idx) %}
521
  {%- for message in _msgs[::-1] %}
 
535
  {%- set ns.last_query_index = 0 %}
536
  {%- endif %}
537
  {%- endif %}
 
 
538
  {%- set ns2 = namespace(prev_role='', consecutive_failures=0) %}
539
  {%- for message in _msgs %}
540
  {%- set is_system = (message.role == "system" or message.role == "developer") %}
 
727
  {%- endif %}
728
  {%- set ns2.prev_role = message.role %}
729
  {%- endfor %}
 
730
  {#- Generation prompt: open thinking when active (variable depth, the model -#}
731
  {#- decides how far to run), or pre-close it when disabled. -#}
732
  {%- if add_generation_prompt %}
 
738
  {%- else %}
739
  {{- '<think>\n' }}
740
  {%- endif %}
741
+ {%- endif %}