@@ -53,27 +53,31 @@ def __init__(
5353 openai_api_base = summary_base_url if summary_base_url is not None else base_url ,
5454 max_retries = 3 ,
5555 temperature = 0.01 ,
56+ max_tokens = 800 ,
5657 )
5758 self .research_model = ChatOpenAI (
5859 model_name = research_model ,
5960 openai_api_key = research_key if research_key is not None else key ,
6061 openai_api_base = research_base_url if research_base_url is not None else base_url ,
6162 max_retries = 3 ,
6263 temperature = 0.01 ,
64+ max_tokens = 1200 ,
6365 )
6466 self .compression_model = ChatOpenAI (
6567 model_name = compression_model ,
6668 openai_api_key = compression_key if compression_key is not None else key ,
6769 openai_api_base = compression_base_url if compression_base_url is not None else base_url ,
6870 max_retries = 3 ,
6971 temperature = 0.01 ,
72+ max_tokens = 600 ,
7073 )
7174 self .final_model = ChatOpenAI (
7275 model_name = final_model ,
7376 openai_api_key = final_key if final_key is not None else key ,
7477 openai_api_base = final_base_url if final_base_url is not None else base_url ,
7578 max_retries = 3 ,
7679 temperature = 0.01 ,
80+ max_tokens = 1600 ,
7781 )
7882 # Caution: PythonREPL can execute arbitrary code on the host machine.
7983 # Use with caution and consider sandboxing for untrusted inputs.
@@ -110,6 +114,15 @@ def _create_research_chain(self) -> RunnableSerializable[dict[str, Any], str]:
110114 prompt = PromptTemplate (
111115 input_variables = ["context" , "question" ],
112116 template = """Generate a comprehensive research report based on the provided context.
117+ The report should be long-form (800-1200 words) and include the sections:
118+ - Executive Summary
119+ - Key Findings
120+ - Evidence (quote or paraphrase context with attributions)
121+ - Limitations and Uncertainties
122+ - Conclusion
123+
124+ Explain reasoning explicitly in prose. Prefer depth over breadth.
125+
113126Context: {context}
114127Question: {question}
115128Research Report:
@@ -171,7 +184,13 @@ def _build_agent_chain() -> RunnableSerializable[dict[str, Any], str]:
171184 "- description: A Python shell for executing Python commands.\n "
172185 "- note: Print values to see output, e.g., `print(...)`.\n "
173186 "- args: keys: 'code' (string: valid python command).\n \n "
174- "Follow an iterative think-act-observe loop until you have enough information to answer.\n "
187+ "Follow an iterative think-act-observe loop. "
188+ "Prefer rich internal reasoning over issuing many tool calls.\n "
189+ "Spend time thinking: produce substantial, explicit reasoning in each 'thought'.\n "
190+ "Avoid giving a final answer too early. Aim for at least 6 detailed thoughts before finalizing,\n "
191+ "unless the question is truly trivial. "
192+ "If no tool use is needed in a step, still provide a reflective 'thought'\n "
193+ "that evaluates evidence, identifies gaps, and plans the next step.\n \n "
175194 "Always respond in strict JSON. Use one of the two schemas:\n \n "
176195 "1) Action step (JSON keys shown with dot-paths):\n "
177196 "- thought: string\n "
@@ -181,7 +200,11 @@ def _build_agent_chain() -> RunnableSerializable[dict[str, Any], str]:
181200 "2) Final answer step:\n "
182201 "- thought: string\n "
183202 "- final_answer: string\n \n "
184- "When producing final_answer, write a structured research report with sections:\n "
203+ "In every step, make 'thought' a detailed paragraph (120-200 words) that:\n "
204+ "- Summarizes what is known and unknown so far\n "
205+ "- Justifies the chosen next action or decision not to act\n "
206+ "- Evaluates evidence quality and cites source numbers when applicable\n "
207+ "- Identifies risks, uncertainties, and alternative hypotheses\n \n "
185208 "Executive Summary, Key Findings, Evidence, Limitations, Conclusion.\n "
186209 "Use inline numeric citations like [1], [2] that refer to Sources.\n "
187210 "Include a final section titled 'Sources' listing the numbered citations.\n \n "
@@ -425,7 +448,16 @@ async def aembed_query(self, text: str) -> list[float]:
425448 deep_researcher = DeepResearchLangchain (** config .deep_research .kwargs , websearch = websearch )
426449
427450 # Create a dummy request.
428- dummy_messages = [{"role" : "user" , "content" : "What is the purpose of subnet 1 in Bittensor?" }]
451+ dummy_messages = [
452+ {
453+ "role" : "user" ,
454+ "content" : """In the study of convex sets, why might two closed convex sets fail to have a strictly
455+ separating hyperplane, even if they are disjoint? What geometric or topological properties could
456+ prevent strict separation, and how does this contrast
457+ with the case where strict separation is possible? Can you provide an intuitive example where such
458+ a scenario occurs, and explain the underlying reasoning?""" ,
459+ }
460+ ]
429461 dummy_body : dict [str , Any ] = {}
430462
431463 # Run the invoke method.
0 commit comments