From 10b58bb2dbdd21c4eceabc14305ff0a9d56472e1 Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Fri, 27 Dec 2024 17:03:47 -0500 Subject: [PATCH] Simplify planning stage by executing tasks directly. Make research notes available to more agents/tools. --- ra_aid/agent_utils.py | 1 + ra_aid/prompts.py | 6 +++--- ra_aid/tool_configs.py | 6 ++---- ra_aid/tools/agent.py | 6 +----- ra_aid/tools/expert.py | 4 ++++ 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ra_aid/agent_utils.py b/ra_aid/agent_utils.py index 4abe866..c11fdfa 100644 --- a/ra_aid/agent_utils.py +++ b/ra_aid/agent_utils.py @@ -404,6 +404,7 @@ def run_task_implementation_agent( related_files=related_files, key_facts=get_memory_value('key_facts'), key_snippets=get_memory_value('key_snippets'), + research_notes=get_memory_value('research_notes'), work_log=get_memory_value('work_log'), expert_section=EXPERT_PROMPT_SECTION_IMPLEMENTATION if expert_enabled else "", human_section=HUMAN_PROMPT_SECTION_IMPLEMENTATION if _global_memory.get('config', {}).get('hil', False) else "", diff --git a/ra_aid/prompts.py b/ra_aid/prompts.py index 5512979..fcb7056 100644 --- a/ra_aid/prompts.py +++ b/ra_aid/prompts.py @@ -470,9 +470,6 @@ Guidelines: After finalizing the overall approach: Use emit_plan to store the high-level implementation plan. - For each sub-task, use emit_task to store a step-by-step description. - The description should be only as detailed as warranted by the complexity of the request. - You may use delete_tasks or swap_task_order to adjust the task list/order as you plan. Once you are absolutely sure you are completed planning, you may begin to call request_task_implementation one-by-one for each task to implement the plan. If you have any doubt about the correctness or thoroughness of the plan, consult the expert (if expert is available) for verification. @@ -506,6 +503,9 @@ Key Snippets: Relevant Files: {related_files} +Research Notes: +{research_notes} + Work done so far: {work_log} diff --git a/ra_aid/tool_configs.py b/ra_aid/tool_configs.py index 1a1d7cd..ffbf09a 100644 --- a/ra_aid/tool_configs.py +++ b/ra_aid/tool_configs.py @@ -96,10 +96,7 @@ def get_planning_tools(expert_enabled: bool = True, web_research_enabled: bool = # Add planning-specific tools planning_tools = [ - delete_tasks, emit_plan, - emit_task, - swap_task_order, request_task_implementation, plan_implementation_completed ] @@ -144,7 +141,8 @@ def get_web_research_tools(expert_enabled: bool = True) -> list: """ tools = [ web_search_tavily, - emit_research_notes + emit_research_notes, + task_completed ] if expert_enabled: diff --git a/ra_aid/tools/agent.py b/ra_aid/tools/agent.py index 4daddd4..3e892ad 100644 --- a/ra_aid/tools/agent.py +++ b/ra_aid/tools/agent.py @@ -111,12 +111,10 @@ def request_web_research(query: str) -> ResearchResult: success = True reason = None - web_research_notes = [] try: # Run web research agent from ..agent_utils import run_web_research_agent - original_research_notes = _global_memory.get('research_notes', []) result = run_web_research_agent( query, model, @@ -125,7 +123,6 @@ def request_web_research(query: str) -> ResearchResult: console_message=query, config=config ) - web_research_notes = _global_memory.get('research_notes', []) except AgentInterrupt: print() response = ask_human.invoke({"question": "Why did you interrupt me?"}) @@ -138,7 +135,6 @@ def request_web_research(query: str) -> ResearchResult: success = False reason = f"error: {str(e)}" finally: - _global_memory['research_notes'] = original_research_notes # Get completion message if available completion_message = _global_memory.get('completion_message', 'Task was completed successfully.' if success else None) @@ -155,8 +151,8 @@ def request_web_research(query: str) -> ResearchResult: return { "work_log": work_log, "completion_message": completion_message, - "web_research_notes": web_research_notes, "key_snippets": get_memory_value("key_snippets"), + "research_notes": get_memory_value("research_notes"), "success": success, "reason": reason } diff --git a/ra_aid/tools/expert.py b/ra_aid/tools/expert.py index 0532f96..056aa63 100644 --- a/ra_aid/tools/expert.py +++ b/ra_aid/tools/expert.py @@ -132,6 +132,7 @@ def ask_expert(question: str) -> str: related_contents = read_related_files(file_paths) key_snippets = get_memory_value('key_snippets') key_facts = get_memory_value('key_facts') + research_notes = get_memory_value('research_notes') # Build display query (just question) display_query = "# Question\n" + question @@ -153,6 +154,9 @@ def ask_expert(question: str) -> str: if related_contents: query_parts.extend(['# Related Files', related_contents]) + if related_contents: + query_parts.extend(['# Research Notes', research_notes]) + if key_snippets and len(key_snippets) > 0: query_parts.extend(['# Key Snippets', key_snippets])