Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bugbug/tools/code_review/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions bugbug/tools/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
6 changes: 5 additions & 1 deletion services/reviewhelper-api/app/review_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 configured agent step limit."
) from e

generated_comments = [
GeneratedComment(
Expand Down