From 0c39166172010d218c7396766880e809e8520042 Mon Sep 17 00:00:00 2001 From: AI Christianson Date: Thu, 9 Jan 2025 15:52:51 -0500 Subject: [PATCH] Increase recusion limit; Handle 429 better; Improve prompts. --- ra_aid/agent_utils.py | 6 ++++-- ra_aid/prompts.py | 1 + ra_aid/tools/agent.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ra_aid/agent_utils.py b/ra_aid/agent_utils.py index 0c1fb45..4784c64 100644 --- a/ra_aid/agent_utils.py +++ b/ra_aid/agent_utils.py @@ -571,8 +571,10 @@ def run_agent_with_retry(agent, prompt: str, config: dict) -> Optional[str]: except (KeyboardInterrupt, AgentInterrupt): raise except (InternalServerError, APITimeoutError, RateLimitError, APIError, ValueError) as e: - if isinstance(e, ValueError) and 'code 429' not in str(e): - raise # Re-raise ValueError if it's not a Lambda 429 + if isinstance(e, ValueError): + error_str = str(e).lower() + if 'code' not in error_str or '429' not in error_str: + raise # Re-raise ValueError if it's not a Lambda 429 if attempt == max_retries - 1: logger.error("Max retries reached, failing: %s", str(e)) raise RuntimeError(f"Max retries ({max_retries}) exceeded. Last error: {e}") diff --git a/ra_aid/prompts.py b/ra_aid/prompts.py index 2132acd..0eb858e 100644 --- a/ra_aid/prompts.py +++ b/ra_aid/prompts.py @@ -697,6 +697,7 @@ Remember: - Never announce that you are going to use a tool, just quietly use it. - Do communicate results/responses from tools that you call as it pertains to the users request. - If the user gives you key facts, record them using emit_key_facts. + - E.g. if the user gives you a stack trace, include the FULL stack trace into any delegated requests you make to fix it. - Typically, you will already be in the directory of a new or existing project. - If the user implies that a project exists, assume it does and make the tool calls as such. - E.g. if the user says "where are the unit tests?", you would call request_research("Find the location of the unit tests in the current project.") diff --git a/ra_aid/tools/agent.py b/ra_aid/tools/agent.py index 0b5a922..4f3fc5d 100644 --- a/ra_aid/tools/agent.py +++ b/ra_aid/tools/agent.py @@ -16,7 +16,7 @@ from ..console import print_task_header CANCELLED_BY_USER_REASON = "The operation was explicitly cancelled by the user. This typically is an indication that the action requested was not aligned with the user request." -RESEARCH_AGENT_RECURSION_LIMIT = 2 +RESEARCH_AGENT_RECURSION_LIMIT = 3 console = Console()