adjust one shot behavior; temporarily take out str replace/write file tools

This commit is contained in:
AI Christianson 2024-12-17 12:16:32 -05:00
parent 64a64053b8
commit ceef1519db
5 changed files with 18 additions and 28 deletions

View File

@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.6.1] - 2024-12-17
### Added
- When key snippets are emitted, snippet files are auto added to related files.
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Track tasks by ID and allow them to be deleted.
- Make one_shot_completed tool available to research agent.
- Make sure file modification tools are not available when research only flag is used.
- Temporarily disable write file/str replace as they do not work as well as just using the programmer tool.
## [0.6.0] - 2024-12-17

View File

@ -1,12 +1,7 @@
import sqlite3
import argparse
import glob
import os
import sys
import shutil
from rich.panel import Panel
from rich.console import Console
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage
from langgraph.checkpoint.memory import MemorySaver
from langgraph.prebuilt import create_react_agent
@ -15,8 +10,8 @@ from ra_aid.tools import (
emit_research_notes, emit_plan, emit_related_files, emit_task,
emit_expert_context, get_memory_value, emit_key_facts, delete_key_facts,
emit_key_snippets, delete_key_snippets,
emit_research_subtask, request_complex_implementation, read_file_tool, write_file_tool, fuzzy_find_project_files, ripgrep_search, list_directory_tree,
file_str_replace, swap_task_order
emit_research_subtask, request_implementation, read_file_tool, fuzzy_find_project_files, ripgrep_search, list_directory_tree,
swap_task_order
)
from ra_aid.env import validate_environment
from ra_aid.tools.memory import _global_memory, get_related_files, one_shot_completed
@ -45,17 +40,12 @@ READ_ONLY_TOOLS = [
# Tools that can modify files or system state
MODIFICATION_TOOLS = [
write_file_tool,
file_str_replace,
run_shell_command,
run_programming_task
]
# Common tools used across multiple agents
COMMON_TOOLS = READ_ONLY_TOOLS + [
write_file_tool,
file_str_replace
]
COMMON_TOOLS = READ_ONLY_TOOLS + []
# Expert-specific tools
EXPERT_TOOLS = [
@ -157,7 +147,7 @@ def get_research_tools(research_only: bool = False, expert_enabled: bool = True)
# Add modification tools if not research_only
if not research_only:
tools.extend(MODIFICATION_TOOLS)
tools.append(request_complex_implementation)
tools.append(request_implementation)
# Add expert tools if enabled
if expert_enabled:

View File

@ -65,10 +65,10 @@ No Planning or Problem-Solving
You must remain strictly within the bounds of describing what currently exists.
If this is a simple task that can be completed in one shot, do the change using tools available and call one_shot_completed.
Only use single-shot completion for truly straightforward tasks that don't require additional planning or extensive changes.
If the change is estimated to be less than 100 lines and less than 5 files, it is definitely a single-shot task.
If the task requires *ANY* compilation, unit tests, or any other non-trivial changes, call request_implementation.
If this is a trival task that can be completed in one shot, do the change using tools available and call one_shot_completed.
Remember, many tasks are more complex and nuanced than they seem and still require requesting implementation.
For one shot tasks, still take some time to consider whether compilation, testing, or additional validation should be done to check your work.
Thoroughness and Completeness
@ -83,7 +83,7 @@ Thoroughness and Completeness
Decision on Implementation
After completing your factual enumeration and description, decide:
If you see reasons that implementation changes will be required in the future, after documenting all findings, call request_complex_implementation and specify why.
If you see reasons that implementation changes will be required in the future, after documenting all findings, call request_implementation and specify why.
If no changes are needed, simply state that no changes are required.
Be thorough on locating all potential change sites/gauging blast radius.

View File

@ -9,7 +9,7 @@ from .list_directory import list_directory_tree
from .ripgrep import ripgrep_search
from .memory import (
emit_research_notes, emit_plan, emit_task, get_memory_value, emit_key_facts,
request_complex_implementation, skip_implementation, delete_key_facts, emit_research_subtask,
request_implementation, skip_implementation, delete_key_facts, emit_research_subtask,
emit_key_snippets, delete_key_snippets, emit_related_files, swap_task_order
)
@ -28,7 +28,7 @@ __all__ = [
'get_memory_value',
'list_directory_tree',
'read_file_tool',
'request_complex_implementation',
'request_implementation',
'run_programming_task',
'run_shell_command',
'skip_implementation',

View File

@ -141,7 +141,7 @@ def delete_key_facts(fact_ids: List[int]) -> str:
# Delete the fact
deleted_fact = _global_memory['key_facts'].pop(fact_id)
success_msg = f"Successfully deleted fact #{fact_id}: {deleted_fact}"
console.print(Panel(Markdown(success_msg), title="🗑️ Fact Deleted", border_style="green"))
console.print(Panel(Markdown(success_msg), title="Fact Deleted", border_style="green"))
results.append(success_msg)
return "Facts deleted."
@ -164,17 +164,16 @@ def delete_tasks(task_ids: List[int]) -> str:
deleted_task = _global_memory['tasks'].pop(task_id)
success_msg = f"Successfully deleted task #{task_id}: {deleted_task}"
console.print(Panel(Markdown(success_msg),
title="🗑️ Task Deleted",
title="Task Deleted",
border_style="green"))
results.append(success_msg)
return "Tasks deleted."
@tool("request_complex_implementation")
def request_complex_implementation(reason: str) -> str:
@tool("request_implementation")
def request_implementation(reason: str) -> str:
"""Request that implementation proceed after research/planning.
Used to indicate the agent should move to implementation stage.
Should be called when the implementation is more complex than a one-shot task.
Args:
reason: Why implementation should proceed
@ -270,7 +269,7 @@ def delete_key_snippets(snippet_ids: List[int]) -> str:
deleted_snippet = _global_memory['key_snippets'].pop(snippet_id)
success_msg = f"Successfully deleted snippet #{snippet_id} from {deleted_snippet['filepath']}"
console.print(Panel(Markdown(success_msg),
title="🗑️ Snippet Deleted",
title="Snippet Deleted",
border_style="green"))
results.append(success_msg)