diff --git a/rdagent/scenarios/data_science/loop.py b/rdagent/scenarios/data_science/loop.py index 306b4e0d..ea52b501 100644 --- a/rdagent/scenarios/data_science/loop.py +++ b/rdagent/scenarios/data_science/loop.py @@ -222,7 +222,6 @@ class DataScienceRDLoop(RDLoop): e = prev_out.get(self.EXCEPTION_KEY, None) if e is None: exp = prev_out["running"] - self.trace.hist.append((exp, prev_out["feedback"])) # NOTE: we put below operations on selections here, instead of out of the if-else block, # to fit the corner case that the trace will be reset @@ -232,8 +231,16 @@ class DataScienceRDLoop(RDLoop): self.trace.set_current_selection(exp.local_selection) self.trace.sync_dag_parent_and_hist() + self.trace.hist.append((exp, prev_out["feedback"])) + else: exp: DSExperiment = prev_out["direct_exp_gen"] if isinstance(e, CoderError) else prev_out["coding"] + + # set the local selection to the trace as global selection, then set the DAG parent for the trace + if exp.local_selection is not None: + self.trace.set_current_selection(exp.local_selection) + self.trace.sync_dag_parent_and_hist() + self.trace.hist.append( ( exp, @@ -241,11 +248,6 @@ class DataScienceRDLoop(RDLoop): ) ) - # set the local selection to the trace as global selection, then set the DAG parent for the trace - if exp.local_selection is not None: - self.trace.set_current_selection(exp.local_selection) - self.trace.sync_dag_parent_and_hist() - if self.trace.sota_experiment() is None: if DS_RD_SETTING.coder_on_whole_pipeline: # check if feedback is not generated