Skip to content

Commit b331ff7

Browse files
committed
fix: avoid duplicate base class insertion
1 parent d767b19 commit b331ff7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

alphaevolve/evolution/controller.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,12 @@ async def _spawn(self, parent_id: str | None, *, prompt: PromptGenome | None = N
120120

121121
child_strategy = apply_patch(parent["code"], diff_json)
122122

123-
imports = "from collections import deque\nimport backtrader as bt"
124-
base_cls = inspect.getsource(BaseLoggingStrategy)
125-
child_code = textwrap.dedent(imports + "\n\n" + base_cls + "\n\n" + child_strategy)
123+
if "class BaseLoggingStrategy" not in child_strategy:
124+
imports = "from collections import deque\nimport backtrader as bt"
125+
base_cls = inspect.getsource(BaseLoggingStrategy)
126+
child_code = textwrap.dedent(imports + "\n\n" + base_cls + "\n\n" + child_strategy)
127+
else:
128+
child_code = textwrap.dedent(child_strategy)
126129

127130
# 4) Evaluate
128131
try:

0 commit comments

Comments
 (0)