From 916a7ef966301602fa5846c1c338785355c1ee43 Mon Sep 17 00:00:00 2001 From: Suhaib Mujahid Date: Tue, 23 Jun 2026 11:28:09 -0400 Subject: [PATCH 1/2] Increase recursion limit to 100 and stop retrying on GraphRecursionError Adds RecursionLimitError to core exceptions, raised by the agent when GraphRecursionError is hit, and caught in the API as ReviewProcessingError to prevent costly Cloud Tasks retries. --- bugbug/tools/code_review/agent.py | 9 ++++++--- bugbug/tools/core/exceptions.py | 4 ++++ services/reviewhelper-api/app/review_processor.py | 6 +++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bugbug/tools/code_review/agent.py b/bugbug/tools/code_review/agent.py index f04de3d860..ecda769f59 100644 --- a/bugbug/tools/code_review/agent.py +++ b/bugbug/tools/code_review/agent.py @@ -49,7 +49,10 @@ convert_generated_comments_to_inline, format_patch_set, ) -from bugbug.tools.core.exceptions import LargeDiffError, ModelResultError +from bugbug.tools.core.exceptions import ( + LargeDiffError, + RecursionLimitError, +) from bugbug.tools.core.llms import DEFAULT_ANTHROPIC_MODEL, get_tokenizer from bugbug.tools.core.platforms.base import Patch @@ -235,11 +238,11 @@ async def generate_review_comments( }, context=CodeReviewContext(patch=patch), stream_mode="values", - config={"recursion_limit": 50}, + config={"recursion_limit": 100}, ): result = chunk except GraphRecursionError as e: - raise ModelResultError("The model could not complete the review") from e + raise RecursionLimitError("The model could not complete the review") from e return result["structured_response"].comments, manifest diff --git a/bugbug/tools/core/exceptions.py b/bugbug/tools/core/exceptions.py index 78d1e92fa9..e2dd3133f0 100644 --- a/bugbug/tools/core/exceptions.py +++ b/bugbug/tools/core/exceptions.py @@ -27,5 +27,9 @@ class RunawayGenerationError(ModelResultError): """ +class RecursionLimitError(ModelResultError): + """Occurs when the agent exceeds the maximum number of recursive steps.""" + + class LargeDiffError(Exception): """Occurs when the diff is too large to be processed.""" diff --git a/services/reviewhelper-api/app/review_processor.py b/services/reviewhelper-api/app/review_processor.py index 198eeb4dcb..f3cee907fa 100644 --- a/services/reviewhelper-api/app/review_processor.py +++ b/services/reviewhelper-api/app/review_processor.py @@ -7,7 +7,7 @@ from app.config import settings from app.database.models import GeneratedComment, ReviewRequest from app.enums import Platform -from bugbug.tools.core.exceptions import LargeDiffError +from bugbug.tools.core.exceptions import LargeDiffError, RecursionLimitError from bugbug.tools.core.platforms.phabricator import ( PhabricatorPatch, get_phabricator_client, @@ -81,6 +81,10 @@ async def process_review( raise ReviewProcessingError( "The diff size exceeds the current processing limits." ) from e + except RecursionLimitError as e: + raise ReviewProcessingError( + "Review Helper could not complete the review within the steps limit." + ) from e generated_comments = [ GeneratedComment( From a89a35007dcca2e74243a6b0e27df8ad6e904287 Mon Sep 17 00:00:00 2001 From: Suhaib Mujahid Date: Tue, 23 Jun 2026 11:39:00 -0400 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- services/reviewhelper-api/app/review_processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/reviewhelper-api/app/review_processor.py b/services/reviewhelper-api/app/review_processor.py index f3cee907fa..84cffce308 100644 --- a/services/reviewhelper-api/app/review_processor.py +++ b/services/reviewhelper-api/app/review_processor.py @@ -83,7 +83,7 @@ async def process_review( ) from e except RecursionLimitError as e: raise ReviewProcessingError( - "Review Helper could not complete the review within the steps limit." + "Review Helper could not complete the review within the configured agent step limit." ) from e generated_comments = [