Add request_implementation tool.

This commit is contained in:
user 2024-12-21 14:20:06 -05:00
parent ba51f99da5
commit a01b8ebf36
2 changed files with 48 additions and 3 deletions

View File

@ -3,14 +3,13 @@ from ra_aid.tools import (
ask_expert, ask_human, run_shell_command, run_programming_task,
emit_research_notes, emit_plan, emit_related_files, emit_task,
emit_expert_context, emit_key_facts, delete_key_facts,
emit_key_snippets, delete_key_snippets, delete_tasks,
request_implementation, read_file_tool,
emit_key_snippets, delete_key_snippets, delete_tasks, read_file_tool,
fuzzy_find_project_files, ripgrep_search, list_directory_tree,
swap_task_order, monorepo_detected, existing_project_detected, ui_detected,
task_completed, plan_implementation_completed
)
from ra_aid.tools.memory import one_shot_completed
from ra_aid.tools.agent import request_research, request_research_and_implementation, request_task_implementation
from ra_aid.tools.agent import request_research, request_implementation, request_research_and_implementation, request_task_implementation
# Read-only tools that don't modify system state
def get_read_only_tools(human_interaction: bool = False) -> list:

View File

@ -167,3 +167,49 @@ def request_task_implementation(task_spec: str) -> Dict[str, Any]:
"success": success,
"reason": reason
}
@tool("request_implementation")
def request_implementation(task_spec: str) -> Dict[str, Any]:
"""Spawn a planning agent to create an implementation plan for the given task.
Args:
task_spec: The task specification to plan implementation for
Returns:
Dict containing:
- facts: Current key facts
- files: Related files
- success: Whether completed or interrupted
- reason: Reason for failure, if any
"""
# Initialize model from config
config = _global_memory.get('config', {})
model = initialize_llm(config.get('provider', 'anthropic'), config.get('model', 'claude-3-5-sonnet-20241022'))
try:
# Run planning agent
from ..agent_utils import run_planning_agent
result = run_planning_agent(
task_spec,
model,
expert_enabled=True,
hil=_global_memory.get('config', {}).get('hil', False)
)
success = True
reason = None
except KeyboardInterrupt:
console.print("\n[yellow]Planning interrupted by user[/yellow]")
success = False
reason = "cancelled_by_user"
except Exception as e:
console.print(f"\n[red]Error during planning: {str(e)}[/red]")
success = False
reason = f"error: {str(e)}"
return {
"facts": get_memory_value("key_facts"),
"files": list(get_related_files()),
"success": success,
"reason": reason
}