From c1ce3bf9b6c1712da23f08f4194e927c4b241d8c Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Tue, 11 Mar 2025 10:45:25 -0500 Subject: [PATCH 01/10] fix merge conflict --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index a1b615b..71b1187 100644 --- a/.gitignore +++ b/.gitignore @@ -19,10 +19,5 @@ experiments/ andy_*.json jill_*.json src/models/logs/* -<<<<<<< HEAD -server_data/* -server_data_*/* -======= server_data* results/* ->>>>>>> d70491e5974a973b96c47f0515c2722b82c9b253 From 87d34aa023f7064da700ef03714bce1b2ccae6a5 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Tue, 11 Mar 2025 10:45:55 -0500 Subject: [PATCH 02/10] add blueprint to blocked actions --- settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.js b/settings.js index 2a960fa..e1cf007 100644 --- a/settings.js +++ b/settings.js @@ -13,7 +13,7 @@ export default // the base profile is shared by all bots for default prompts/examples/modes "base_profile": "./profiles/defaults/survival.json", // also see creative.json, god_mode.json "profiles": ((process.env.PROFILES) && JSON.parse(process.env.PROFILES)) || [ - "./profiles/deepseek.json", + "./profiles/andy.json", // "./profiles/gpt.json", // "./profiles/claude.json", // "./profiles/gemini.json", @@ -35,7 +35,7 @@ export default "show_bot_views": false, // show bot's view in browser at localhost:3000, 3001... "allow_insecure_coding": process.env.INSECURE_CODING || false, // allows newAction command and model can write/run code on your computer. enable at own risk - "blocked_actions" : [], // commands to disable and remove from docs. Ex: ["!setMode"] + "blocked_actions" : ["!checkBlueprint", "!checkBlueprintLevel", "!getBlueprint", "!getBlueprintLevel"], // commands to disable and remove from docs "code_timeout_mins": -1, // minutes code is allowed to run. -1 for no timeout "relevant_docs_count": 5, // Parameter: -1 = all, 0 = no references, 5 = five references. If exceeding the maximum, all reference documents are returned. From ce8dd89231443b63628bbb87471c03932db63145 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Tue, 11 Mar 2025 11:03:40 -0500 Subject: [PATCH 03/10] prompter refactor --- settings.js | 2 +- src/models/prompter.js | 114 +++++++++++++++-------------------------- 2 files changed, 42 insertions(+), 74 deletions(-) diff --git a/settings.js b/settings.js index e1cf007..5c16d27 100644 --- a/settings.js +++ b/settings.js @@ -45,5 +45,5 @@ export default "verbose_commands": true, // show full command syntax "narrate_behavior": true, // chat simple automatic actions ('Picking up item!') "chat_bot_messages": true, // publicly chat messages to other bots - "log_all_prompts": false, // log all prompts to console + "log_all_prompts": false, // log all prompts to file } diff --git a/src/models/prompter.js b/src/models/prompter.js index bdcaa4e..1d3b380 100644 --- a/src/models/prompter.js +++ b/src/models/prompter.js @@ -131,6 +131,8 @@ export class Prompter { profile.api = 'google'; else if (profile.model.includes('openrouter/')) profile.api = 'openrouter'; // must do before others bc shares model names + else if (profile.model.includes('vllm/')) + profile.api = 'vllm'; else if (profile.model.includes('gpt') || profile.model.includes('o1')|| profile.model.includes('o3')) profile.api = 'openai'; else if (profile.model.includes('claude')) @@ -304,51 +306,7 @@ export class Prompter { this.last_prompt_time = Date.now(); } - // async promptConvo(messages) { - // this.most_recent_msg_time = Date.now(); - // let current_msg_time = this.most_recent_msg_time; - // for (let i = 0; i < 3; i++) { // try 3 times to avoid hallucinations - // await this.checkCooldown(); - // if (current_msg_time !== this.most_recent_msg_time) { - // return ''; - // } - // let prompt = this.profile.conversing; - // prompt = await this.replaceStrings(prompt, messages, this.convo_examples); - // let generation = await this.chat_model.sendRequest(messages, prompt); - // // in conversations >2 players LLMs tend to hallucinate and role-play as other bots - // // the FROM OTHER BOT tag should never be generated by the LLM - // if (generation.includes('(FROM OTHER BOT)')) { - // console.warn('LLM hallucinated message as another bot. Trying again...'); - // continue; - // } - // if (current_msg_time !== this.most_recent_msg_time) { - // console.warn(this.agent.name + ' received new message while generating, discarding old response.'); - // return ''; - // } - // return generation; - // } - // return ''; - // } - - async saveToFile(logFile, logEntry) { - let task_id = this.agent.task.task_id; - console.log(task_id) - let logDir; - if (this.task_id === null) { - logDir = path.join(__dirname, `../../bots/${this.agent.name}/logs`); - } else { - logDir = path.join(__dirname, `../../bots/${this.agent.name}/logs/${task_id}`); - } - - await fs.mkdir(logDir, { recursive: true }); - - logFile = path.join(logDir, logFile); - await fs.appendFile(logFile, String(logEntry), 'utf-8'); - } - async promptConvo(messages) { - // console.log(`[${new Date().toISOString()}] promptConvo called with messages:`, messages); - this.most_recent_msg_time = Date.now(); let current_msg_time = this.most_recent_msg_time; @@ -371,15 +329,7 @@ export class Prompter { throw new Error('Generated response is not a string'); } console.log("Generated response:", generation); - const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); - let logEntry; - if (this.task_id === null) { - logEntry = `[${timestamp}] \nPrompt:\n${prompt}\n\nConversation:\n${JSON.stringify(messages, null, 2)}\n\nResponse:\n${generation}\n\n`; - } else { - logEntry = `[${timestamp}] Task ID: ${task_id}\nPrompt:\n${prompt}\n\nConversation:\n${JSON.stringify(messages, null, 2)}\n\nResponse:\n${generation}\n\n`; - } - const logFile = `conversation_${timestamp}.txt`; - await this.saveToFile(logFile, logEntry); + await this._saveLog(prompt, messages, generation, 'conversation'); } catch (error) { console.error('Error during message generation or file writing:', error); @@ -413,35 +363,19 @@ export class Prompter { let prompt = this.profile.coding; prompt = await this.replaceStrings(prompt, messages, this.coding_examples); - let logEntry; - const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); - if (this.task_id === null) { - logEntry = `[${timestamp}] \nPrompt:\n${prompt}\n\nConversation:\n${JSON.stringify(messages, null, 2)}\n\n`; - } else { - logEntry = `[${timestamp}] Task ID: ${this.agent.task.task_id}\nPrompt:\n${prompt}\n\nConversation:\n${JSON.stringify(messages, null, 2)}\n\n`; - } - - const logFile = `coding_${timestamp}.txt`; - await this.saveToFile(logFile, logEntry); let resp = await this.code_model.sendRequest(messages, prompt); this.awaiting_coding = false; + await this._saveLog(prompt, messages, resp, 'coding'); return resp; } async promptMemSaving(to_summarize) { await this.checkCooldown(); let prompt = this.profile.saving_memory; - let logEntry; - const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); - if (this.task_id === null) { - logEntry = `[${timestamp}] \nPrompt:\n${prompt}\n\nTo Summarize:\n${JSON.stringify(messages, null, 2)}\n\n`; - } else { - logEntry = `[${timestamp}] Task ID: ${this.agent.task.task_id}\nPrompt:\n${prompt}\n\nConversation:\n${JSON.stringify(to_summarize, null, 2)}\n\n`; - } - const logFile = `memSaving_${timestamp}.txt`; - await this.saveToFile(logFile, logEntry); prompt = await this.replaceStrings(prompt, null, null, to_summarize); - return await this.chat_model.sendRequest([], prompt); + let resp = await this.chat_model.sendRequest([], prompt); + await this._saveLog(prompt, null, resp, 'memSaving'); + return resp; } async promptShouldRespondToBot(new_message) { @@ -455,6 +389,7 @@ export class Prompter { } async promptGoalSetting(messages, last_goals) { + // deprecated let system_message = this.profile.goal_setting; system_message = await this.replaceStrings(system_message, messages); @@ -479,4 +414,37 @@ export class Prompter { goal.quantity = parseInt(goal.quantity); return goal; } + + async _saveLog(prompt, messages, generation, tag) { + if (!settings.log_all_prompts) + return; + const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); + let logEntry; + let task_id = this.agent.task.task_id; + if (task_id == null) { + logEntry = `[${timestamp}] \nPrompt:\n${prompt}\n\nConversation:\n${JSON.stringify(messages, null, 2)}\n\nResponse:\n${generation}\n\n`; + } else { + logEntry = `[${timestamp}] Task ID: ${task_id}\nPrompt:\n${prompt}\n\nConversation:\n${JSON.stringify(messages, null, 2)}\n\nResponse:\n${generation}\n\n`; + } + const logFile = `${tag}_${timestamp}.txt`; + await this._saveToFile(logFile, logEntry); + } + + async _saveToFile(logFile, logEntry) { + let task_id = this.agent.task.task_id; + console.log(task_id) + let logDir; + if (task_id == null) { + logDir = path.join(__dirname, `../../bots/${this.agent.name}/logs`); + } else { + logDir = path.join(__dirname, `../../bots/${this.agent.name}/logs/${task_id}`); + } + + await fs.mkdir(logDir, { recursive: true }); + + logFile = path.join(logDir, logFile); + await fs.appendFile(logFile, String(logEntry), 'utf-8'); + } + + } From e96131b8c5d89b5a973125c768561cfe5bdeb081 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 12 Mar 2025 14:18:53 -0500 Subject: [PATCH 04/10] added python requirements --- requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7706406 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +boto3==1.37.11 +botocore==1.37.11 +javascript==1!1.2.2 +numpy==1.22.2 +opencv_python==4.10.0.84 +tqdm==4.62.3 From 7225699bf17f2893338d750661841ee95560c0c3 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 12 Mar 2025 14:19:59 -0500 Subject: [PATCH 05/10] move task json out of root --- example_tasks.json => tasks/example_tasks.json | 0 .../multiagent_crafting_tasks.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename example_tasks.json => tasks/example_tasks.json (100%) rename multiagent_crafting_tasks.json => tasks/multiagent_crafting_tasks.json (100%) diff --git a/example_tasks.json b/tasks/example_tasks.json similarity index 100% rename from example_tasks.json rename to tasks/example_tasks.json diff --git a/multiagent_crafting_tasks.json b/tasks/multiagent_crafting_tasks.json similarity index 100% rename from multiagent_crafting_tasks.json rename to tasks/multiagent_crafting_tasks.json From 753b8aa32b8ed369e2c04f07e3aa90bc5fab094c Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 12 Mar 2025 15:00:51 -0500 Subject: [PATCH 06/10] fix andy path --- settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.js b/settings.js index 5c16d27..e57ff23 100644 --- a/settings.js +++ b/settings.js @@ -13,7 +13,7 @@ export default // the base profile is shared by all bots for default prompts/examples/modes "base_profile": "./profiles/defaults/survival.json", // also see creative.json, god_mode.json "profiles": ((process.env.PROFILES) && JSON.parse(process.env.PROFILES)) || [ - "./profiles/andy.json", + "./andy.json", // "./profiles/gpt.json", // "./profiles/claude.json", // "./profiles/gemini.json", From 2597d32488317b7c79b4a2e7e971b7842f28be62 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 15 Mar 2025 14:16:03 -0500 Subject: [PATCH 07/10] move multi agent crafting tasks back --- ...ltiagent_crafting_tasks.json => multiagent_crafting_tasks.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tasks/multiagent_crafting_tasks.json => multiagent_crafting_tasks.json (100%) diff --git a/tasks/multiagent_crafting_tasks.json b/multiagent_crafting_tasks.json similarity index 100% rename from tasks/multiagent_crafting_tasks.json rename to multiagent_crafting_tasks.json From 57be4ec42ebda34717c539a976c6a0fb3206411d Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 19 Mar 2025 13:31:18 -0500 Subject: [PATCH 08/10] remove log --- src/models/prompter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/models/prompter.js b/src/models/prompter.js index 1d3b380..440160a 100644 --- a/src/models/prompter.js +++ b/src/models/prompter.js @@ -432,7 +432,6 @@ export class Prompter { async _saveToFile(logFile, logEntry) { let task_id = this.agent.task.task_id; - console.log(task_id) let logDir; if (task_id == null) { logDir = path.join(__dirname, `../../bots/${this.agent.name}/logs`); From a6cb062862910d58c3fa04f7e3f57e1511f931d8 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Wed, 19 Mar 2025 13:53:50 -0500 Subject: [PATCH 09/10] add script to run all tasks in task file --- tasks/run_task_file.py | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tasks/run_task_file.py diff --git a/tasks/run_task_file.py b/tasks/run_task_file.py new file mode 100644 index 0000000..11fec7a --- /dev/null +++ b/tasks/run_task_file.py @@ -0,0 +1,58 @@ +# run all tasks in a given file + +import os +import json +import argparse +import subprocess +import time + +def run_task(task_path, task_id, profiles=None): + """Run a single task using main.js""" + # Convert task_path to absolute path if it's relative + if not os.path.isabs(task_path): + task_path = os.path.abspath(task_path) + + cmd = ["node", "main.js", "--task_path", task_path, "--task_id", task_id] + + # Add profiles if provided + if profiles: + cmd.extend(["--profiles", *profiles]) + + print(f"Running task: {task_id}") + + project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + # Execute the command from the project root directory + process = subprocess.run(cmd, check=True, cwd=project_root) + + return process.returncode == 0 + +def main(): + parser = argparse.ArgumentParser(description='Run all tasks in a JSON file sequentially') + parser.add_argument('--task_path', required=True, help='Path to the task file') + parser.add_argument('--profiles', nargs='+', help='List of agent profile paths') + parser.add_argument('--delay', type=int, default=2, help='Delay in seconds between tasks') + + args = parser.parse_args() + + # Load the task file + with open(args.task_path, 'r') as f: + tasks = json.load(f) + + print(f"Found {len(tasks)} tasks in {args.task_path}") + + # Run each task sequentially + successful_tasks = 0 + for task_id in tasks: + success = run_task(args.task_path, task_id, args.profiles) + if success: + successful_tasks += 1 + + # Wait between tasks + time.sleep(args.delay) + + print(f"Completed {successful_tasks}/{len(tasks)} tasks successfully") + +if __name__ == "__main__": + main() + From e3d61ceead03acb14e422923171017bbc8ad2573 Mon Sep 17 00:00:00 2001 From: Isadora White Date: Thu, 20 Mar 2025 15:36:45 -0500 Subject: [PATCH 10/10] changing task path --- evaluation_script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evaluation_script.py b/evaluation_script.py index 076b3da..3df9077 100644 --- a/evaluation_script.py +++ b/evaluation_script.py @@ -399,7 +399,7 @@ def make_ops(agent_names, session_name): """Make the agents operators in the Minecraft world.""" print('Making agents operators...') - cmd = f"node main.js --task_path example_tasks.json --task_id debug_{len(agent_names)}_agent_timeout" + cmd = f"node main.js --task_path tasks/example_tasks.json --task_id debug_{len(agent_names)}_agent_timeout" subprocess.run(["tmux", "send-keys", "-t", session_name, cmd, "C-m"])