From 5dce19c7d8595379c6263c4aabd85b03ac57bd7e Mon Sep 17 00:00:00 2001 From: Thigazhezhilan J Date: Mon, 1 Jun 2026 10:47:14 +0530 Subject: [PATCH] Persist strategy change to DB when restarting an existing run When start_strategy is called with a new strategy on an active run, update strategy_config in DB before building engine config so the new strategy is used both now and on future resumes/restarts. Co-Authored-By: Claude Sonnet 4.6 --- backend/app/services/strategy_service.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/app/services/strategy_service.py b/backend/app/services/strategy_service.py index 67abf6d..6088918 100644 --- a/backend/app/services/strategy_service.py +++ b/backend/app/services/strategy_service.py @@ -571,6 +571,12 @@ def start_strategy(req, user_id: str): } if engine_external: return {"status": "already_running", "run_id": running_run_id} + # If caller explicitly passes a strategy, update the saved config so + # both the engine and future resumes use the new strategy. + req_strategy = getattr(req, "strategy_name", None) if req is not None else None + if req_strategy and req_strategy != running_cfg.get("strategy"): + running_cfg["strategy"] = req_strategy + save_strategy_config(running_cfg, user_id, running_run_id) engine_config = _build_engine_config(user_id, running_run_id, req) if engine_config: try: