~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
fix(research): persist Stop entries in progress logs (#7031)
LearningCircuit189d72ea13b1
diff --git a/changelog.d/+termination-log-persistence.bugfix.md b/changelog.d/+termination-log-persistence.bugfix.mdnew file mode 100644index 0000000000..b2c379e4ff--- /dev/null+++ b/changelog.d/+termination-log-persistence.bugfix.md@@ -0,0 +1 @@+Persist the termination entry when stopping a research run whose progress log is already a JSON list. The entry now survives database reloads; malformed legacy logs remain recoverable.diff --git a/src/local_deep_research/web/routers/research.py b/src/local_deep_research/web/routers/research.pyindex a7d263645b..80af450fd1 100644--- a/src/local_deep_research/web/routers/research.py+++ b/src/local_deep_research/web/routers/research.py@@ -1764,8 +1764,8 @@ def terminate_research()current_log = []- current_log.append(log_entry)- research.progress_log = current_log+ # Assign a new value so SQLAlchemy sees the JSON column change.+ research.progress_log = [*current_log, log_entry]research.status = ResearchStatus.SUSPENDEDdb_session.commit()diff --git a/tests/web/routers/test_research_mutating_route_effects.py b/tests/web/routers/test_research_mutating_route_effects.pyindex 372315691d..f40381197b 100644--- a/tests/web/routers/test_research_mutating_route_effects.py+++ b/tests/web/routers/test_research_mutating_route_effects.py@@ -20,8 +20,8 @@ The specific holes each test closes:``~claimed_queue_row`` guard is pinned; the early return can be removedon its own and stay green.* **``terminate_research``'s ``progress_log`` handling and its- spawn-grace boundary.** The JSON-string parse and the- "cleanup runs only in the QUEUED arm" negative have no coverage at all.+ spawn-grace boundary.** The JSON-string parse, healthy-list persistence,+ and "cleanup runs only in the QUEUED arm" negative need real row checks.* **``get_history``'s item payload.** Not one field of the listing isasserted anywhere on the branch.* **``get_research_report``'s ``None``-vs-``""`` distinction.** Pinned for@@ -271,6 +271,7 @@ def test_terminate_parses_a_progress_log_stored_as_a_json_string(patch.stopall()assert response.status_code == 200, response.text[:300]+ db.expire_all()assert isinstance(row.progress_log, list)assert len(row.progress_log) == 2assert row.progress_log[-1]["message"] == (@@ -278,14 +279,44 @@ def test_terminate_parses_a_progress_log_stored_as_a_json_string()-def test_terminate_recovers_from_an_unparseable_progress_log(+def test_terminate_persists_entry_for_a_list_progress_log(authenticated_client, db):- """The ``except -> []`` arm: a corrupt column must not make Stop- fail. The user's request to halt a run is the last thing that should- depend on a well-formed log."""+ """A successful Stop must keep its audit entry after the row is reloaded."""+ from local_deep_research.database.models import ResearchHistory++ _add_research(+ db,+ "res-list",+ status="in_progress",+ progress_log=[{"time": "t0", "message": "started", "progress": 0}],+ )+ cleanup = MagicMock()++ with _patch_session(db):+ for patcher in _terminate_mocks(active=True, cleanup=cleanup):+ patcher.start()+ try:+ response = authenticated_client.post("/api/terminate/res-list")+ finally:+ patch.stopall()++ assert response.status_code == 200, response.text[:300]+ db.expire_all()+ stored = db.get(ResearchHistory, "res-list")+ assert stored.status == "suspended"+ assert isinstance(stored.progress_log, list)+ assert len(stored.progress_log) == 2+ assert stored.progress_log[-1]["metadata"]["phase"] == "termination"++[email protected]("initial_progress_log", ["{not json", '{"time": "t"}'])+def test_terminate_recovers_from_malformed_progress_log_text(+ authenticated_client, db, initial_progress_log+):+ """Malformed text or a JSON object must not prevent a persisted Stop."""row = _add_research(- db, "res-1", status="in_progress", progress_log="{not json"+ db, "res-1", status="in_progress", progress_log=initial_progress_log)cleanup = MagicMock()@@ -298,6 +329,7 @@ def test_terminate_recovers_from_an_unparseable_progress_log(patch.stopall()assert response.status_code == 200, response.text[:300]+ db.expire_all()assert isinstance(row.progress_log, list)assert len(row.progress_log) == 1