From d4565aa68c72a045c3b718ce1cfc5ba4d5f800bf Mon Sep 17 00:00:00 2001 From: Isadora White Date: Thu, 20 Feb 2025 21:45:29 -0800 Subject: [PATCH] small fixes, the items were being given twice to the agents on initialization and accounting for blocked_actions not being in the task file --- evaluation_script.py | 51 -------------------------------------------- src/agent/agent.js | 2 +- src/agent/tasks.js | 11 +++++----- 3 files changed, 6 insertions(+), 58 deletions(-) diff --git a/evaluation_script.py b/evaluation_script.py index ab37989..a0b9959 100644 --- a/evaluation_script.py +++ b/evaluation_script.py @@ -306,57 +306,6 @@ def detach_process(command): print(f"An error occurred: {e}") return None - - # Generate timestamp at the start of experiments - timestamp = datetime.now().strftime('%Y%m%d_%H%M%S') - results_filename = f"results_{task_id}_{timestamp}.txt" - print(f"Results will be saved to: {results_filename}") - - success_count = 0 - experiment_results = [] - - for exp_num in range(num_exp): - print(f"\nRunning experiment {exp_num + 1}/{num_exp}") - - start_time = time.time() - - # Run the node command - cmd = f"node main.js --task_path {task_path} --task_id {task_id}" - try: - subprocess.run(cmd, shell=True, check=True) - except subprocess.CalledProcessError as e: - print(f"Error running experiment: {e}") - continue - - # Check if task was successful - success = check_task_completion(agents) - if success: - success_count += 1 - print(f"Experiment {exp_num + 1} successful") - else: - print(f"Experiment {exp_num + 1} failed") - - end_time = time.time() - - time_taken = end_time - start_time - - # Store individual experiment result - experiment_results.append({ - 'success': success, - 'time_taken': time_taken - }) - - # Update results file after each experiment - update_results_file(task_id, success_count, exp_num + 1, time_taken, experiment_results) - - - # Small delay between experiments - time.sleep(1) - - final_ratio = success_count / num_exp - print(f"\nExperiments completed. Final success ratio: {final_ratio:.2f}") - return experiment_results - def main(): # edit_settings("settings.js", {"profiles": ["./andy.json", "./jill.json"], "port": 55917}) # edit_server_properties_file("../server_data/", 55917) diff --git a/src/agent/agent.js b/src/agent/agent.js index 071aa51..2a84250 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -91,7 +91,7 @@ export class Agent { this._setupEventHandlers(save_data, init_message); this.startEvents(); - this.task.initBotTask(); + // this.task.initBotTask(); if (!load_mem) { this.task.initBotTask(); diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 55b6de2..9474a06 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -49,7 +49,11 @@ export class Task { this.taskTimeout = this.data.timeout || 300; this.taskStartTime = Date.now(); this.validator = new TaskValidator(this.data, this.agent); - this.blocked_actions = this.data.blocked_actions[this.agent.count_id.toString()] || []; + if (this.data.blocked_actions) { + this.blocked_actions = this.data.blocked_actions[this.agent.count_id.toString()] || []; + } else { + this.blocked_actions = []; + } this.restrict_to_inventory = !!this.data.restrict_to_inventory; if (this.data.goal) this.blocked_actions.push('!endGoal'); @@ -80,11 +84,6 @@ export class Task { isDone() { if (this.validator && this.validator.validate()) return {"message": 'Task successful', "code": 2}; - // TODO check for other terminal conditions - // if (this.task.goal && !this.self_prompter.isActive()) - // return {"message": 'Agent ended goal', "code": 3}; - // if (this.task.conversation && !inConversation()) - // return {"message": 'Agent ended conversation', "code": 3}; if (this.taskTimeout) { const elapsedTime = (Date.now() - this.taskStartTime) / 1000; if (elapsedTime >= this.taskTimeout) {