Skip to content

Commit 10531fd

Browse files
authored
feat: add last_exp_fb to DSTrace and update feedback retrieval usage (#910)
* feat: add last_exp_fb to DSTrace and update feedback retrieval usage * fix: use trace.last_exp_fb for previous trial feedback description
1 parent c3854cf commit 10531fd

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

rdagent/scenarios/data_science/dev/feedback.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ def generate_feedback(self, exp: DSExperiment, trace: DSTrace) -> ExperimentFeed
3131
exp=sota_exp, heading="SOTA of previous exploration of the scenario"
3232
)
3333

34-
last_exp = trace.last_exp()
35-
3634
# Get feedback description using shared template
3735
feedback_desc = T("scenarios.data_science.share:describe.feedback").r(
38-
exp_and_feedback=trace.hist[-1] if trace.hist else None, heading="Previous Trial Feedback"
36+
exp_and_feedback=trace.last_exp_fb(), heading="Previous Trial Feedback"
3937
)
4038

4139
# TODO:

rdagent/scenarios/data_science/proposal/exp_gen/base.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,20 @@ def last_exp(
304304
"""
305305
Access the last experiment
306306
"""
307-
search_list = self.retrieve_search_list(search_type)
307+
if (last_exp_fb := self.last_exp_fb(search_type=search_type)) is not None:
308+
return last_exp_fb[0]
309+
return None
308310

311+
def last_exp_fb(
312+
self,
313+
search_type: Literal["all", "ancestors"] = "ancestors",
314+
) -> tuple[DSExperiment, ExperimentFeedback] | None:
315+
"""
316+
Access the last experiment and feedback
317+
"""
318+
search_list = self.retrieve_search_list(search_type)
309319
for exp, ef in search_list[::-1]:
310-
return exp
320+
return exp, ef
311321
return None
312322

313323
def last_runnable_exp_fb(

0 commit comments

Comments
 (0)