get rid of research summary phase

This commit is contained in:
AI Christianson 2024-12-12 07:16:31 -05:00
parent 0fc4899191
commit 5596553945
3 changed files with 3 additions and 79 deletions

View File

@ -24,7 +24,6 @@ from ra_aid.prompts import (
RESEARCH_PROMPT,
PLANNING_PROMPT,
IMPLEMENTATION_PROMPT,
SUMMARY_PROMPT
)
from ra_aid.exceptions import TaskCompletedException
import time
@ -172,42 +171,6 @@ def run_implementation_stage(base_task, tasks, plan, related_files):
# Run agent for this task
run_agent_with_retry(task_agent, task_prompt, {"configurable": {"thread_id": "abc123"}, "recursion_limit": 100})
def summarize_research_findings(base_task: str, config: dict) -> None:
"""Summarize research findings for informational queries.
Generates and prints a concise summary of research findings including key facts
and research notes collected during the research stage.
Args:
base_task: The original user query
config: Configuration dictionary for the agent
"""
print_stage_header("Research Summary")
# Create dedicated memory for research summarization
summary_memory = MemorySaver()
# Create fresh agent for summarization with its own memory
summary_agent = create_react_agent(model, implementation_tools, checkpointer=summary_memory)
summary_prompt = SUMMARY_PROMPT.format(
base_task=base_task,
research_notes=get_memory_value('research_notes'),
key_facts=get_memory_value('key_facts'),
key_snippets=get_memory_value('key_snippets')
)
while True:
try:
for chunk in summary_agent.stream(
{"messages": [HumanMessage(content=summary_prompt)]},
config
):
print_agent_output(chunk)
break
except ChatAnthropic.InternalServerError as e:
print(f"Encountered Anthropic Internal Server Error: {e}. Retrying...")
continue
def run_research_subtasks(base_task: str, config: dict):
"""Run research subtasks with separate agents."""
@ -301,11 +264,8 @@ Be very thorough in your research and emit lots of snippets, key facts. If you t
# Run any research subtasks
run_research_subtasks(base_task, config)
# For informational queries, summarize findings
if is_informational_query():
summarize_research_findings(base_task, config)
else:
# Only proceed with planning and implementation if not an informational query
# Proceed with planning and implementation if not an informational query
if not is_informational_query():
print_stage_header("Planning Stage")
planning_prompt = PLANNING_PROMPT.format(
research_notes=get_memory_value('research_notes'),

View File

@ -19,7 +19,6 @@ def print_stage_header(stage: str) -> None:
'task completed': '',
'debug stage': '🐛',
'testing stage': '🧪',
'research summary': '📋',
'research subtasks': '📚',
'skipping implementation stage': '⏭️'
}

View File

@ -72,7 +72,7 @@ Single-Shot Task Detection
- Situations where immediate response meets all user requirements
One-shot completion will be blocked if:
- Research subtasks have been requested (must wait for research summary)
- Research subtasks have been requested
- Complex implementation has been explicitly requested
If you determine a task can be completed in a single shot:
@ -163,41 +163,6 @@ Guidelines:
Do not implement anything yet.
"""
# Research summary prompt - guides generation of research summaries
# Remains essentially the same, but with complexity scaling if needed.
SUMMARY_PROMPT = """
Using only the information provided in the Research Notes and Key Facts below, write a concise and direct answer to the user's query.
User's Query:
{base_task}
Research Notes:
{research_notes}
Key Facts:
{key_facts}
Key Snippets:
{key_snippets}
Fact Management:
Each fact is identified with [Fact ID: X].
Facts may be deleted if they become outdated, irrelevant, or duplicates.
Use delete_key_facts([id1, id2, ...]) with a list of numeric Fact IDs to remove unnecessary facts.
Snippet Management:
Each snippet is identified with [Snippet ID: X].
Snippets include file path, line number, and source code.
Snippets may have optional descriptions explaining their significance.
Delete snippets with delete_key_snippets([id1, id2, ...]) to remove outdated or irrelevant ones.
Use emit_key_snippets to store important code sections needed for reference in batches.
Instructions:
- **Stay Within Provided Information**: Do not include any information not present in the Research Notes or Key Facts.
- **Handle Contradictions Appropriately**: If contradictions exist, consider additional research or note the contradictions.
- **Maintain Focus and Brevity**: Keep the response concise, focusing on the user's query.
- **Include Technical Details If Relevant**: For technical queries, reference discovered files and snippets.
"""
# Implementation stage prompt - guides specific task implementation
# Added instruction to adjust complexity of implementation to match request.