Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: add customizable output instructions for research reports

LearningCircuitef146995a2df
diff --git a/src/local_deep_research/citation_handlers/base_citation_handler.py b/src/local_deep_research/citation_handlers/base_citation_handler.py
index 0fd961196f..fe1066514c 100644
--- a/src/local_deep_research/citation_handlers/base_citation_handler.py
+++ b/src/local_deep_research/citation_handlers/base_citation_handler.py
@@ -25,6 +25,31 @@ class BaseCitationHandler(ABC):
return value
return default
+ def _get_output_instruction_prefix(self) -> str:
+ """
+ Get formatted output instructions from settings if present.
+
+ This allows users to customize output language, tone, style, and formatting
+ for research answers and reports. Instructions are prepended to prompts
+ sent to the LLM.
+
+ Returns:
+ str: Formatted instruction prefix if custom instructions are set,
+ empty string otherwise.
+
+ Examples:
+ - "Respond in Spanish with formal academic tone"
+ - "Use simple language suitable for beginners"
+ - "Be concise with bullet points"
+ """
+ output_instructions = self.get_setting(
+ "general.output_instructions", ""
+ ).strip()
+
+ if output_instructions:
+ return f"IMPORTANT: {output_instructions}\n\n"
+ return ""
+
def _create_documents(
self, search_results: Union[str, List[Dict]], nr_of_links: int = 0
) -> List[Document]:
diff --git a/src/local_deep_research/citation_handlers/forced_answer_citation_handler.py b/src/local_deep_research/citation_handlers/forced_answer_citation_handler.py
index 0d28f2599f..886ec5bf9d 100644
--- a/src/local_deep_research/citation_handlers/forced_answer_citation_handler.py
+++ b/src/local_deep_research/citation_handlers/forced_answer_citation_handler.py
@@ -25,7 +25,9 @@ class ForcedAnswerCitationHandler(BaseCitationHandler):
"%Y-%m-%d %H:%M"
)
- prompt = f"""Analyze the following information and provide a DIRECT answer to the question. Include citations using numbers in square brackets [1], [2], etc.
+ output_prefix = self._get_output_instruction_prefix()
+
+ prompt = f"""{output_prefix}Analyze the following information and provide a DIRECT answer to the question. Include citations using numbers in square brackets [1], [2], etc.
Question: {query}
@@ -90,7 +92,9 @@ Return the most likely answer based on evidence consistency."""
"%Y-%m-%d %H:%M"
)
- prompt = f"""Using the previous knowledge and new sources, provide a DIRECT answer to the question. Include citations using numbers in square brackets.
+ output_prefix = self._get_output_instruction_prefix()
+
+ prompt = f"""{output_prefix}Using the previous knowledge and new sources, provide a DIRECT answer to the question. Include citations using numbers in square brackets.
Previous Knowledge:
{previous_knowledge}
diff --git a/src/local_deep_research/citation_handlers/precision_extraction_handler.py b/src/local_deep_research/citation_handlers/precision_extraction_handler.py
index 67f09b80ce..9890af8fee 100644
--- a/src/local_deep_research/citation_handlers/precision_extraction_handler.py
+++ b/src/local_deep_research/citation_handlers/precision_extraction_handler.py
@@ -54,7 +54,9 @@ class PrecisionExtractionHandler(BaseCitationHandler):
"%Y-%m-%d %H:%M"
)
- prompt = f"""Analyze the following information and provide a PRECISE answer to the question. Include citations using numbers in square brackets [1], [2], etc.
+ output_prefix = self._get_output_instruction_prefix()
+
+ prompt = f"""{output_prefix}Analyze the following information and provide a PRECISE answer to the question. Include citations using numbers in square brackets [1], [2], etc.
Question: {query}
Question Type: {question_type}
@@ -107,7 +109,9 @@ Format: Start with the direct, precise answer, then explain with citations."""
"%Y-%m-%d %H:%M"
)
- prompt = f"""Using the previous knowledge and new sources, provide a PRECISE answer to the question.
+ output_prefix = self._get_output_instruction_prefix()
+
+ prompt = f"""{output_prefix}Using the previous knowledge and new sources, provide a PRECISE answer to the question.
Previous Key Facts:
{key_facts}
diff --git a/src/local_deep_research/citation_handlers/standard_citation_handler.py b/src/local_deep_research/citation_handlers/standard_citation_handler.py
index 4901d78ee7..ca514ed619 100644
--- a/src/local_deep_research/citation_handlers/standard_citation_handler.py
+++ b/src/local_deep_research/citation_handlers/standard_citation_handler.py
@@ -20,7 +20,9 @@ class StandardCitationHandler(BaseCitationHandler):
"%Y-%m-%d %H:%M"
)
- prompt = f"""Analyze the following information concerning the question and include citations using numbers in square brackets [1], [2], etc. When citing, use the source number provided at the start of each source.
+ output_prefix = self._get_output_instruction_prefix()
+
+ prompt = f"""{output_prefix}Analyze the following information concerning the question and include citations using numbers in square brackets [1], [2], etc. When citing, use the source number provided at the start of each source.
Question: {query}
@@ -73,7 +75,9 @@ New Sources:
"%Y-%m-%d %H:%M"
)
- prompt = f"""Using the previous knowledge and new sources, answer the question. Include citations using numbers in square brackets [1], [2], etc. When citing, use the source number provided at the start of each source. Reflect information from sources critically.
+ output_prefix = self._get_output_instruction_prefix()
+
+ prompt = f"""{output_prefix}Using the previous knowledge and new sources, answer the question. Include citations using numbers in square brackets [1], [2], etc. When citing, use the source number provided at the start of each source. Reflect information from sources critically.
Previous Knowledge:
{previous_knowledge}
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index 5ef3b2732a..30738dc318 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -1727,6 +1727,21 @@
"value": "research_outputs",
"visible": true
},
+ "general.output_instructions": {
+ "category": "general",
+ "description": "Custom instructions for how research answers and reports should be formatted. You can specify language (e.g., 'Respond in Spanish'), tone (e.g., 'Use formal academic tone'), style (e.g., 'Be concise with bullet points'), or any combination. Leave empty for default English output. Examples: 'Respond in Spanish with formal tone' | 'Use simple language suitable for beginners' | 'Write in Japanese using technical terminology'",
+ "editable": true,
+ "max_value": null,
+ "min_value": null,
+ "name": "Output Instructions",
+ "options": null,
+ "placeholder": "Example: Respond in Spanish using formal academic tone",
+ "step": null,
+ "type": "APP",
+ "ui_element": "textarea",
+ "value": "",
+ "visible": true
+ },
"search.engine.web.github.display_name": {
"category": "github",
"description": "Display name to use in the U.I. for this search engine.",