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 <liyuan851277048@icloud.com>
This commit is contained in:
octo-patch 2026-04-24 09:38:41 +08:00
parent 9fb101282f
commit 8e25743c44
2 changed files with 6 additions and 13 deletions

View file

@ -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

View file

@ -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