mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 02:05:22 -04:00
fix: preserve partial deep research findings on non-timeout errors (#2189)
* fix: preserve partial deep research findings on non-timeout errors * fix: preserve partial deep research findings on non-timeout errors
This commit is contained in:
+20
-2
@@ -362,8 +362,26 @@ class ResearchHandler:
|
|||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Background research failed: {e}", exc_info=True)
|
logger.error(f"Background research failed: {e}", exc_info=True)
|
||||||
entry["result"] = str(e)
|
# Preserve partial findings if available (mirrors timeout branch)
|
||||||
entry["status"] = "error"
|
researcher = entry.get("researcher")
|
||||||
|
if researcher and researcher.evolving_report:
|
||||||
|
_elapsed = time.time() - entry["started_at"]
|
||||||
|
entry["result"] = self._format_research_report(
|
||||||
|
query, researcher.evolving_report,
|
||||||
|
researcher.get_stats(), _elapsed,
|
||||||
|
)
|
||||||
|
entry["status"] = "done"
|
||||||
|
self._save_result(session_id, entry)
|
||||||
|
try:
|
||||||
|
sources = self._extract_sources(researcher.findings) if researcher.findings else []
|
||||||
|
findings = self._extract_raw_findings(researcher.findings) if researcher.findings else []
|
||||||
|
_guarded_complete(session_id, entry["result"], sources, findings)
|
||||||
|
except Exception as cb_err:
|
||||||
|
logger.warning(f"on_complete callback failed in error branch: {cb_err}")
|
||||||
|
on_progress({"phase": "warning", "message": f"Research finished with errors — partial results saved ({_elapsed:.0f}s elapsed)"})
|
||||||
|
else:
|
||||||
|
entry["result"] = str(e)
|
||||||
|
entry["status"] = "error"
|
||||||
|
|
||||||
task = asyncio.create_task(_run())
|
task = asyncio.create_task(_run())
|
||||||
entry["task"] = task
|
entry["task"] = task
|
||||||
|
|||||||
Reference in New Issue
Block a user