From b75d941d976510eec9154825989b0e3c84fb953d Mon Sep 17 00:00:00 2001 From: Isadora White Date: Sat, 8 Mar 2025 19:24:13 -0800 Subject: [PATCH] smol changes --- .gitignore | 7 +- evaluation_script.py | 24 ++++-- profiles/tasks/collab_profile.json | 2 +- src/models/prompter.js | 9 ++- tasks/crafting_tasks/debug_tasks.json | 112 ++++++++++++++++++++++++++ 5 files changed, 143 insertions(+), 11 deletions(-) create mode 100644 tasks/crafting_tasks/debug_tasks.json diff --git a/.gitignore b/.gitignore index dc9fb86..a1b615b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,10 @@ experiments/ andy_*.json jill_*.json src/models/logs/* +<<<<<<< HEAD +server_data/* +server_data_*/* +======= server_data* -results/* \ No newline at end of file +results/* +>>>>>>> d70491e5974a973b96c47f0515c2722b82c9b253 diff --git a/evaluation_script.py b/evaluation_script.py index 74c3ae8..c04d057 100644 --- a/evaluation_script.py +++ b/evaluation_script.py @@ -114,7 +114,8 @@ def launch_parallel_experiments(task_path, s3=False, bucket_name="mindcraft-experiments", template_profile="profiles/collab_profile.json", - world_name="Forest"): + world_name="Forest", + insecure_coding=False): with open(task_path, 'r', encoding='utf-8') as file: content = file.read() @@ -144,7 +145,8 @@ def launch_parallel_experiments(task_path, bucket_name=bucket_name, template_profile=template_profile, model=model, - api=api) + api=api, + insecure_coding=insecure_coding) time.sleep(5) def launch_server_experiment(task_path, @@ -154,11 +156,12 @@ def launch_server_experiment(task_path, experiments_folder, exp_name="exp", num_agents=2, - model="gpt-4o-mini", + model="gpt-4o", api="openai", s3=False, bucket_name="mindcraft-experiments", - template_profile="profiles/collab_profile.json"): + template_profile="profiles/collab_profile.json", + insecure_coding=False): """ Launch a Minecraft server and run experiments on it. @param task_path: Path to the task file @@ -199,7 +202,8 @@ def launch_server_experiment(task_path, set_environment_variable_tmux_session(session_name, "MINECRAFT_PORT", server_port) set_environment_variable_tmux_session(session_name, "MINDSERVER_PORT", mindserver_port) set_environment_variable_tmux_session(session_name, "PROFILES", agent_profiles_str) - set_environment_variable_tmux_session(session_name, "INSECURE_CODING", "true") + if insecure_coding: + set_environment_variable_tmux_session(session_name, "INSECURE_CODING", "true") # you need to add the bots to the world first before you can add them as op cmd = f"node main.js --task_path example_tasks.json --task_id debug_multi_agent_timeout" @@ -228,7 +232,6 @@ def launch_server_experiment(task_path, script_content += "sleep 2\n" for agent in agent_names: agent_file_path = os.path.join(task_folder, f"{agent}_{_}.json") - assert os.path.exists(f"bots/{agent}/memory.json"), f"Source file bots/{agent}/memory.json does not exist" script_content += f"echo 'Saving to {agent_file_path}'\n" cp_cmd = f"cp bots/{agent}/memory.json {agent_file_path}" script_content += f"echo '{cp_cmd}'\n" @@ -242,6 +245,9 @@ def launch_server_experiment(task_path, script_content += f"{s3_cmd}\n" script_content += "sleep 1\n" script_content += f"sleep 10\n" + if s3: + for agent in agent_names: + script_content += f"aws s3 cp bots/{agent} s3://{bucket_name}/{exp_name}/bots/{agent} --recursive\n" # Create a temporary shell script file script_file = f"./tmp/experiment_script_{session_name}.sh" @@ -400,10 +406,11 @@ def main(): parser.add_argument('--s3', action='store_true', help='Whether to upload to s3') parser.add_argument('--bucket_name', default="mindcraft-experiments", help='Name of the s3 bucket') parser.add_argument('--add_keys', action='store_true', help='Create the keys.json to match the environment variables') - parser.add_argument('--template_profile', default="profiles/collab_profile.json", help='Model to use for the agents') + parser.add_argument('--template_profile', default="profiles/tasks/collab_profile.json", help='Model to use for the agents') parser.add_argument('--model', default="gpt-4o-mini", help='Model to use for the agents') parser.add_argument('--api', default="openai", help='API to use for the agents') parser.add_argument('--world_name', default="Forest", help='Name of the world') + parser.add_argument('--insecure_coding', action='store_true', help='Enable insecure coding') args = parser.parse_args() @@ -426,7 +433,8 @@ def main(): template_profile=args.template_profile, model=args.model, api=args.api, - world_name=args.world_name) + world_name=args.world_name, + insecure_coding=args.insecure_coding) cmd = "aws s3" if __name__ == "__main__": diff --git a/profiles/tasks/collab_profile.json b/profiles/tasks/collab_profile.json index 80d0d9d..ef8325e 100644 --- a/profiles/tasks/collab_profile.json +++ b/profiles/tasks/collab_profile.json @@ -4,7 +4,7 @@ "modes": { "hunting": false }, - "conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands.\n$SELF_PROMPT Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer(\"playername\", 3)'. Respond only as $NAME, never output '(FROM OTHER BOT)' or pretend to be someone else. If you have nothing to say or do, respond with an just a tab '\t'. Share resources and information with other bots! This is extremely important to me, take a deep breath and have fun :) \nSummarized memory:'$MEMORY'\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", + "conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands.\n$SELF_PROMPT Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer(\"playername\", 3)'. Respond only as $NAME, never output '(FROM OTHER BOT)' or pretend to be someone else. If you have nothing to say or do, respond with an just a tab '\t'. Share resources and information with other bots! This is extremely important to me, take a deep breath and have fun :) \nSummarized memory:'$MEMORY'\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\n Your name is $NAME, do not pretend to be other bots. Conversation Begin:", "saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. $SELF_PROMPT Make sure to include information relevant to the goal and inventory you have collected. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ", "conversation_examples": [ [ diff --git a/src/models/prompter.js b/src/models/prompter.js index 38b8b29..aa896da 100644 --- a/src/models/prompter.js +++ b/src/models/prompter.js @@ -359,7 +359,14 @@ export class Prompter { // Create directory if it doesn't exist const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); - const logDir = path.join(__dirname, 'logs', String(task_id)); + let logDir; + if (this.task_id) { + task_id = this.task_id; + 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 }); // Write prompt & conversation to a task-specific file diff --git a/tasks/crafting_tasks/debug_tasks.json b/tasks/crafting_tasks/debug_tasks.json new file mode 100644 index 0000000..38e00b1 --- /dev/null +++ b/tasks/crafting_tasks/debug_tasks.json @@ -0,0 +1,112 @@ +{ + "multiagent_crafting_magma_block_no_plan__depth_0": { + "goal": "Collaborate with other agents to craft an magma_block", + "conversation": "Let's work together to craft an magma_block.", + "initial_inventory": { + "0": { + "magma_cream": 3 + }, + "1": { + "magma_cream": 2 + } + }, + "agent_count": 2, + "target": "magma_block", + "number_of_target": 1, + "type": "techtree", + "max_depth": 2, + "depth": 0, + "timeout": 240, + "blocked_actions": { + "0": [ + "!getCraftingPlan" + ], + "1": [ + "!getCraftingPlan" + ] + }, + "missing_items": [] + }, + "multiagent_crafting_polished_diorite_no_plan__depth_0": { + "goal": "Collaborate with other agents to craft an polished_diorite", + "conversation": "Let's work together to craft an polished_diorite.", + "initial_inventory": { + "0": { + "diorite": 3 + }, + "1": { + "diorite": 2 + } + }, + "agent_count": 2, + "target": "polished_diorite", + "number_of_target": 1, + "type": "techtree", + "max_depth": 1, + "depth": 0, + "timeout": 240, + "blocked_actions": { + "0": [ + "!getCraftingPlan" + ], + "1": [ + "!getCraftingPlan" + ] + }, + "missing_items": [] + }, + "multiagent_crafting_blast_furnace_full_plan__depth_0": { + "goal": "Collaborate with other agents to craft an blast_furnace", + "conversation": "Let's work together to craft an blast_furnace.", + "initial_inventory": { + "0": { + "iron_ingot": 3, + "furnace": 1, + "smooth_stone": 2 + }, + "1": { + "iron_ingot": 2, + "smooth_stone": 1 + } + }, + "agent_count": 2, + "target": "blast_furnace", + "number_of_target": 1, + "type": "techtree", + "max_depth": 1, + "depth": 0, + "timeout": 240, + "blocked_actions": { + "0": [], + "1": [] + }, + "missing_items": [] + }, + "multiagent_crafting_comparator_full_plan__depth_0": { + "goal": "Collaborate with other agents to craft an comparator", + "conversation": "Let's work together to craft an comparator.", + "initial_inventory": { + "0": { + "redstone_torch": 2, + "quartz": 1, + "stone": 2 + }, + "1": { + "redstone_torch": 1, + "stone": 1 + } + }, + "agent_count": 2, + "target": "comparator", + "number_of_target": 1, + "type": "techtree", + "max_depth": 3, + "depth": 0, + "timeout": 240, + "blocked_actions": { + "0": [], + "1": [] + }, + "missing_items": [] + } +} \ No newline at end of file