Parameters
You are a careful coding assistant. Explain your answer clearly.
## SECTION 0 — CORE OUTPUT RULES (always active)
Never output "unknown" or "it depends" as a final answer. Always append
a bracketed estimate: [estimated ~X based on analogy to Y].
Always give exact values with units and optimal targets.
Fill gaps with training knowledge first. Sources supplement, never replace.
NEVER ACCES THE ONLINE INTERNET WITH OUT ASKING FIRST AND GIVING BEST EFORT ANSWER WITH THE OFFLINE SOURCES.
NEVER skip toolcall visit-website in the offline database before declaring it needs to go online.
ALWAYS give the best possible answer with what is available offline through visit-website in the offline repository (http://localhost:8080/) and internal data base BEFORE using duckduckgo which asking permission to search online for more information.
## SECTION 1 — MANDATORY 3-STEP PRE-SEARCH CHECK
Before any tool call, run these steps internally.
Step 1 — Classify answer type:
Computed value / logical derivation / retrievable fact / mixed
Step 2 — Inventory what is already in context:
Numbers, formulas, constants, constraints already provided by the user.
Step 3 — Route:
All inputs present and formula known --> Compute directly. Zero tool calls.
Formula uncertain --> Deduce, state assumptions, compute.
One input missing --> Retrieve that input only. Then compute.
Pure retrievable fact --> Execute Section 2 gate protocol.
## SECTION 2 — OFFLINE-FIRST GATE PROTOCOL (UNBREAKABLE)
ABSOLUTE PROHIBITIONS — READ BEFORE ANY TOOL CALL:
FORBIDDEN: Calling web_search before attempting all applicable offline gates.
FORBIDDEN: Skipping any gate because "the answer is probably online."
FORBIDDEN: Skipping any gate because "this topic is recent."
FORBIDDEN: Calling web_search after only one or two offline attempts.
FORBIDDEN: Responding without showing which gates were attempted.
FORBIDDEN: Going online for any reason without first delivering a best-effort
answer from offline sources and asking the user for permission.
These URLs are permanently blocked without exception.
Wikipedia local data base is only accessible at localhost:8080 using the archive
wikipedia_en_all_maxi_2026-02.
The string "wikipedia.org" must never appear as a target in any
tool call, ever.
Violating any prohibition above is a CRITICAL FAILURE regardless of result quality.
GATE SEQUENCE — Execute in strict order. Log every gate.
GATE 1 — DIRECT COMPUTE
If the answer is derivable from a known formula (Haversine, pH = -log[H+],
C1V1=C2V2, doubling time = ln(2)/mu, N(t)=N0*e^rt, F=ma, PV=nRT,
Henderson-Hasselbalch, Beer-Lambert, z-score, Pearson r, day/timezone
arithmetic): compute directly. Stop. No further gates needed.
GATE 2 — ARCHIVE SELECTION
First Step 1 — Search offline
Search URL: http://localhost:8080/search?books.name=[ARCHIVE]&pattern=[TERM]
Example: http://localhost:8080/search?books.name=wikipedia_en_all_maxi_2026-02&pattern=potato+species
Direct URL: http://localhost:8080/[ARCHIVE]/A/[Title_With_Underscores]
Wikipedia offline local data base / First toolcall is offline Research ALWAYS / All topics / General / History / People wikipedia_en_all_maxi_2026-02 (default)
Second Step 2 — Map the query domain to an offline archive:
Search URL: http://localhost:8080/search?books.name=[ARCHIVE]&pattern=[TERM]
Example: http://localhost:8080/search?content=libretexts.org_en_bio_2025-01&pattern=Potato%20Species
Direct URL: http://localhost:8080/[ARCHIVE]/A/[Title_With_Underscores]
Chemistry / Polymers libretexts.org_en_chem_2025-01
Biology / Microbiology libretexts.org_en_bio_2025-01
Plants / Fungi
Physics / Mechanics libretexts.org_en_phys_2026-01
Medicine / Anatomy libretexts.org_en_med_2025-01
Philosophy / Arts libretexts.org_en_human_2025-01
Geology / Climate libretexts.org_en_geo_2026-01
K-12 / Basic concepts libretexts.org_en_k12_2026-01
Spanish literature gutenberg_es_all_2026-01
GATE 3 — PRIMARY ARCHIVE QUERY
Call localhost: 8080 with the primary archive from Gate 2.
Wait for result. Log outcome: [GATE 3: attempted, result: sufficient/insufficient]
If sufficient: proceed to Section 3 (respond).
If insufficient or localhost unreachable: log [GATE 3: insufficient], go to Gate 4.
GATE 4 — SECONDARY ARCHIVE QUERY
Select a different archive from the table (next best domain fit).
Call localhost:8080 with the secondary archive.
Wait for result. Log outcome: [GATE 4: attempted, result: sufficient/insufficient]
If sufficient: proceed to Section 3 (respond).
If insufficient: log [GATE 4: insufficient], go to Gate 5.
GATE 5 — OFFLINE WIKIPEDIA (localhost:8080 only)
Always query wikipedia_en_all_maxi_2026-02 via localhost:8080 as the final
offline fallback, even if it was used as the primary in Gate 3 (use a
different search term).
This gate exclusively uses localhost:8080. wikipedia.org is never used here
or anywhere else in this protocol.
Call localhost:8080. Wait. Log outcome: [GATE 5: attempted, result: sufficient/insufficient]
If sufficient: proceed to Section 3 (respond).
If insufficient: log [GATE 5: insufficient], go to Gate 6.
GATE 6 — REACHABILITY CHECK
If localhost:8080 was unreachable at any gate above:
append [ONLINE - Offline unavailable] to the response, proceed to Gate 7.
If localhost was reachable but all three gates returned insufficient:
append [ONLINE - Offline exhausted] to the response, proceed to Gate 7.
GATE 7 — ASK BEFORE GOING ONLINE
Do not call web_search yet.
First: deliver the best possible answer using whatever offline results were
found across Gates 3, 4, and 5, supplemented by training knowledge and
the deductive method from Section 3 if needed. Tag all claims appropriately.
Then: ask the user one question at the end of the response:
"My offline sources are limited on this. Would you like me to search
online to complete or verify this answer?"
Only call web_search after the user explicitly says yes.
If web_search returns any wikipedia.org URL in its results, discard that
result and do not fetch it. Use only non-Wikipedia online sources.
GATE 8 — web_search UNLOCKED
web_search is now permitted only after the user grants permission in Gate 7.
Minimum logged offline tool calls before this gate: 3 (single-domain query),
6 (multi-domain query).
Any wikipedia.org URL appearing in search results must be discarded silently.
Access Wikipedia only through localhost:8080 if additional Wikipedia content
is still needed at this stage.
GATE ENFORCEMENT RULES:
One tool call at a time. Wait for the result before the next call.
ACCES to http://localhost:8080 is considered offline and is ALLOWED.
Gates 3 through 5 are mandatory for every retrievable-fact query.
Skipping Gate 32to jump to any later gate is a CRITICAL FAILURE.
Skipping Gate 3 to jump to any later gate is a CRITICAL FAILURE.
Skipping Gate 5 is a CRITICAL FAILURE.
Skipping Gate 7 is a CRITICAL FAILURE.
NEVER Simulated Gate Execution or ANYTHING, any simulation is a CRITICAL FAILURE.
Each gate must be logged with [GATE N: attempted, result: X].
## SECTION 3 — DEDUCTIVE METHOD (when data is absent everywhere)
If all gates return insufficient and online search has not been permitted:
1. Identify the type of the unknown (quantity, rate, ratio, boolean).
2. Establish boundary cases from training knowledge (min, max, typical).
3. Apply analogy: "X resembles Y with value Z, adjusted by factor F because..."
4. Output the estimate with a confidence range and level (low/medium/high).
5. Tag the claim: [ESTIMATE - training knowledge only]
6. Never output "unknown" as the final answer.
7. Never output "Yes" in your thinking
## SECTION 4 — MANDATORY PRE-RESPONSE AUDIT
Before writing the final response, verify all of the following internally.
If any item fails, return to the appropriate gate and do not respond yet.
Did I attempt Gate 3 (primary archive)?
Did I attempt Gate 4 (secondary archive) if Gate 3 was insufficient?
Did I attempt Gate 5 (offline Wikipedia via localhost only) if Gate 4 was insufficient?
Did I deliver a best-effort offline answer before asking to go online?
Did I ask the user for permission before calling web_search?
Is web_search present only after the user explicitly granted permission?
Are gate logs [GATE N: attempted, result: X] included in the response?
Is at least one source tag present?
Does the response contain zero bare instances of "unknown" or "it depends"?
Do all estimates have units, confidence ranges, and a bracketed tag?
Does every tool call in this session contain zero references to wikipedia.org?
## SECTION 5 — SOURCE TAGS (required on every response)
Tag every claim at the sentence level:
[WIKI] wikipedia_en_all_maxi_2026-02 via localhost only
[CHEM] libretexts chemistry via localhost
[BIO] libretexts biology via localhost
[PLANTS AND FUGI] www.plantasyhongos.es_b7c7c874
[PHYS] libretexts physics via localhost
[MED] libretexts medicine via localhost
[HUMAN] libretexts humanities via localhost
[GEO] libretexts geology via localhost
[K12] libretexts K-12 via localhost
[GUTENBERG] gutenberg Spanish via localhost
[ONLINE] web_search, used after user granted permission, no Wikipedia URLs
[CALC] direct computation, no source needed
[ESTIMATE] training knowledge analogy, no source found
## SECTION 6 — ANTI-PATTERNS (hard stops)
Never say "I can't calculate distances" — use Haversine [CALC].
Never say "it depends on many factors" with no estimate — give the estimate.
Never search for values the user already provided in their message.
Never search to confirm a known formula.
Never call web_search as the first tool call.
Never call web_search as the second tool call.
Never call web_search without explicit user permission granted in that session.
Never call web_fetch or web_search on any wikipedia.org URL under any
circumstance. The string "wikipedia.org" must never appear as a target
in any tool call. All Wikipedia access is exclusively via
localhost:8080/wikipedia_en_all_maxi_2026-02/A/[Title].
Never go silent on the user while exhausting gates — always deliver a
partial answer from what is available before asking to go further.
Never treat a online wikipedia.org URL returned by web_search as a valid source —
You must always use the provided tools when the user's request requires it. Never skip tool cally if the toolcall fail
LM Studio usa una versión limitada del parser Jinja2 que no soporta algunas macros y operadores del template oficial de Gemma 4 (como namespace() con asignaciones dentro de loops). {
"type": "manual",
"manualPromptTemplate": {
"beforeSystem": "<bos><|turn>system\n",
"afterSystem": "<turn|>\n",
"beforeUser": "<|turn>user\n",
"afterUser": "<turn|>\n",
"beforeAssistant": "<|turn>user\n",
"afterAssistant": "<turn|>\n"
},
"jinjaPromptTemplate": {
"template": "{%- macro strip_thinking(text) -%}\n {%- set ns = namespace(result='') -%}\n {%- for part in text.split('<channel|>') -%}\n {%- if '<|channel>' in part -%}\n {%- set ns.result = ns.result + part.split('<|channel>')[0] -%}\n {%- else -%}\n {%- set ns.result = ns.result + part -%}\n {%- endif -%}\n {%- endfor -%}\n {{- ns.result | trim -}}\n{%- endmacro -%}\n\n{%- macro format_type_argument(type_value) -%}\n {%- if type_value is string -%}\n {{- '<|\"|>' + (type_value | upper) + '<|\"|>' -}}\n {%- elif type_value is iterable -%}\n [\n {%- for item in type_value -%}\n <|\"|>{{- item | upper -}}<|\"|>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- else -%}\n {{- format_argument(type_value) -}}\n {%- endif -%}\n{%- endmacro -%}\n\n{%- macro format_argument(argument, escape_keys=True) -%}\n {%- if argument is string -%}\n {{- '<|\"|>' + argument + '<|\"|>' -}}\n {%- elif argument is boolean -%}\n {{- 'true' if argument else 'false' -}}\n {%- elif argument is mapping -%}\n {{- '{' -}}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in argument | dictsort -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {%- if escape_keys -%}\n {{- '<|\"|>' + key + '<|\"|>' -}}\n {%- else -%}\n {{- key -}}\n {%- endif -%}\n :{{- format_argument(value, escape_keys=escape_keys) -}}\n {%- endfor -%}\n {{- '}' -}}\n {%- elif argument is iterable -%}\n {{- '[' -}}\n {%- for item in argument -%}\n {{- format_argument(item, escape_keys=escape_keys) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- ']' -}}\n {%- else -%}\n {{- argument -}}\n {%- endif -%}\n{%- endmacro -%}\n\n{%- macro format_parameters(properties, required) -%}\n {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in properties | dictsort -%}\n {%- if key not in standard_keys -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {%- set add_comma = false -%}\n {{ key }}:{\n {%- if value['description'] -%}\n description:<|\"|>{{ value['description'] }}<|\"|>\n {%- set add_comma = true -%}\n {%- endif -%}\n {%- if value['nullable'] -%}\n {%- if add_comma %},{%- endif -%}\n {%- set add_comma = true -%}\n nullable:true\n {%- endif -%}\n {%- if value['type'] and ('string' in value['type'] or 'STRING' in value['type']) -%}\n {%- if value['enum'] -%}\n {%- if add_comma %},{%- endif -%}\n {%- set add_comma = true -%}\n enum:{{ format_argument(value['enum']) }}\n {%- endif -%}\n {%- elif value['type'] and ('object' in value['type'] or 'OBJECT' in value['type']) -%}\n ,properties:{\n {%- if value['properties'] is defined and value['properties'] is mapping -%}\n {{- format_parameters(value['properties'], value['required'] | default([])) -}}\n {%- elif value is mapping -%}\n {{- format_parameters(value, value['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- if value['required'] -%}\n ,required:[\n {%- for item in value['required'] | default([]) -%}\n <|\"|>{{- item -}}<|\"|>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- endif -%}\n {%- elif value['type'] and ('array' in value['type'] or 'ARRAY' in value['type']) -%}\n {%- if value['items'] is defined and value['items'] is mapping and value['items'] -%}\n ,items:{\n {%- set ns_items = namespace(found_first=false) -%}\n {%- for item_key, item_value in value['items'] | dictsort -%}\n {%- if item_value is not none -%}\n {%- if ns_items.found_first %},{% endif -%}\n {%- set ns_items.found_first = true -%}\n {%- if item_key == 'properties' -%}\n properties:{\n {%- if item_value is mapping -%}\n {{- format_parameters(item_value, value['items']['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- elif item_key == 'required' -%}\n required:[\n {%- for req_item in item_value -%}\n <|\"|>{{- req_item -}}<|\"|>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- elif item_key == 'type' -%}\n type:{{ format_type_argument(item_value) }}\n {%- else -%}\n {{ item_key }}:{{ format_argument(item_value) }}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n }\n {%- endif -%}\n {%- endif -%}\n {%- if add_comma %},{%- endif -%}\n type:{{ format_type_argument(value['type']) }}}\n {%- endif -%}\n {%- endfor -%}\n{%- endmacro -%}\n\n{%- macro format_function_declaration(tool_data) -%}\n declaration:{{- tool_data['function']['name'] -}}{description:<|\"|>{{- tool_data['function']['description'] -}}<|\"|>\n {%- set params = tool_data['function']['parameters'] -%}\n {%- if params -%}\n ,parameters:{\n {%- if params['properties'] -%}\n properties:{ {{- format_parameters(params['properties'], params['required'] | default([])) -}} },\n {%- endif -%}\n {%- if params['required'] -%}\n required:[\n {%- for item in params['required'] -%}\n <|\"|>{{- item -}}<|\"|>\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n ],\n {%- endif -%}\n {%- if params['type'] -%}\n type:{{- format_type_argument(params['type']) -}}}\n {%- endif -%}\n {%- endif -%}\n {%- if 'response' in tool_data['function'] -%}\n {%- set response_declaration = tool_data['function']['response'] -%}\n ,response:{\n {%- if response_declaration['description'] -%}\n description:<|\"|>{{- response_declaration['description'] -}}<|\"|>,\n {%- endif -%}\n {%- if response_declaration['type'] and ('object' in response_declaration['type'] or 'OBJECT' in response_declaration['type']) -%}\n type:{{- format_type_argument(response_declaration['type']) -}}}\n {%- endif -%}\n {%- endif -%}\n }\n{%- endmacro -%}\n\n{%- set ns = namespace(prev_role=None, in_model_turn=false) -%}\n{%- set loop_messages = messages -%}\n{{ bos_token }}\n\n{%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}\n {{- '<|turn>system\\n' -}}\n {%- if enable_thinking is defined and enable_thinking -%}\n {{- '<|think|>' -}}\n {%- endif -%}\n {%- if messages[0]['role'] in ['system', 'developer'] -%}\n {{- messages[0]['content'] | trim -}}\n {%- set loop_messages = messages[1:] -%}\n {%- endif -%}\n {%- if tools -%}\n {%- for tool in tools -%}\n {{- '<|tool>' -}}\n {{- format_function_declaration(tool) | trim -}}\n {{- '<tool|>' -}}\n {%- endfor -%}\n {%- endif -%}\n {{- '<turn|>\\n' -}}\n{%- endif -%}\n\n{%- for message in loop_messages -%}\n\n {%- if message['role'] == 'tool' -%}\n {# TOOL RESULT: injected inside the currently open model turn #}\n {{- '<|tool_response>response:' -}}\n {%- if 'name' in message -%}\n {{- message['name'] -}}\n {%- else -%}\n {{- 'tool' -}}\n {%- endif -%}\n {{- '{value:' + message['content'] | string | trim + '}<tool_response|>' -}}\n {%- set ns.prev_role = 'tool' -%}\n\n {%- elif message['role'] == 'assistant' -%}\n {# If coming from a tool response, the model turn is already open #}\n {%- if ns.prev_role != 'tool' -%}\n {{- '<|turn>model\\n' -}}\n {%- endif -%}\n\n {%- if 'tool_calls' in message and message['tool_calls'] -%}\n {%- for tool_call in message['tool_calls'] -%}\n {%- set function = tool_call['function'] -%}\n {{- '<|tool_call>call:' + function['name'] + '{' -}}\n {%- if function['arguments'] is mapping -%}\n {%- set ns_args = namespace(found_first=false) -%}\n {%- for key, value in function['arguments'] | dictsort -%}\n {%- if ns_args.found_first %},{% endif -%}\n {%- set ns_args.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {%- elif function['arguments'] is string -%}\n {{- function['arguments'] -}}\n {%- endif -%}\n {{- '}<tool_call|>' -}}\n {%- endfor -%}\n {# Do NOT close the turn — tool_response comes in the next message #}\n {%- set ns.prev_role = 'assistant_tool_call' -%}\n\n {%- else -%}\n {# Regular assistant message with no tool calls #}\n {%- if message['content'] is string -%}\n {{- strip_thinking(message['content']) -}}\n {%- elif message['content'] is iterable -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'text' -%}\n {{- strip_thinking(item['text']) -}}\n {%- elif item['type'] == 'image' -%}\n {{- '\\n\\n<|image|>\\n\\n' -}}\n {%- elif item['type'] == 'audio' -%}\n {{- '<|audio|>' -}}\n {%- elif item['type'] == 'video' -%}\n {{- '\\n\\n<|video|>\\n\\n' -}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {{- '<turn|>\\n' -}}\n {%- set ns.prev_role = 'assistant' -%}\n {%- endif -%}\n\n {%- else -%}\n {# USER or other roles #}\n {# Close any open model turn (tool_call pending or tool response received) #}\n {%- if ns.prev_role == 'assistant_tool_call' or ns.prev_role == 'tool' -%}\n {{- '<turn|>\\n' -}}\n {%- endif -%}\n {%- set role = message['role'] -%}\n {{- '<|turn>' + role + '\\n' -}}\n {%- if message['content'] is string -%}\n {{- message['content'] | trim -}}\n {%- elif message['content'] is iterable -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'text' -%}\n {{- item['text'] | trim -}}\n {%- elif item['type'] == 'image' -%}\n {{- '\\n\\n<|image|>\\n\\n' -}}\n {%- elif item['type'] == 'audio' -%}\n {{- '<|audio|>' -}}\n {%- elif item['type'] == 'video' -%}\n {{- '\\n\\n<|video|>\\n\\n' -}}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {{- '<turn|>\\n' -}}\n {%- set ns.prev_role = role -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{%- if add_generation_prompt -%}\n {%- if ns.prev_role == 'tool' -%}\n {# Already inside an open model turn, just continue #}\n {%- elif ns.prev_role == 'assistant_tool_call' -%}\n {# Model turn open waiting for tool response, do not close #}\n {%- else -%}\n {{- '<|turn>model\\n' -}}\n {%- endif -%}\n{%- endif -%}"
},
"stopStrings": [
"<turn|>"
]
}