From 57c47c0bcf576f30b5ebf43113c1d61d91416fe9 Mon Sep 17 00:00:00 2001 From: Ayush Maniar Date: Sun, 23 Feb 2025 03:21:59 -0800 Subject: [PATCH] Provide agent specific goals in task, added more example tasks --- example_tasks.json | 48 +++++++++++++++++++++++++++------------------- src/agent/tasks.js | 25 ++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/example_tasks.json b/example_tasks.json index 44d8943..a1287c2 100644 --- a/example_tasks.json +++ b/example_tasks.json @@ -17,6 +17,14 @@ }, "type": "debug" }, + "debug_different_goal": { + "goal": { + "0": "Reply to all messages with star emojis when prompted", + "1": "Reply to all messages with heart emojis when prompted" + }, + "agent_count": 2, + "type": "debug" + }, "debug_inventory_restriction": { "goal": "Place 1 oak plank, then place 1 stone brick", "initial_inventory": { @@ -90,6 +98,25 @@ "type": "techtree", "timeout": 300 }, + "multiagent_smelt_ingot": { + "conversation": "Let's collaborate to smelt ingots", + "goal": "Smelt 1 iron ingot and 1 copper ingot, use star emojis in every response", + "agent_count": 2, + "initial_inventory": { + "0": { + "furnace": 1, + "coal": 2 + }, + "1": { + "raw_iron": 1, + "raw_copper": 1 + } + }, + "target": "copper_ingot", + "number_of_target": 1, + "type": "techtree", + "timeout": 300 + }, "multiagent_cooking_1": { "conversation": "Let's collaborate to make dinner, I am going to search for 'potatoes' and make 1 'baked_potato', you on the other hand, search for cow and cook 1 beef. We have a furnace (fuel already present) nearby to help us cook, search for it over long distances to find it. Note : We only need one of each item, lets not waste time by collecting unnecessary resources.", "agent_count": 2, @@ -122,24 +149,5 @@ }, "blocked_access_to_recipe": [], "goal": "Collaborate to make 1 bread, 1 cooked_mutton" - }, - "multiagent_smelt_ingot": { - "conversation": "Let's collaborate to smelt ingots", - "goal": "Smelt 1 iron ingot and 1 copper ingot, use star emojis in every response", - "agent_count": 2, - "initial_inventory": { - "0": { - "furnace": 1, - "coal": 2 - }, - "1": { - "raw_iron": 1, - "raw_copper": 1 - } - }, - "target": "copper_ingot", - "number_of_target": 1, - "type": "techtree", - "timeout": 300 - } + } } \ No newline at end of file diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 96b3849..770a939 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -150,6 +150,25 @@ export class Task { this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name); } + getAgentGoal() { + if (!this.data || !this.data.goal) { + return null; + } + + // If goal is a string, all agents share the same goal + if (typeof this.data.goal === 'string') { + return this.data.goal; + } + + // If goal is an object, get the goal for this agent's count_id + if (typeof this.data.goal === 'object' && this.data.goal !== null) { + const agentId = this.agent.count_id.toString(); + return this.data.goal[agentId] || null; + } + + return null; + } + loadTask(task_path, task_id) { try { const tasksFile = readFileSync(task_path, 'utf8'); @@ -242,8 +261,10 @@ export class Task { } } - if (this.data.goal) { - await executeCommand(this.agent, `!goal("${this.data.goal}")`); + const agentGoal = this.getAgentGoal(); + if (agentGoal) { + console.log(`Setting goal for agent ${this.agent.count_id}: ${agentGoal}`); + await executeCommand(this.agent, `!goal("${agentGoal}")`); } if (this.data.conversation && this.agent.count_id === 0) {