make cwd/current date available to more agents

This commit is contained in:
AI Christianson 2025-02-08 13:58:16 -05:00
parent ea992960c1
commit 5fad3fc755
2 changed files with 42 additions and 5 deletions

View File

@ -1,5 +1,6 @@
"""Utility functions for working with agents.""" """Utility functions for working with agents."""
import os
import signal import signal
import sys import sys
import threading import threading
@ -361,8 +362,12 @@ def run_research_agent(
logger.warning(f"Failed to get project info: {e}") logger.warning(f"Failed to get project info: {e}")
formatted_project_info = "" formatted_project_info = ""
current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
working_directory = os.getcwd()
prompt = (RESEARCH_ONLY_PROMPT if research_only else RESEARCH_PROMPT).format( prompt = (RESEARCH_ONLY_PROMPT if research_only else RESEARCH_PROMPT).format(
current_date=datetime.now().strftime("%Y-%m-%d"), current_date=current_date,
working_directory=working_directory,
base_task=base_task_or_query, base_task=base_task_or_query,
research_only_note=( research_only_note=(
"" ""
@ -482,8 +487,12 @@ def run_web_research_agent(
code_snippets = _global_memory.get("code_snippets", "") code_snippets = _global_memory.get("code_snippets", "")
related_files = _global_memory.get("related_files", "") related_files = _global_memory.get("related_files", "")
current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
working_directory = os.getcwd()
prompt = WEB_RESEARCH_PROMPT.format( prompt = WEB_RESEARCH_PROMPT.format(
current_date=datetime.now().strftime("%Y-%m-%d"), current_date=current_date,
working_directory=working_directory,
web_research_query=query, web_research_query=query,
expert_section=expert_section, expert_section=expert_section,
human_section=human_section, human_section=human_section,
@ -551,6 +560,14 @@ def run_planning_agent(
if thread_id is None: if thread_id is None:
thread_id = str(uuid.uuid4()) thread_id = str(uuid.uuid4())
# Get latest project info
try:
project_info = get_project_info(".")
formatted_project_info = format_project_info(project_info)
except Exception as e:
logger.warning("Failed to get project info: %s", str(e))
formatted_project_info = "Project info unavailable"
tools = get_planning_tools( tools = get_planning_tools(
expert_enabled=expert_enabled, expert_enabled=expert_enabled,
web_research_enabled=config.get("web_research_enabled", False), web_research_enabled=config.get("web_research_enabled", False),
@ -566,11 +583,17 @@ def run_planning_agent(
else "" else ""
) )
current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
working_directory = os.getcwd()
planning_prompt = PLANNING_PROMPT.format( planning_prompt = PLANNING_PROMPT.format(
current_date=current_date,
working_directory=working_directory,
expert_section=expert_section, expert_section=expert_section,
human_section=human_section, human_section=human_section,
web_research_section=web_research_section, web_research_section=web_research_section,
base_task=base_task, base_task=base_task,
project_info=formatted_project_info,
research_notes=get_memory_value("research_notes"), research_notes=get_memory_value("research_notes"),
related_files="\n".join(get_related_files()), related_files="\n".join(get_related_files()),
key_facts=get_memory_value("key_facts"), key_facts=get_memory_value("key_facts"),
@ -657,7 +680,12 @@ def run_task_implementation_agent(
agent = create_agent(model, tools, checkpointer=memory, agent_type="planner") agent = create_agent(model, tools, checkpointer=memory, agent_type="planner")
current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
working_directory = os.getcwd()
prompt = IMPLEMENTATION_PROMPT.format( prompt = IMPLEMENTATION_PROMPT.format(
current_date=current_date,
working_directory=working_directory,
base_task=base_task, base_task=base_task,
task=task, task=task,
tasks=tasks, tasks=tasks,

View File

@ -460,7 +460,7 @@ No Planning or Problem-Solving
Do not suggest fixes or improvements. Do not suggest fixes or improvements.
Do not mention what should be done. Do not mention what should be done.
Do not discuss how the code could be better structured. Do not discuss how the code could be better structured.
Do not provide advice or commentary on the project's future. Do not provide advice or commentary on the projects future.
You must remain strictly within the bounds of describing what currently exists. You must remain strictly within the bounds of describing what currently exists.
@ -506,9 +506,15 @@ NEVER ANNOUNCE WHAT YOU ARE DOING, JUST DO IT!
# Planning stage prompt - guides task breakdown and implementation planning # Planning stage prompt - guides task breakdown and implementation planning
# Includes a directive to scale complexity with request size and consult the expert (if available) for logic verification and debugging. # Includes a directive to scale complexity with request size and consult the expert (if available) for logic verification and debugging.
PLANNING_PROMPT = """Base Task: PLANNING_PROMPT = """Current Date: {current_date}
Working Directory: {working_directory}
Base Task:
{base_task} --keep it simple {base_task} --keep it simple
Project Info:
{project_info}
Research Notes: Research Notes:
<notes> <notes>
{research_notes} {research_notes}
@ -587,7 +593,10 @@ NEVER ANNOUNCE WHAT YOU ARE DOING, JUST DO IT!
# Implementation stage prompt - guides specific task implementation # Implementation stage prompt - guides specific task implementation
# Added instruction to adjust complexity of implementation to match request, and consult the expert (if available) for correctness, debugging. # Added instruction to adjust complexity of implementation to match request, and consult the expert (if available) for correctness, debugging.
IMPLEMENTATION_PROMPT = """Base-level task (for reference only): IMPLEMENTATION_PROMPT = """Current Date: {current_date}
Working Directory: {working_directory}
Base-level task (for reference only):
{base_task} --keep it simple {base_task} --keep it simple
Plan Overview (for reference only, remember you are only implementing your specific task): Plan Overview (for reference only, remember you are only implementing your specific task):