From a9c6ea93b41e559b13a7c19c0515aa3076367231 Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Sat, 21 Dec 2024 11:04:57 -0500 Subject: [PATCH] Return reason for failure. --- ra_aid/tools/agent.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ra_aid/tools/agent.py b/ra_aid/tools/agent.py index 1640738..3e88000 100644 --- a/ra_aid/tools/agent.py +++ b/ra_aid/tools/agent.py @@ -29,6 +29,7 @@ def request_research(query: str) -> Dict[str, Any]: - facts: Current key facts - files: Related files - success: Whether completed or interrupted + - reason: Reason for failure, if any """ # Initialize model and memory model = initialize_llm("anthropic", "claude-3-sonnet-20240229") @@ -79,17 +80,21 @@ def request_research(query: str) -> Dict[str, Any]: ) success = True + reason = None except KeyboardInterrupt: console.print("\n[yellow]Research interrupted by user[/yellow]") success = False + reason = "cancelled_by_user" except Exception as e: console.print(f"\n[red]Error during research: {str(e)}[/red]") success = False + reason = f"error: {str(e)}" # Gather results return { "facts": get_memory_value("key_facts"), "files": list(get_related_files()), "notes": get_memory_value("research_notes"), - "success": success + "success": success, + "reason": reason }