Skip to content

Commit edb552e

Browse files
authored
fix: fix a bug in initial tasks (microsoft#635)
* fix a bug in initial tasks * fix ci
1 parent e4acd92 commit edb552e

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

rdagent/scenarios/data_science/proposal/exp_gen.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -237,30 +237,23 @@ def _handle_missing_component(
237237
last_successful_exp: Last successful experiment or None
238238
spec_file: Path to specification file if needed
239239
"""
240-
former_task_desc = (
241-
trace.hist[-1][0].pending_tasks_list[0][0].get_task_information()
242-
if len(trace.hist) > 0 and trace.hist[-1][0] is not last_successful_exp
243-
else None
244-
)
245240

246-
exp_and_feedback = trace.hist[-1] if len(trace.hist) > 0 else None
247-
if (
248-
exp_and_feedback
249-
and exp_and_feedback[1].exception is not None
250-
and (
251-
exp_and_feedback[0].pending_tasks_list[0][0].name == component
252-
or exp_and_feedback[0].pending_tasks_list[0][0].name.startswith("model_")
253-
and component == "Model"
254-
)
255-
): # Assumption: when completing missing component, using component name as task name
256-
former_task_desc += f"\n\nYou have tried to implement the same component and got the following exception: \n{exp_and_feedback[1].exception}\n Please try different methods to avoid the same errors and results in an infinite loop"
241+
former_tasks_desc = ""
242+
if len(trace.hist) > 0:
243+
for exp, fb in reversed(trace.hist):
244+
if exp is not last_successful_exp:
245+
former_task_desc = exp.pending_tasks_list[0][0].get_task_information()
246+
former_task_desc += f"\n\nYou have tried to implement the same component and got the following exception: \n{fb.exception}\n Please try different methods to avoid the same errors and results in an infinite loop"
247+
former_tasks_desc += former_task_desc
248+
else:
249+
break
257250

258251
resp_dict = self._init_task_gen(
259252
targets=component,
260253
scenario_desc=scenario_desc,
261254
spec=last_successful_exp.experiment_workspace.file_dict[spec_file] if spec_file else None,
262255
task_output_format=T(f".prompts:output_format.{component_prompt_key or component.lower()}").r(),
263-
former_task=former_task_desc,
256+
former_task=former_tasks_desc if former_tasks_desc else None,
264257
)
265258

266259
task = task_cls(

0 commit comments

Comments
 (0)