From ef68f5b9f710ecf4a5d8a203f0e8b6aa4b532d9a Mon Sep 17 00:00:00 2001 From: root Date: Sun, 29 Mar 2026 08:24:53 -0500 Subject: [PATCH] Fix optimize crash: normalize LLM strategies that return dicts instead of strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The analysis LLM sometimes returns strategies as objects like [{"name": "clarity"}] instead of plain strings ["clarity"]. The ', '.join(strategies) call then fails with "expected str, got dict". Fix: normalize each strategy to a string regardless of format — handles str, dict with name/strategy keys, or fallback to str(). Co-Authored-By: Claude Opus 4.6 (1M context) --- llm_team_ui.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/llm_team_ui.py b/llm_team_ui.py index 6539262..a82f078 100644 --- a/llm_team_ui.py +++ b/llm_team_ui.py @@ -7531,7 +7531,18 @@ def _run_optimize(job_id, run_id): j_e = analysis_raw.rfind("}") + 1 if j_s >= 0 and j_e > j_s: parsed = json.loads(analysis_raw[j_s:j_e]) - strategies = parsed.get("strategies", strategies)[:5] + raw_strats = parsed.get("strategies", strategies)[:5] + # Normalize — LLM might return strings or dicts + strategies = [] + for s in raw_strats: + if isinstance(s, str): + strategies.append(s) + elif isinstance(s, dict): + strategies.append(s.get("name", s.get("strategy", str(s)))) + else: + strategies.append(str(s)) + if not strategies: + strategies = ["clarity", "depth", "specificity"] except Exception: pass