Simplify planning stage by executing tasks directly. Make research notes available to more agents/tools.

This commit is contained in:
AI Christianson 2024-12-27 17:03:47 -05:00
parent f2ce6a7ab0
commit 10b58bb2db
5 changed files with 11 additions and 12 deletions

View File

@ -404,6 +404,7 @@ def run_task_implementation_agent(
related_files=related_files, related_files=related_files,
key_facts=get_memory_value('key_facts'), key_facts=get_memory_value('key_facts'),
key_snippets=get_memory_value('key_snippets'), key_snippets=get_memory_value('key_snippets'),
research_notes=get_memory_value('research_notes'),
work_log=get_memory_value('work_log'), work_log=get_memory_value('work_log'),
expert_section=EXPERT_PROMPT_SECTION_IMPLEMENTATION if expert_enabled else "", 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 "", human_section=HUMAN_PROMPT_SECTION_IMPLEMENTATION if _global_memory.get('config', {}).get('hil', False) else "",

View File

@ -470,9 +470,6 @@ Guidelines:
After finalizing the overall approach: After finalizing the overall approach:
Use emit_plan to store the high-level implementation plan. 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. 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. 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: Relevant Files:
{related_files} {related_files}
Research Notes:
{research_notes}
Work done so far: Work done so far:
<work log> <work log>
{work_log} {work_log}

View File

@ -96,10 +96,7 @@ def get_planning_tools(expert_enabled: bool = True, web_research_enabled: bool =
# Add planning-specific tools # Add planning-specific tools
planning_tools = [ planning_tools = [
delete_tasks,
emit_plan, emit_plan,
emit_task,
swap_task_order,
request_task_implementation, request_task_implementation,
plan_implementation_completed plan_implementation_completed
] ]
@ -144,7 +141,8 @@ def get_web_research_tools(expert_enabled: bool = True) -> list:
""" """
tools = [ tools = [
web_search_tavily, web_search_tavily,
emit_research_notes emit_research_notes,
task_completed
] ]
if expert_enabled: if expert_enabled:

View File

@ -111,12 +111,10 @@ def request_web_research(query: str) -> ResearchResult:
success = True success = True
reason = None reason = None
web_research_notes = []
try: try:
# Run web research agent # Run web research agent
from ..agent_utils import 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( result = run_web_research_agent(
query, query,
model, model,
@ -125,7 +123,6 @@ def request_web_research(query: str) -> ResearchResult:
console_message=query, console_message=query,
config=config config=config
) )
web_research_notes = _global_memory.get('research_notes', [])
except AgentInterrupt: except AgentInterrupt:
print() print()
response = ask_human.invoke({"question": "Why did you interrupt me?"}) response = ask_human.invoke({"question": "Why did you interrupt me?"})
@ -138,7 +135,6 @@ def request_web_research(query: str) -> ResearchResult:
success = False success = False
reason = f"error: {str(e)}" reason = f"error: {str(e)}"
finally: finally:
_global_memory['research_notes'] = original_research_notes
# Get completion message if available # Get completion message if available
completion_message = _global_memory.get('completion_message', 'Task was completed successfully.' if success else None) 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 { return {
"work_log": work_log, "work_log": work_log,
"completion_message": completion_message, "completion_message": completion_message,
"web_research_notes": web_research_notes,
"key_snippets": get_memory_value("key_snippets"), "key_snippets": get_memory_value("key_snippets"),
"research_notes": get_memory_value("research_notes"),
"success": success, "success": success,
"reason": reason "reason": reason
} }

View File

@ -132,6 +132,7 @@ def ask_expert(question: str) -> str:
related_contents = read_related_files(file_paths) related_contents = read_related_files(file_paths)
key_snippets = get_memory_value('key_snippets') key_snippets = get_memory_value('key_snippets')
key_facts = get_memory_value('key_facts') key_facts = get_memory_value('key_facts')
research_notes = get_memory_value('research_notes')
# Build display query (just question) # Build display query (just question)
display_query = "# Question\n" + question display_query = "# Question\n" + question
@ -153,6 +154,9 @@ def ask_expert(question: str) -> str:
if related_contents: if related_contents:
query_parts.extend(['# Related Files', 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: if key_snippets and len(key_snippets) > 0:
query_parts.extend(['# Key Snippets', key_snippets]) query_parts.extend(['# Key Snippets', key_snippets])