From c0a874b90e3d4eb3930bd282559e617b15667f0f Mon Sep 17 00:00:00 2001 From: Joshua Smith Date: Tue, 11 Mar 2025 15:52:47 -0400 Subject: [PATCH] added some workflow debugging, converted from "done" to pick-new-goal and updated prompts --- prompts/agent_prompt_generators.py | 12 ++++++------ workflows/agent_goal_workflow.py | 15 +++++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/prompts/agent_prompt_generators.py b/prompts/agent_prompt_generators.py index cbd0d97..8a001f3 100644 --- a/prompts/agent_prompt_generators.py +++ b/prompts/agent_prompt_generators.py @@ -68,7 +68,7 @@ def generate_genai_prompt( "Your JSON format must be:\n" "{\n" ' "response": "",\n' - ' "next": "",\n' + ' "next": "",\n' ' "tool": "",\n' ' "args": {\n' ' "": "",\n' @@ -122,11 +122,11 @@ def generate_tool_completion_prompt(current_tool: str, dynamic_result: dict) -> return ( f"### The '{current_tool}' tool completed successfully with {dynamic_result}. " "INSTRUCTIONS: Parse this tool result as plain text, and use the system prompt containing the list of tools in sequence and the conversation history (and previous tool_results) to figure out next steps, if any. " - "You will need to use the tool_results to auto-fill arguments for subsequent tools and also to figure out if all tools have been run." - '{"next": "", "tool": "", "args": {"": "", "": "}, "response": ""}' - "ONLY return those json keys (next, tool, args, response), nothing else." - 'Next should be "question" if the tool is not the last one in the sequence.' - 'Next should only be "confirm" if all tools have been run (use the system prompt to figure that out).' + "You will need to use the tool_results to auto-fill arguments for subsequent tools and also to figure out if all tools have been run. " + '{"next": "", "tool": "", "args": {"": "", "": "}, "response": ""}' + "ONLY return those json keys (next, tool, args, response), nothing else. " + 'Next should be "question" if the tool is not the last one in the sequence. ' + 'Next should only be "pick-new-goal" if all tools have been run (use the system prompt to figure that out).' ) def generate_missing_args_prompt(current_tool: str, tool_data: dict, missing_args: list[str]) -> str: diff --git a/workflows/agent_goal_workflow.py b/workflows/agent_goal_workflow.py index ba5652b..4a6f3eb 100644 --- a/workflows/agent_goal_workflow.py +++ b/workflows/agent_goal_workflow.py @@ -169,8 +169,13 @@ class AgentGoalWorkflow: # move forward in the tool chain next_step = tool_data.get("next") current_tool = tool_data.get("tool") + if "next" in self.tool_data.keys(): + workflow.logger.warning(f"ran the toolplanner, next step: {next_step}") + else: + workflow.logger.warning("ran the toolplanner, next step not set!") if next_step == "confirm" and current_tool: + workflow.logger.warning("ran the toolplanner, trying to confirm") args = tool_data.get("args", {}) if await helpers.handle_missing_args(current_tool, args, tool_data, self.prompt_queue): continue @@ -180,10 +185,12 @@ class AgentGoalWorkflow: workflow.logger.info("Waiting for user confirm signal...") # todo probably here we can set the next step to be change-goal - elif next_step == "done": - workflow.logger.info("All steps completed. Exiting workflow.") - self.add_message("agent", tool_data) - return str(self.conversation_history) + elif next_step == "pick-new-goal": + workflow.logger.info("All steps completed. Resetting goal.") + #self.add_message("agent", tool_data) + workflow.logger.warning("pick-new-goal time, setting goal to goal_choose_agent_type") + self.change_goal("goal_choose_agent_type") + #return str(self.conversation_history) self.add_message("agent", tool_data) await helpers.continue_as_new_if_needed(