Skip to content

Commit 033b63e

Browse files
committed
Align early stop prompt with final
1 parent 21f51f0 commit 033b63e

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

apex/services/deep_research/deep_research_langchain.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525

2626

2727
class DeepResearchLangchain(DeepResearchBase):
28+
_FINAL_ANSWER_INST = (
29+
"You are a senior interdisciplinary researcher with expertise across "
30+
"science, technology, humanities, and social sciences.\n"
31+
"Provide report only in plain text using natural language.\n"
32+
"Write your response in the form of a well-structured research report with sections:\n"
33+
"Executive Summary, Key Findings, Evidence, Limitations, Conclusion.\n"
34+
"Use inline numeric citations like [1], [2] that refer to Sources.\n"
35+
"At the end, include a 'Sources' section listing the numbered citations.\n\n"
36+
)
37+
2838
def __init__(
2939
self,
3040
key: str,
@@ -142,6 +152,7 @@ async def invoke(
142152
reasoning_traces: list[dict[str, Any]] = []
143153

144154
question = messages[-1]["content"]
155+
question = self._FINAL_ANSWER_INST + question
145156

146157
# Seed notes with any provided documents
147158
notes: list[str] = []
@@ -297,14 +308,7 @@ async def invoke(
297308
final_prompt = PromptTemplate(
298309
input_variables=["question", "notes", "sources"],
299310
template=(
300-
"You are a senior interdisciplinary researcher with expertise across "
301-
"science, technology, humanities, and social sciences.\n"
302-
"Provide report only in plain text using natural language.\n"
303-
"Write your response in the form of a well-structured research report with sections:\n"
304-
"Executive Summary, Key Findings, Evidence, Limitations, Conclusion.\n"
305-
"Use inline numeric citations like [1], [2] that refer to Sources.\n"
306-
"At the end, include a 'Sources' section listing the numbered citations.\n\n"
307-
"Do NOT use JSON, or any other structured data format.\n"
311+
self._FINAL_ANSWER_INST + "Do NOT use JSON, or any other structured data format.\n"
308312
"Question:\n{question}\n\n"
309313
"Notes:\n{notes}\n\n"
310314
"Sources:\n{sources}\n\n"

apex/validator/generate_reference.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ async def generate_reference(
2626
}
2727
user_message: dict[str, str] = {
2828
"role": "user",
29-
"content": (
30-
f"Research Question: {query}\n\n"
31-
"Please think through the answer carefully, annotate each step with citations like [1], [2], etc., "
32-
'and conclude with a "Sources:" list mapping each [n] to its source URL or title.'
33-
),
29+
"content": query,
3430
}
3531

3632
response, tool_history, reasoning_traces = await llm.invoke([system_message, user_message])

0 commit comments

Comments
 (0)