From 220e510d5e2504c0d7efd9a38b92d8cfdb391add Mon Sep 17 00:00:00 2001 From: Adriano Dal Pastro Date: Sat, 16 May 2026 13:21:08 +0000 Subject: [PATCH] fix(orchestrator): escludi prompt_library dal config_dict JSON PromptLibrary e' un frozen dataclass non JSON-serializable. Quando passata in cfg.prompt_library e poi spread via **cfg.__dict__ in config_dict, faceva fallire repo.create_run() con TypeError al primo run dopo refactor. Fix: filtra cfg.__dict__ escludendo prompt_library, e salva separatamente la lista degli stili (prompt_library_styles) per reproducibility. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../multi_swarm_core/orchestrator/run.py | 8 +- .../strategies/btc_fb63e851.json | 142 ------------------ 2 files changed, 7 insertions(+), 143 deletions(-) delete mode 100644 src/strategy_crypto/strategy_crypto/strategies/btc_fb63e851.json diff --git a/src/multi_swarm_core/multi_swarm_core/orchestrator/run.py b/src/multi_swarm_core/multi_swarm_core/orchestrator/run.py index b86acc5..5fe849c 100644 --- a/src/multi_swarm_core/multi_swarm_core/orchestrator/run.py +++ b/src/multi_swarm_core/multi_swarm_core/orchestrator/run.py @@ -112,10 +112,16 @@ def run_phase1( repo = Repository(cfg.db_path) repo.init_schema() + # Escludi prompt_library (PromptLibrary dataclass non e' JSON-serializable); + # salva solo i nomi degli stili per reproducibility. config_dict = { - **cfg.__dict__, + **{k: v for k, v in cfg.__dict__.items() if k != "prompt_library"}, "db_path": str(cfg.db_path), "model_tier": cfg.model_tier.value, + "prompt_library_styles": ( + list(cfg.prompt_library.cognitive_styles) + if cfg.prompt_library is not None else None + ), } run_id = repo.create_run(name=cfg.run_name, config=config_dict) diff --git a/src/strategy_crypto/strategy_crypto/strategies/btc_fb63e851.json b/src/strategy_crypto/strategy_crypto/strategies/btc_fb63e851.json deleted file mode 100644 index 3f79cb7..0000000 --- a/src/strategy_crypto/strategy_crypto/strategies/btc_fb63e851.json +++ /dev/null @@ -1,142 +0,0 @@ -{ - "rules": [ - { - "condition": { - "op": "and", - "args": [ - { - "op": "gt", - "args": [ - { - "kind": "indicator", - "name": "rsi", - "params": [ - 14 - ] - }, - { - "kind": "literal", - "value": 70.0 - } - ] - }, - { - "op": "gt", - "args": [ - { - "kind": "indicator", - "name": "atr", - "params": [ - 14 - ] - }, - { - "kind": "indicator", - "name": "sma", - "params": [ - 14 - ] - } - ] - }, - { - "op": "gt", - "args": [ - { - "kind": "feature", - "name": "hour" - }, - { - "kind": "literal", - "value": 9 - } - ] - }, - { - "op": "lt", - "args": [ - { - "kind": "feature", - "name": "hour" - }, - { - "kind": "literal", - "value": 17 - } - ] - } - ] - }, - "action": "entry-short" - }, - { - "condition": { - "op": "and", - "args": [ - { - "op": "lt", - "args": [ - { - "kind": "indicator", - "name": "rsi", - "params": [ - 14 - ] - }, - { - "kind": "literal", - "value": 30.0 - } - ] - }, - { - "op": "lt", - "args": [ - { - "kind": "indicator", - "name": "atr", - "params": [ - 14 - ] - }, - { - "kind": "indicator", - "name": "sma", - "params": [ - 14 - ] - } - ] - }, - { - "op": "gt", - "args": [ - { - "kind": "feature", - "name": "hour" - }, - { - "kind": "literal", - "value": 9 - } - ] - }, - { - "op": "lt", - "args": [ - { - "kind": "feature", - "name": "hour" - }, - { - "kind": "literal", - "value": 17 - } - ] - } - ] - }, - "action": "entry-long" - } - ] -} \ No newline at end of file