~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat(langgraph): emit a progress milestone when an oversized subtopic batch is rejected (#6631)
LearningCircuit3608fa665818
diff --git a/changelog.d/5584.feature.md b/changelog.d/5584.feature.mdnew file mode 100644index 0000000000..6107458ca9--- /dev/null+++ b/changelog.d/5584.feature.md@@ -0,0 +1 @@+When a subtopic batch exceeds the hard limit, `research_subtopic` now emits a dedicated, count-only progress milestone (e.g. "Rejected batch of 11 subtopics (hard limit 10)", metadata `overflow_strategy: rejected`) in addition to its existing error reply, matching the milestone the queued-overflow path already emits for accepted batches. The rejection was already visible in the progress stream via the tool's observation event ("From subtopic researcher: Error: …") and in the logs; this gives progress consumers a consistent, structured milestone for both outcomes instead of only the queued-overflow path having one.diff --git a/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.py b/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.pyindex 5de90239f9..179bdbae3c 100644--- a/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.py+++ b/src/local_deep_research/advanced_search_system/strategies/langgraph_agent_strategy.py@@ -1556,6 +1556,25 @@ def _make_research_subtopic_tool(requested_count,MAX_SUBTOPICS_HARD_LIMIT,)+ # The rejection is already visible via the observation-event+ # milestone built from this tool's return text (see+ # _observation_event: "From subtopic researcher: Error: ...").+ # This adds a dedicated, count-only milestone with structured+ # metadata (overflow_strategy: rejected) matching the+ # queued-overflow path below, so progress consumers get a+ # consistent milestone for both outcomes (#5584). Counts+ # only — never echo subtopic content.+ if progress_callback:+ progress_callback(+ f"Rejected batch of {requested_count} subtopics "+ f"(hard limit {MAX_SUBTOPICS_HARD_LIMIT})",+ None,+ {+ "phase": "sub_research",+ "type": "milestone",+ "overflow_strategy": "rejected",+ },+ )return (f"Error: research_subtopic received {requested_count} subtopics, "f"above the hard limit of {MAX_SUBTOPICS_HARD_LIMIT}. No "diff --git a/tests/strategies/test_langgraph_agent_strategy.py b/tests/strategies/test_langgraph_agent_strategy.pyindex 033ae76c8e..999eddd5f8 100644--- a/tests/strategies/test_langgraph_agent_strategy.py+++ b/tests/strategies/test_langgraph_agent_strategy.py@@ -5599,7 +5599,9 @@ class TestResearchSubtopicToolOverflow:result = tool.invoke({"subtopics": subtopics})create_agent.assert_not_called()- progress_callback.assert_not_called()+ # The rejection milestone IS emitted (see the dedicated test+ # below) — exactly one progress event, nothing else.+ progress_callback.assert_called_once()log.warning.assert_called_once()assert f"received {len(subtopics)} subtopics" in resultassert f"hard limit of {MAX_SUBTOPICS_HARD_LIMIT}" in result@@ -5607,6 +5609,45 @@ class TestResearchSubtopicToolOverflow:assert f"batches of at most {preferred_limit}" in resultassert "## topic 0" not in result+ def test_hard_limit_rejection_emits_progress_milestone(self):+ """A rejected oversized batch gets a dedicated progress milestone.++ The rejection itself already reaches progress consumers via the+ tool's observation event (the returned error text is logged as+ "From subtopic researcher: Error: ..."); this milestone is a+ second, count-only signal with structured metadata that matches+ the shape the queued-overflow path already emits (#5584).+ """+ from local_deep_research.advanced_search_system.strategies.langgraph_agent_strategy import (+ MAX_SUBTOPICS_HARD_LIMIT,+ )++ progress_callback = MagicMock()+ tool, _ = self._make_tool(progress_callback=progress_callback)+ secret = "private topic"+ subtopics = [secret] * (MAX_SUBTOPICS_HARD_LIMIT + 1)++ result = tool.invoke({"subtopics": subtopics})++ progress_callback.assert_called_once()+ message, payload, meta = progress_callback.call_args.args+ assert "Rejected batch" in message+ assert str(len(subtopics)) in message+ assert str(MAX_SUBTOPICS_HARD_LIMIT) in message+ assert payload is None+ assert meta["phase"] == "sub_research"+ assert meta["type"] == "milestone"+ assert meta["overflow_strategy"] == "rejected"+ # Counts only — the milestone never echoes subtopic content,+ # not even in the metadata dict (the queued-overflow path's+ # milestone puts the full subtopic list in meta["subtopics"];+ # the rejection milestone must not).+ assert secret not in message+ assert "subtopics" not in meta+ assert secret not in repr(meta)+ # The lead agent still gets the split-into-batches guidance.+ assert "Split the request into batches" in result+def test_hard_limit_rejection_does_not_echo_subtopic_content(self):from local_deep_research.advanced_search_system.strategies.langgraph_agent_strategy import (MAX_SUBTOPICS_HARD_LIMIT,