do one shot projects
This commit is contained in:
parent
6b3be3c965
commit
d302222c3e
|
|
@ -24,6 +24,7 @@ from ra_aid.prompts import (
|
|||
IMPLEMENTATION_PROMPT,
|
||||
SUMMARY_PROMPT
|
||||
)
|
||||
from ra_aid.exceptions import TaskCompletedException
|
||||
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -237,6 +238,7 @@ def validate_environment():
|
|||
|
||||
def main():
|
||||
"""Main entry point for the ra-aid command line tool."""
|
||||
try:
|
||||
validate_environment()
|
||||
args = parse_arguments()
|
||||
base_task = args.message
|
||||
|
|
@ -260,6 +262,7 @@ def main():
|
|||
|
||||
Be very thorough in your research and emit lots of snippets, key facts. If you take more than a few steps, be eager to emit research subtasks.{'' if args.research_only else ' Only request implementation if the user explicitly asked for changes to be made.'}"""
|
||||
|
||||
try:
|
||||
while True:
|
||||
try:
|
||||
for chunk in research_agent.stream(
|
||||
|
|
@ -271,6 +274,9 @@ Be very thorough in your research and emit lots of snippets, key facts. If you t
|
|||
except ChatAnthropic.InternalServerError as e:
|
||||
print(f"Encountered Anthropic Internal Server Error: {e}. Retrying...")
|
||||
continue
|
||||
except TaskCompletedException as e:
|
||||
print_stage_header("TASK COMPLETED")
|
||||
raise # Re-raise to be caught by outer handler
|
||||
|
||||
# Run any research subtasks
|
||||
run_research_subtasks(base_task, config)
|
||||
|
|
@ -309,6 +315,8 @@ Be very thorough in your research and emit lots of snippets, key facts. If you t
|
|||
get_memory_value('plan'),
|
||||
related_files
|
||||
)
|
||||
except TaskCompletedException:
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
class TaskCompletedException(Exception):
|
||||
"""Raised when a one-shot task has been completed."""
|
||||
pass
|
||||
|
|
@ -61,6 +61,22 @@ No Planning or Problem-Solving
|
|||
Do not provide advice or commentary on the project’s future.
|
||||
|
||||
You must remain strictly within the bounds of describing what currently exists.
|
||||
|
||||
Single-Shot Task Detection
|
||||
|
||||
Autonomously determine if a task can be completed immediately without further planning:
|
||||
- Simple informational queries that can be answered directly from research
|
||||
- Requests that don't require complex analysis or implementation
|
||||
- Cases where further planning would not add value
|
||||
- Situations where immediate response meets all user requirements
|
||||
|
||||
If you determine a task can be completed in a single shot:
|
||||
1. Complete the necessary research to fully answer the query
|
||||
2. Document your findings using emit_research_notes
|
||||
3. Call one_shot_completed() to immediately conclude the task
|
||||
|
||||
Only use single-shot completion when you are confident no implementation or further planning is needed.
|
||||
|
||||
Thoroughness and Completeness
|
||||
|
||||
If this is determined to be a new/empty project (no code or files), state that and stop.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from typing import Dict, List, Any, Union, TypedDict, Optional, Sequence
|
||||
from ra_aid.exceptions import TaskCompletedException
|
||||
from rich.console import Console
|
||||
from rich.markdown import Markdown
|
||||
from rich.panel import Panel
|
||||
|
|
@ -238,6 +239,21 @@ def delete_key_snippets(snippet_ids: List[int]) -> str:
|
|||
|
||||
return "Snippets deleted."
|
||||
|
||||
@tool("one_shot_completed")
|
||||
def one_shot_completed(message: str) -> str:
|
||||
"""Signal that a one-shot task has been completed and execution should stop.
|
||||
|
||||
Args:
|
||||
message: Completion message to display
|
||||
|
||||
Raises:
|
||||
TaskCompletedException: Always raised to stop execution
|
||||
|
||||
Returns:
|
||||
Never returns, always raises exception
|
||||
"""
|
||||
raise TaskCompletedException(message)
|
||||
|
||||
def get_memory_value(key: str) -> str:
|
||||
"""Get a value from global memory.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue