Add request_implementation tool.
This commit is contained in:
parent
ba51f99da5
commit
a01b8ebf36
|
|
@ -3,14 +3,13 @@ from ra_aid.tools import (
|
||||||
ask_expert, ask_human, run_shell_command, run_programming_task,
|
ask_expert, ask_human, run_shell_command, run_programming_task,
|
||||||
emit_research_notes, emit_plan, emit_related_files, emit_task,
|
emit_research_notes, emit_plan, emit_related_files, emit_task,
|
||||||
emit_expert_context, emit_key_facts, delete_key_facts,
|
emit_expert_context, emit_key_facts, delete_key_facts,
|
||||||
emit_key_snippets, delete_key_snippets, delete_tasks,
|
emit_key_snippets, delete_key_snippets, delete_tasks, read_file_tool,
|
||||||
request_implementation, read_file_tool,
|
|
||||||
fuzzy_find_project_files, ripgrep_search, list_directory_tree,
|
fuzzy_find_project_files, ripgrep_search, list_directory_tree,
|
||||||
swap_task_order, monorepo_detected, existing_project_detected, ui_detected,
|
swap_task_order, monorepo_detected, existing_project_detected, ui_detected,
|
||||||
task_completed, plan_implementation_completed
|
task_completed, plan_implementation_completed
|
||||||
)
|
)
|
||||||
from ra_aid.tools.memory import one_shot_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
|
# Read-only tools that don't modify system state
|
||||||
def get_read_only_tools(human_interaction: bool = False) -> list:
|
def get_read_only_tools(human_interaction: bool = False) -> list:
|
||||||
|
|
|
||||||
|
|
@ -167,3 +167,49 @@ def request_task_implementation(task_spec: str) -> Dict[str, Any]:
|
||||||
"success": success,
|
"success": success,
|
||||||
"reason": reason
|
"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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue