From 21971db722620153bd001164af5dba7920cd4f46 Mon Sep 17 00:00:00 2001 From: Alice Hau <110418948+ahau-square@users.noreply.github.com> Date: Thu, 10 Apr 2025 14:05:37 -0400 Subject: [PATCH] chore: cleanup bench evals copy session dir code (#2131) --- crates/goose-bench/src/eval_suites/utils.rs | 39 +------------------ .../src/eval_suites/vibes/blog_summary.rs | 11 +----- .../src/eval_suites/vibes/flappy_bird.rs | 11 +----- .../src/eval_suites/vibes/goose_wiki.rs | 11 +----- .../eval_suites/vibes/restaurant_research.rs | 11 +----- .../src/eval_suites/vibes/squirrel_census.rs | 11 +----- 6 files changed, 11 insertions(+), 83 deletions(-) diff --git a/crates/goose-bench/src/eval_suites/utils.rs b/crates/goose-bench/src/eval_suites/utils.rs index d860381b..880e457b 100644 --- a/crates/goose-bench/src/eval_suites/utils.rs +++ b/crates/goose-bench/src/eval_suites/utils.rs @@ -1,8 +1,7 @@ use crate::bench_work_dir::BenchmarkWorkDir; use anyhow::{Context, Result}; use goose::message::Message; -use goose::session::storage; -use std::fs::{self, File}; +use std::fs::File; use std::io::Write; use std::path::PathBuf; @@ -31,39 +30,3 @@ pub fn write_response_to_file( Ok(text_content) } - -/// Copy the most recent session file to the current working directory -/// -/// This function finds the most recent Goose session file (.jsonl) and copies it -/// to the current working directory. Session files are stored by the Goose framework -/// in a platform-specific data directory. -/// -/// # Returns -/// - Ok(session_path) if successfully copied, where session_path is the path to the copied file -/// - Err if any errors occurred during the process -pub fn copy_session_to_cwd() -> Result { - // Try to get the most recent session file - let src_path = storage::get_most_recent_session() - .with_context(|| "Failed to find any recent session files")?; - - // Extract the filename from the path - let filename = src_path - .file_name() - .ok_or_else(|| anyhow::anyhow!("Invalid session filename"))?; - - // Create the destination path in the current directory - let dest_path = PathBuf::from(".").join(filename); - - // Copy the file - fs::copy(&src_path, &dest_path).with_context(|| { - format!( - "Failed to copy from '{}' to '{}'", - src_path.display(), - dest_path.display() - ) - })?; - - println!("Session file copied to: {}", dest_path.display()); - - Ok(dest_path) -} diff --git a/crates/goose-bench/src/eval_suites/vibes/blog_summary.rs b/crates/goose-bench/src/eval_suites/vibes/blog_summary.rs index eef140d0..de2f22ef 100644 --- a/crates/goose-bench/src/eval_suites/vibes/blog_summary.rs +++ b/crates/goose-bench/src/eval_suites/vibes/blog_summary.rs @@ -1,8 +1,8 @@ use crate::bench_session::BenchAgent; use crate::bench_work_dir::BenchmarkWorkDir; use crate::eval_suites::{ - collect_baseline_metrics, copy_session_to_cwd, metrics_hashmap_to_vec, write_response_to_file, - EvalMetricValue, Evaluation, ExtensionRequirements, + collect_baseline_metrics, metrics_hashmap_to_vec, write_response_to_file, EvalMetricValue, + Evaluation, ExtensionRequirements, }; use crate::register_evaluation; use async_trait::async_trait; @@ -65,13 +65,6 @@ impl Evaluation for BlogSummary { EvalMetricValue::Boolean(used_fetch_tool), )); - // Copy the session file to the current working directory - if let Err(e) = copy_session_to_cwd() { - println!("Warning: Failed to copy session file: {}", e); - } else { - println!("Successfully copied session file to current directory"); - } - Ok(metrics) } diff --git a/crates/goose-bench/src/eval_suites/vibes/flappy_bird.rs b/crates/goose-bench/src/eval_suites/vibes/flappy_bird.rs index 0fecedf5..cbde37e0 100644 --- a/crates/goose-bench/src/eval_suites/vibes/flappy_bird.rs +++ b/crates/goose-bench/src/eval_suites/vibes/flappy_bird.rs @@ -1,8 +1,8 @@ use crate::bench_session::BenchAgent; use crate::bench_work_dir::BenchmarkWorkDir; use crate::eval_suites::{ - collect_baseline_metrics, copy_session_to_cwd, metrics_hashmap_to_vec, EvalMetricValue, - Evaluation, ExtensionRequirements, + collect_baseline_metrics, metrics_hashmap_to_vec, EvalMetricValue, Evaluation, + ExtensionRequirements, }; use crate::register_evaluation; use async_trait::async_trait; @@ -97,13 +97,6 @@ impl Evaluation for FlappyBird { } } - // Copy the session file to the current working directory - if let Err(e) = copy_session_to_cwd() { - println!("Warning: Failed to copy session file: {}", e); - } else { - println!("Successfully copied session file to current directory"); - } - Ok(metrics) } diff --git a/crates/goose-bench/src/eval_suites/vibes/goose_wiki.rs b/crates/goose-bench/src/eval_suites/vibes/goose_wiki.rs index 9c87a31f..13dd2779 100644 --- a/crates/goose-bench/src/eval_suites/vibes/goose_wiki.rs +++ b/crates/goose-bench/src/eval_suites/vibes/goose_wiki.rs @@ -1,8 +1,8 @@ use crate::bench_session::BenchAgent; use crate::bench_work_dir::BenchmarkWorkDir; use crate::eval_suites::{ - collect_baseline_metrics, copy_session_to_cwd, metrics_hashmap_to_vec, EvalMetricValue, - Evaluation, ExtensionRequirements, + collect_baseline_metrics, metrics_hashmap_to_vec, EvalMetricValue, Evaluation, + ExtensionRequirements, }; use crate::register_evaluation; use async_trait::async_trait; @@ -75,13 +75,6 @@ impl Evaluation for GooseWiki { EvalMetricValue::Boolean(valid_tool_call), )); - // Copy the session file to the current working directory - if let Err(e) = copy_session_to_cwd() { - println!("Warning: Failed to copy session file: {}", e); - } else { - println!("Successfully copied session file to current directory"); - } - Ok(metrics) } diff --git a/crates/goose-bench/src/eval_suites/vibes/restaurant_research.rs b/crates/goose-bench/src/eval_suites/vibes/restaurant_research.rs index 72bf3820..5d6a5573 100644 --- a/crates/goose-bench/src/eval_suites/vibes/restaurant_research.rs +++ b/crates/goose-bench/src/eval_suites/vibes/restaurant_research.rs @@ -1,8 +1,8 @@ use crate::bench_session::BenchAgent; use crate::bench_work_dir::BenchmarkWorkDir; use crate::eval_suites::{ - collect_baseline_metrics, copy_session_to_cwd, metrics_hashmap_to_vec, write_response_to_file, - EvalMetricValue, Evaluation, ExtensionRequirements, + collect_baseline_metrics, metrics_hashmap_to_vec, write_response_to_file, EvalMetricValue, + Evaluation, ExtensionRequirements, }; use crate::register_evaluation; use async_trait::async_trait; @@ -85,13 +85,6 @@ Present the information in order of significance or quality. Focus specifically EvalMetricValue::Boolean(used_fetch_tool), )); - // Copy the session file to the current working directory - if let Err(e) = copy_session_to_cwd() { - println!("Warning: Failed to copy session file: {}", e); - } else { - println!("Successfully copied session file to current directory"); - } - Ok(metrics) } diff --git a/crates/goose-bench/src/eval_suites/vibes/squirrel_census.rs b/crates/goose-bench/src/eval_suites/vibes/squirrel_census.rs index da4db4fe..4bfb1ed2 100644 --- a/crates/goose-bench/src/eval_suites/vibes/squirrel_census.rs +++ b/crates/goose-bench/src/eval_suites/vibes/squirrel_census.rs @@ -1,8 +1,8 @@ use crate::bench_session::BenchAgent; use crate::bench_work_dir::BenchmarkWorkDir; use crate::eval_suites::{ - collect_baseline_metrics, copy_session_to_cwd, metrics_hashmap_to_vec, EvalMetricValue, - Evaluation, ExtensionRequirements, + collect_baseline_metrics, metrics_hashmap_to_vec, EvalMetricValue, Evaluation, + ExtensionRequirements, }; use crate::register_evaluation; use async_trait::async_trait; @@ -153,13 +153,6 @@ After writing the script, run it using python3 and show the results. Do not ask EvalMetricValue::Boolean(correct_results), )); - // Copy the session file to the current working directory - if let Err(e) = copy_session_to_cwd() { - println!("Warning: Failed to copy session file: {}", e); - } else { - println!("Successfully copied session file to current directory"); - } - Ok(metrics) }