From e81421a95aff68e70f8d9a21c8621337ff52c86d Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Mon, 10 Mar 2025 15:30:22 -0400 Subject: [PATCH] improve prompts --- ra_aid/agents/research_agent.py | 4 ++- ra_aid/prompts/reasoning_assist_prompt.py | 30 +++++++++++++++++++++++ ra_aid/prompts/research_prompts.py | 9 +++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ra_aid/agents/research_agent.py b/ra_aid/agents/research_agent.py index b5903a7..667f07b 100644 --- a/ra_aid/agents/research_agent.py +++ b/ra_aid/agents/research_agent.py @@ -333,7 +333,9 @@ def run_research_agent( if expert_guidance: expert_guidance_section = f""" {expert_guidance} -""" + +YOU MUST FOLLOW THE EXPERT'S GUIDANCE OR ELSE BE TERMINATED! +""" # Format research notes if available # We get research notes earlier for reasoning assistance diff --git a/ra_aid/prompts/reasoning_assist_prompt.py b/ra_aid/prompts/reasoning_assist_prompt.py index 075dad5..77a4bea 100644 --- a/ra_aid/prompts/reasoning_assist_prompt.py +++ b/ra_aid/prompts/reasoning_assist_prompt.py @@ -48,6 +48,19 @@ Given the available information, tools, and base task, write a couple paragraphs The agent has a tendency to do the same work/functin calls over and over again. Answer quickly and confidently with five sentences at most. + +DO NOT WRITE CODE +WRITE AT LEAST ONE SENTENCE +WRITE NO MORE THAN FIVE PARAGRAPHS. +WRITE ABOUT HOW THE AGENT WILL USE THE TOOLS AVAILABLE TO EFFICIENTLY ACCOMPLISH THE GOAL. +REFERENCE ACTUAL TOOL NAMES IN YOUR WRITING, BUT KEEP THE WRITING PLAIN LOGICAL ENGLISH. +BE DETAILED AND INCLUDE LOGIC BRANCHES FOR WHAT TO DO IF DIFFERENT TOOLS RETURN DIFFERENT THINGS. +THINK OF IT AS A FLOW CHART BUT IN NATURAL ENGLISH. +REMEMBER THE ULTIMATE GOAL AT THIS STAGE IS TO BREAK THINGS DOWN INTO DISCRETE TASKS AND CALL request_task_implementation FOR EACH TASK. +PROPOSE THE TASK BREAKDOWN TO THE AGENT. INCLUDE THIS AS A BULLETED LIST IN YOUR GUIDANCE. +WE ARE NOT WRITING ANY CODE AT THIS STAGE. +THE AGENT IS VERY FORGETFUL AND YOUR WRITING MUST INCLUDE REMARKS ABOUT HOW IT SHOULD USE *ALL* AVAILABLE TOOLS, INCLUDING AND ESPECIALLY ask_expert. +THE AGENT IS DUMB AND NEEDS REALLY DETAILED GUIDANCE LIKE LITERALLY REMINDING IT TO CALL request_task_implementation FOR EACH TASK IN YOUR BULLETED LIST. """ REASONING_ASSIST_PROMPT_IMPLEMENTATION = """Current Date: {current_date} @@ -93,6 +106,14 @@ IF ANYTHING AT ALL GOES WRONG, CALL ask_expert. Given the available information, tools, and base task, write a couple paragraphs about how an agentic system might use the available tools to implement the given task definition. The agent will be writing code and making changes at this point. Answer quickly and confidently with a few sentences at most. + +WRITE AT LEAST ONE SENTENCE +WRITE NO MORE THAN FIVE PARAGRAPHS. +WRITE ABOUT HOW THE AGENT WILL USE THE TOOLS AVAILABLE TO EFFICIENTLY ACCOMPLISH THE GOAL. +REFERENCE ACTUAL TOOL NAMES IN YOUR WRITING, BUT KEEP THE WRITING PLAIN LOGICAL ENGLISH. +BE DETAILED AND INCLUDE LOGIC BRANCHES FOR WHAT TO DO IF DIFFERENT TOOLS RETURN DIFFERENT THINGS. +THE AGENT IS VERY FORGETFUL AND YOUR WRITING MUST INCLUDE REMARKS ABOUT HOW IT SHOULD USE *ALL* AVAILABLE TOOLS, INCLUDING AND ESPECIALLY ask_expert. +THINK OF IT AS A FLOW CHART BUT IN NATURAL ENGLISH. """ REASONING_ASSIST_PROMPT_RESEARCH = """Current Date: {current_date} @@ -136,4 +157,13 @@ IF INFORMATION IS TOO COMPLEX TO UNDERSTAND, THE AGENT SHOULD USE ask_expert. Given the available information, tools, and base task or query, write a couple paragraphs about how an agentic system might use the available tools to research the codebase, identify important components, gather key information, and emit key facts and snippets. The focus is on thorough investigation and understanding before any implementation. Remember, the research agent generally should emit research notes at the end of its execution, right before it calls request_implementation if a change or new work is required. Answer quickly and confidently with five sentences at most. + +DO NOT WRITE CODE +WRITE AT LEAST ONE SENTENCE +WRITE NO MORE THAN FIVE PARAGRAPHS. +WRITE ABOUT HOW THE AGENT WILL USE THE TOOLS AVAILABLE TO EFFICIENTLY ACCOMPLISH THE GOAL. +REFERENCE ACTUAL TOOL NAMES IN YOUR WRITING, BUT KEEP THE WRITING PLAIN LOGICAL ENGLISH. +BE DETAILED AND INCLUDE LOGIC BRANCHES FOR WHAT TO DO IF DIFFERENT TOOLS RETURN DIFFERENT THINGS. +THINK OF IT AS A FLOW CHART BUT IN NATURAL ENGLISH. +THE AGENT IS VERY FORGETFUL AND YOUR WRITING MUST INCLUDE REMARKS ABOUT HOW IT SHOULD USE *ALL* AVAILABLE TOOLS, INCLUDING AND ESPECIALLY ask_expert. """ diff --git a/ra_aid/prompts/research_prompts.py b/ra_aid/prompts/research_prompts.py index 8388c12..b458b4c 100644 --- a/ra_aid/prompts/research_prompts.py +++ b/ra_aid/prompts/research_prompts.py @@ -123,7 +123,6 @@ If you find this is an empty directory, you can stop research immediately and as {expert_section} {human_section} {web_research_section} -{expert_guidance_section} You have often been criticized for: - Needlessly requesting more research tasks, especially for general background knowledge which you already know. @@ -180,12 +179,12 @@ If this is a top-level README.md or docs folder, start there. If the user explicitly requests implementation, that means you should first perform all the background research for that task, then call request_implementation where the implementation will be carried out. +{expert_guidance_section} + {base_task} -{expert_guidance_section} - USER QUERY *ALWAYS* TAKES PRECEDENCE OVER EVERYTHING IN PREVIOUS RESEARCH. KEEP IT SIMPLE @@ -207,12 +206,12 @@ You have been spawned by a higher level research agent, so only spawn more resea When you emit research notes, keep it extremely concise and relevant only to the specific research subquery you've been assigned. +{expert_guidance_section} + {base_task} -{expert_guidance_section} - USER QUERY *ALWAYS* TAKES PRECEDENCE OVER EVERYTHING IN PREVIOUS RESEARCH. KEEP IT SIMPLE