Skip to content

Commit d0a41b5

Browse files
author
彦辅
committed
feat: Add type validation to assign_code_list_to_evo
1 parent fb628e3 commit d0a41b5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

rdagent/components/coder/factor_coder/evolving_strategy.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,16 @@ def assign_code_list_to_evo(self, code_list, evo):
169169
continue
170170
if evo.sub_workspace_list[index] is None:
171171
evo.sub_workspace_list[index] = FactorFBWorkspace(target_task=evo.sub_tasks[index])
172-
evo.sub_workspace_list[index].inject_files(**{"factor.py": code_list[index]})
172+
# code_list[index] should be either a string (for new implementations)
173+
# or a dict (for existing implementations from knowledge base)
174+
if isinstance(code_list[index], str):
175+
# New implementation - code is a string
176+
evo.sub_workspace_list[index].inject_files(**{"factor.py": code_list[index]})
177+
elif isinstance(code_list[index], dict):
178+
# Existing implementation - code_list[index] is already a file_dict
179+
if "factor.py" not in code_list[index]:
180+
raise ValueError(f"Dictionary at code_list[{index}] must contain 'factor.py' key")
181+
evo.sub_workspace_list[index].inject_files(**code_list[index])
182+
else:
183+
raise TypeError(f"Expected str or dict for code_list[{index}], got {type(code_list[index])}")
173184
return evo

0 commit comments

Comments
 (0)