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.

fix(langgraph): default search.fetch.mode to summary_focus_query (#3793)

LearningCircuitb95442a51d56
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.py
index 497ae3d816..6c2280d208 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
@@ -243,7 +243,7 @@ def _make_research_subtopic_tool(
max_sub_iterations: int,
progress_callback=None,
programmatic_mode: bool = False,
- fetch_mode: str = "full",
+ fetch_mode: str = "summary_focus_query",
overall_query: str = "",
):
"""Create the ``research_subtopic`` tool that spawns parallel subagents.
@@ -426,13 +426,15 @@ class LangGraphAgentStrategy(BaseSearchStrategy):
)
self.collector = SearchResultsCollector(self.all_links_of_system)
- fetch_mode = self.get_setting("search.fetch.mode", "full")
+ fetch_mode = self.get_setting(
+ "search.fetch.mode", "summary_focus_query"
+ )
if fetch_mode not in FETCH_MODES:
logger.warning(
- f"Unknown search.fetch.mode={fetch_mode!r}, falling back to 'full'. "
- f"Valid modes: {FETCH_MODES}"
+ f"Unknown search.fetch.mode={fetch_mode!r}, falling back to "
+ f"'summary_focus_query'. Valid modes: {FETCH_MODES}"
)
- fetch_mode = "full"
+ fetch_mode = "summary_focus_query"
self.fetch_mode = fetch_mode
logger.info(f"LangGraph agent fetch_mode={self.fetch_mode}")
diff --git a/src/local_deep_research/database/migrations/versions/0009_default_fetch_mode_summary.py b/src/local_deep_research/database/migrations/versions/0009_default_fetch_mode_summary.py
new file mode 100644
index 0000000000..f8fd04a811
--- /dev/null
+++ b/src/local_deep_research/database/migrations/versions/0009_default_fetch_mode_summary.py
@@ -0,0 +1,107 @@
+"""Switch default search.fetch.mode from 'full' to 'summary_focus_query'.
+
+Background
+==========
+PR #3680 (v1.6.3) introduced the ``search.fetch.mode`` setting with a
+default of ``"full"``. ``full`` returns every page's complete extracted
+text to the LangGraph agent. With small-to-mid local models (e.g.
+qwen3.6:27b at 20480 ctx) this floods the context with boilerplate and
+metadata, simultaneously slowing each example down (~60% in our SimpleQA
+runs) and dropping accuracy (95.7% → ~80% on a 25-example sample).
+
+The new default ``summary_focus_query`` asks the model to extract only
+spans relevant to the agent's per-fetch focus question AND the original
+research query, keeping the context lean.
+
+What this migration does
+========================
+Updates rows where ``key = 'search.fetch.mode'`` AND the stored value is
+exactly ``"full"``. Users who explicitly chose ``summary_focus``,
+``summary_focus_query``, or ``disabled`` are left untouched. Users who
+deliberately picked ``full`` will find their preference flipped — they
+can re-select ``Full Page Text`` from the settings UI; this is the
+intentional cost of fixing a poor default that almost everyone inherited
+without choosing it.
+
+Storage note: the ``value`` column uses SQLAlchemy's ``JSON`` type, which
+serializes Python strings via ``json.dumps`` and stores them as TEXT.
+The on-disk representation of the string ``full`` is the 6-character
+literal ``"full"`` (with the surrounding quotes), so the WHERE clause
+matches on that exact form.
+
+Revision ID: 0009
+Revises: 0008
+Create Date: 2026-05-02
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+from loguru import logger
+from sqlalchemy import inspect
+
+revision = "0009"
+down_revision = "0008"
+branch_labels = None
+depends_on = None
+
+SETTING_KEY = "search.fetch.mode"
+OLD_VALUE_JSON = '"full"'
+NEW_VALUE_JSON = '"summary_focus_query"'
+
+
+def upgrade() -> None:
+ conn = op.get_bind()
+
+ inspector = inspect(conn)
+ if not inspector.has_table("settings"):
+ return
+
+ result = conn.execute(
+ sa.text(
+ "UPDATE settings SET value = :new_value "
+ "WHERE key = :key AND value = :old_value"
+ ),
+ {
+ "new_value": NEW_VALUE_JSON,
+ "key": SETTING_KEY,
+ "old_value": OLD_VALUE_JSON,
+ },
+ )
+
+ if result.rowcount:
+ logger.info(
+ "Migrated {} setting(s) {!r} from 'full' to 'summary_focus_query'.",
+ result.rowcount,
+ SETTING_KEY,
+ )
+
+
+def downgrade() -> None:
+ """Revert previously-migrated rows back to 'full'.
+
+ Only rows whose value is currently ``"summary_focus_query"`` are
+ reverted — leaves any user choice of ``summary_focus`` or
+ ``disabled`` alone. Rows that already held ``summary_focus_query``
+ before the upgrade are indistinguishable from migrated rows; the
+ downgrade conservatively reverts them as well, since the
+ pre-upgrade state stored ``"full"`` as the default.
+ """
+ conn = op.get_bind()
+
+ inspector = inspect(conn)
+ if not inspector.has_table("settings"):
+ return
+
+ conn.execute(
+ sa.text(
+ "UPDATE settings SET value = :old_value "
+ "WHERE key = :key AND value = :new_value"
+ ),
+ {
+ "old_value": OLD_VALUE_JSON,
+ "key": SETTING_KEY,
+ "new_value": NEW_VALUE_JSON,
+ },
+ )
diff --git a/src/local_deep_research/defaults/default_settings.json b/src/local_deep_research/defaults/default_settings.json
index b531ac7bab..8f2a149d85 100644
--- a/src/local_deep_research/defaults/default_settings.json
+++ b/src/local_deep_research/defaults/default_settings.json
@@ -773,23 +773,23 @@
},
"search.fetch.mode": {
"category": "search_parameters",
- "description": "Controls the LangGraph agent's fetch_content tool. 'full' returns the entire extracted page text (current behavior; can flood small-model context with boilerplate/metadata). 'summary_focus' makes the tool ask the LLM to extract only spans relevant to a focus question the agent supplies per call. 'summary_focus_query' is the same but also includes the original research query in the extraction prompt, so a vague focus can be disambiguated. 'disabled' removes the tool entirely so the agent works from search snippets only — useful for diagnosing whether full-page fetching is hurting accuracy.",
+ "description": "Controls the LangGraph agent's fetch_content tool. 'summary_focus_query' (default) asks the LLM to extract only spans relevant to a focus question the agent supplies per call AND the original research query, so vague focus can be disambiguated — keeps small-model context clean. 'summary_focus' is the same but uses only the per-call focus question. 'full' returns the entire extracted page text (legacy behavior; can flood small-model context with boilerplate/metadata and degrade benchmark accuracy). 'disabled' removes the tool entirely so the agent works from search snippets only — useful for diagnosing whether fetching is helping or hurting accuracy.",
"editable": true,
"max_value": null,
"min_value": null,
"name": "Fetch Content Mode",
"options": [
{
- "label": "Full Page Text",
- "value": "full"
+ "label": "Focused Summary (Page-Specific Question + Overall Query)",
+ "value": "summary_focus_query"
},
{
"label": "Focused Summary (Page-Specific Question Only)",
"value": "summary_focus"
},
{
- "label": "Focused Summary (Page-Specific Question + Overall Query)",
- "value": "summary_focus_query"
+ "label": "Full Page Text",
+ "value": "full"
},
{
"label": "Disabled (Snippets Only)",
@@ -799,7 +799,7 @@
"step": null,
"type": "SEARCH",
"ui_element": "select",
- "value": "full",
+ "value": "summary_focus_query",
"visible": true
},
"search.iterations": {
diff --git a/tests/database/test_alembic_migrations.py b/tests/database/test_alembic_migrations.py
index 6cbdc28c7f..9a3f355f2f 100644
--- a/tests/database/test_alembic_migrations.py
+++ b/tests/database/test_alembic_migrations.py
@@ -660,6 +660,7 @@ class TestMigrationChain:
"0006_journal_quality_system.py",
"0007_backfill_missing_indexes.py",
"0008_fix_research_strategy_fk.py",
+ "0009_default_fetch_mode_summary.py",
]
for filename in expected_files:
@@ -686,7 +687,10 @@ class TestMigrationChain:
# Head should be the latest migration
assert script.get_current_head() == get_head_revision()
- # Verify chain link 0008 -> 0007 (the rest of the chain is checked below).
+ # Verify chain link 0009 -> 0008 (the rest of the chain is checked below).
+ rev_0009 = script.get_revision("0009")
+ assert rev_0009.down_revision == "0008"
+
rev_0008 = script.get_revision("0008")
assert rev_0008.down_revision == "0007"
diff --git a/tests/database/test_migration_0009_default_fetch_mode.py b/tests/database/test_migration_0009_default_fetch_mode.py
new file mode 100644
index 0000000000..46871457d8
--- /dev/null
+++ b/tests/database/test_migration_0009_default_fetch_mode.py
@@ -0,0 +1,201 @@
+"""Tests for migration 0009: default search.fetch.mode 'full' → 'summary_focus_query'.
+
+Pins the upgrade/downgrade semantics:
+- Rows with the legacy default ``"full"`` get flipped.
+- Rows users explicitly chose (``summary_focus``, ``summary_focus_query``,
+ ``disabled``) are left untouched.
+- Other settings keys with value ``"full"`` are not affected.
+- Idempotency: a second upgrade is a no-op once values are migrated.
+
+The on-disk encoding is JSON-text (``"full"`` with the surrounding
+quotes), so the test inserts through SQLAlchemy's JSON column type to
+match production storage exactly.
+"""
+
+import json
+
+import pytest
+from alembic import command
+from sqlalchemy import create_engine, text
+
+from local_deep_research.database.alembic_runner import (
+ get_alembic_config,
+ get_head_revision,
+)
+
+
+def _run_upgrade_to(engine, revision):
+ config = get_alembic_config(engine)
+ with engine.begin() as conn:
+ config.attributes["connection"] = conn
+ command.upgrade(config, revision)
+
+
+def _run_downgrade_to(engine, revision):
+ config = get_alembic_config(engine)
+ with engine.begin() as conn:
+ config.attributes["connection"] = conn
+ command.downgrade(config, revision)
+
+
+def _seed_setting(engine, key, value):
+ """Insert a setting matching production's JSON-text storage.
+
+ SQLAlchemy's JSON column writes ``json.dumps(value)``; we mirror that
+ explicitly so raw SQL produces the same on-disk bytes the migration
+ expects to match in its WHERE clause.
+ """
+ with engine.begin() as conn:
+ conn.execute(
+ text(
+ "INSERT INTO settings "
+ "(key, value, type, name, ui_element, visible, editable) "
+ "VALUES (:key, :value, 'search', :name, 'select', 1, 1)"
+ ),
+ {"key": key, "value": json.dumps(value), "name": key},
+ )
+
+
+def _read_setting(engine, key):
+ with engine.begin() as conn:
+ row = conn.execute(
+ text("SELECT value FROM settings WHERE key = :key"),
+ {"key": key},
+ ).fetchone()
+ if row is None:
+ return None
+ raw = row[0]
+ # JSON column round-trips through json.loads on read, but raw text()
+ # bypasses the column type — so decode manually.
+ return json.loads(raw) if isinstance(raw, str) else raw
+
+
+def migrated_to_0008_engine(tmp_path):
+ """Database fully migrated through 0008 (the revision before 0009)."""
+ db_path = tmp_path / "test_0009.db"
+ engine = create_engine(f"sqlite:///{db_path}")
+ _run_upgrade_to(engine, "0008")
+ yield engine
+ engine.dispose()
+
+
+class TestMigration0009Upgrade:
+ def test_full_value_is_migrated_to_summary_focus_query(
+ self, migrated_to_0008_engine
+ ):
+ engine = migrated_to_0008_engine
+
+ with engine.begin() as conn:
+ conn.execute(
+ text("DELETE FROM settings WHERE key = 'search.fetch.mode'")
+ )
+ _seed_setting(engine, "search.fetch.mode", "full")
+
+ _run_upgrade_to(engine, "0009")
+
+ assert (
+ _read_setting(engine, "search.fetch.mode") == "summary_focus_query"
+ )
+
+ @pytest.mark.parametrize(
+ "explicit_value",
+ ["summary_focus", "summary_focus_query", "disabled"],
+ )
+ def test_explicit_non_full_choices_are_preserved(
+ self, migrated_to_0008_engine, explicit_value
+ ):
+ engine = migrated_to_0008_engine
+
+ with engine.begin() as conn:
+ conn.execute(
+ text("DELETE FROM settings WHERE key = 'search.fetch.mode'")
+ )
+ _seed_setting(engine, "search.fetch.mode", explicit_value)
+
+ _run_upgrade_to(engine, "0009")
+
+ assert _read_setting(engine, "search.fetch.mode") == explicit_value
+
+ def test_other_keys_with_full_value_are_not_touched(
+ self, migrated_to_0008_engine
+ ):
+ engine = migrated_to_0008_engine
+
+ # An unrelated key that happens to hold 'full' must not be flipped.
+ _seed_setting(engine, "test.unrelated.mode", "full")
+
+ _run_upgrade_to(engine, "0009")
+
+ assert _read_setting(engine, "test.unrelated.mode") == "full"
+
+ def test_upgrade_is_idempotent(self, migrated_to_0008_engine):
+ """Running the upgrade a second time is a no-op (already at head)."""
+ engine = migrated_to_0008_engine
+
+ with engine.begin() as conn:
+ conn.execute(
+ text("DELETE FROM settings WHERE key = 'search.fetch.mode'")
+ )
+ _seed_setting(engine, "search.fetch.mode", "full")
+
+ _run_upgrade_to(engine, "0009")
+ # Second invocation: nothing left to do; alembic short-circuits.
+ _run_upgrade_to(engine, "0009")
+
+ assert (
+ _read_setting(engine, "search.fetch.mode") == "summary_focus_query"
+ )
+
+ def test_no_settings_row_does_not_error(self, migrated_to_0008_engine):
+ """If the row never existed, the migration is a clean no-op."""
+ engine = migrated_to_0008_engine
+
+ with engine.begin() as conn:
+ conn.execute(
+ text("DELETE FROM settings WHERE key = 'search.fetch.mode'")
+ )
+
+ _run_upgrade_to(engine, "0009")
+
+ assert _read_setting(engine, "search.fetch.mode") is None
+
+
+class TestMigration0009Downgrade:
+ def test_downgrade_reverts_summary_focus_query_to_full(
+ self, migrated_to_0008_engine
+ ):
+ engine = migrated_to_0008_engine
+
+ with engine.begin() as conn:
+ conn.execute(
+ text("DELETE FROM settings WHERE key = 'search.fetch.mode'")
+ )
+ _seed_setting(engine, "search.fetch.mode", "full")
+
+ _run_upgrade_to(engine, "0009")
+ _run_downgrade_to(engine, "0008")
+
+ assert _read_setting(engine, "search.fetch.mode") == "full"
+
+ @pytest.mark.parametrize("preserved_value", ["summary_focus", "disabled"])
+ def test_downgrade_preserves_other_explicit_choices(
+ self, migrated_to_0008_engine, preserved_value
+ ):
+ engine = migrated_to_0008_engine
+
+ with engine.begin() as conn:
+ conn.execute(
+ text("DELETE FROM settings WHERE key = 'search.fetch.mode'")
+ )
+ _seed_setting(engine, "search.fetch.mode", preserved_value)
+
+ _run_upgrade_to(engine, "0009")
+ _run_downgrade_to(engine, "0008")
+
+ assert _read_setting(engine, "search.fetch.mode") == preserved_value
+
+
+class TestMigration0009HeadAlignment:
+ def test_head_revision_is_0009(self):
+ assert get_head_revision() == "0009"
diff --git a/tests/settings/golden_master_settings.json b/tests/settings/golden_master_settings.json
index 711c95da59..174edc8b30 100644
--- a/tests/settings/golden_master_settings.json
+++ b/tests/settings/golden_master_settings.json
@@ -7224,23 +7224,23 @@
},
"search.fetch.mode": {
"category": "search_parameters",
- "description": "Controls the LangGraph agent's fetch_content tool. 'full' returns the entire extracted page text (current behavior; can flood small-model context with boilerplate/metadata). 'summary_focus' makes the tool ask the LLM to extract only spans relevant to a focus question the agent supplies per call. 'summary_focus_query' is the same but also includes the original research query in the extraction prompt, so a vague focus can be disambiguated. 'disabled' removes the tool entirely so the agent works from search snippets only — useful for diagnosing whether full-page fetching is hurting accuracy.",
+ "description": "Controls the LangGraph agent's fetch_content tool. 'summary_focus_query' (default) asks the LLM to extract only spans relevant to a focus question the agent supplies per call AND the original research query, so vague focus can be disambiguated — keeps small-model context clean. 'summary_focus' is the same but uses only the per-call focus question. 'full' returns the entire extracted page text (legacy behavior; can flood small-model context with boilerplate/metadata and degrade benchmark accuracy). 'disabled' removes the tool entirely so the agent works from search snippets only — useful for diagnosing whether fetching is helping or hurting accuracy.",
"editable": true,
"max_value": null,
"min_value": null,
"name": "Fetch Content Mode",
"options": [
{
- "label": "Full Page Text",
- "value": "full"
+ "label": "Focused Summary (Page-Specific Question + Overall Query)",
+ "value": "summary_focus_query"
},
{
"label": "Focused Summary (Page-Specific Question Only)",
"value": "summary_focus"
},
{
- "label": "Focused Summary (Page-Specific Question + Overall Query)",
- "value": "summary_focus_query"
+ "label": "Full Page Text",
+ "value": "full"
},
{
"label": "Disabled (Snippets Only)",
@@ -7250,7 +7250,7 @@
"step": null,
"type": "SEARCH",
"ui_element": "select",
- "value": "full",
+ "value": "summary_focus_query",
"visible": true
},
"search.final_max_results": {