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 cancel_research API endpoint to properly pass username parameter

LearningCircuite8a7a0d59bff
diff --git a/src/local_deep_research/web/routes/api_routes.py b/src/local_deep_research/web/routes/api_routes.py
index ae6e10a404..fc021ab26c 100644
--- a/src/local_deep_research/web/routes/api_routes.py
+++ b/src/local_deep_research/web/routes/api_routes.py
@@ -177,14 +177,26 @@ def api_terminate_research(research_id):
Terminate a research process
"""
try:
- result = cancel_research(research_id)
- return jsonify(
- {
- "status": "success",
- "message": "Research terminated",
- "result": result,
- }
- )
+ from flask import session
+
+ username = session.get("username")
+ result = cancel_research(research_id, username)
+ if result:
+ return jsonify(
+ {
+ "status": "success",
+ "message": "Research terminated",
+ "result": result,
+ }
+ )
+ else:
+ return jsonify(
+ {
+ "status": "success",
+ "message": "Research not found or already completed",
+ "result": result,
+ }
+ )
except Exception:
logger.exception("Error terminating research")
return (
diff --git a/src/local_deep_research/web/services/research_service.py b/src/local_deep_research/web/services/research_service.py
index 72a7d2bf33..4709b12719 100644
--- a/src/local_deep_research/web/services/research_service.py
+++ b/src/local_deep_research/web/services/research_service.py
@@ -1413,12 +1413,13 @@ def handle_termination(
)
-def cancel_research(research_id):
+def cancel_research(research_id, username=None):
"""
Cancel/terminate a research process using ORM.
Args:
research_id: The ID of the research to cancel
+ username: The username of the user cancelling the research (optional, will try to get from session if not provided)
Returns:
bool: True if the research was found and cancelled, False otherwise
@@ -1440,10 +1441,12 @@ def cancel_research(research_id):
return True
else:
# Update database directly if not found in active_research
- # Get username from active research entry
- from flask import session
+ # Get username from parameter or session
+ if not username:
+ from flask import session
+
+ username = session.get("username")
- username = session.get("username")
if not username:
return False