From 8e25743c4470059e7e2c7e94d1cd16b0a9ff6263 Mon Sep 17 00:00:00 2001 From: octo-patch Date: Fri, 24 Apr 2026 09:38:41 +0800 Subject: [PATCH] fix: persist scan data on exit and save partial reports (fixes #294) Two related fixes for reports not being saved when Strix exits: 1. Call tracer.cleanup() in main.py's finally block before posthog.end() so that run data is always written to disk regardless of whether the atexit handlers registered in cli.py/tui.py fire (they can be skipped on Windows when the asyncio event loop tears down). 2. Replace the strict all-or-nothing validation in finish_actions.py with a graceful fallback: missing fields get the placeholder "[Not provided by model]" so partial reports are saved rather than silently discarded when the LLM omits a section. Co-Authored-By: Octopus --- strix/interface/main.py | 1 + strix/tools/finish/finish_actions.py | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/strix/interface/main.py b/strix/interface/main.py index bc88da673..37a6de5b4 100644 --- a/strix/interface/main.py +++ b/strix/interface/main.py @@ -629,6 +629,7 @@ def main() -> None: # noqa: PLR0912, PLR0915 finally: tracer = get_global_tracer() if tracer: + tracer.cleanup() posthog.end(tracer, exit_reason=exit_reason) results_path = Path("strix_runs") / args.run_name diff --git a/strix/tools/finish/finish_actions.py b/strix/tools/finish/finish_actions.py index 79f48e79b..ff78abc98 100644 --- a/strix/tools/finish/finish_actions.py +++ b/strix/tools/finish/finish_actions.py @@ -99,19 +99,11 @@ def finish_scan( if active_agents_error: return active_agents_error - validation_errors = [] - - if not executive_summary or not executive_summary.strip(): - validation_errors.append("Executive summary cannot be empty") - if not methodology or not methodology.strip(): - validation_errors.append("Methodology cannot be empty") - if not technical_analysis or not technical_analysis.strip(): - validation_errors.append("Technical analysis cannot be empty") - if not recommendations or not recommendations.strip(): - validation_errors.append("Recommendations cannot be empty") - - if validation_errors: - return {"success": False, "message": "Validation failed", "errors": validation_errors} + _NOT_PROVIDED = "[Not provided by model]" + executive_summary = (executive_summary or "").strip() or _NOT_PROVIDED + methodology = (methodology or "").strip() or _NOT_PROVIDED + technical_analysis = (technical_analysis or "").strip() or _NOT_PROVIDED + recommendations = (recommendations or "").strip() or _NOT_PROVIDED try: from strix.telemetry.tracer import get_global_tracer