Skip to content

Self-hosted AI workspace.

Python

fix: respect user round count in deep research (#2896)

michaelxerf07bf99236e1
diff --git a/src/deep_research.py b/src/deep_research.py
index 7a314229b..204de7217 100644
--- a/src/deep_research.py
+++ b/src/deep_research.py
@@ -107,7 +107,7 @@ You are deciding whether a research report is comprehensive enough.
**Current report:**
{report}
-**Rounds completed:** {round_num}
+**Rounds completed:** {round_num} of {max_rounds}
Based on the report so far, do we have enough information to answer the question \
comprehensively? Consider:
@@ -115,6 +115,9 @@ comprehensively? Consider:
- Are there obvious gaps or unanswered sub-questions?
- Is the evidence sufficient and from multiple sources?
+If rounds completed is well below the target, prefer continuing unless the \
+report is already exhaustive.
+
Reply with ONLY "YES" or "NO" followed by a brief one-sentence reason.
Example: "YES — The report covers all major aspects with evidence from multiple sources."
Example: "NO — We still lack information about the economic impact."
@@ -698,6 +701,7 @@ class DeepResearcher:
question=question,
report=report,
round_num=round_num,
+ max_rounds=self.max_rounds,
)
try:
diff --git a/src/research_handler.py b/src/research_handler.py
index 4a721cd5e..70433b61b 100644
--- a/src/research_handler.py
+++ b/src/research_handler.py
@@ -777,7 +777,7 @@ class ResearchHandler:
llm_model=llm_model,
llm_headers=llm_headers,
max_rounds=max_rounds,
- min_rounds=min(3, max_rounds),
+ min_rounds=max(2, max_rounds - 2),
max_time=max_time,
max_report_tokens=_max_report_tokens,
extraction_timeout=_extraction_timeout,