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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ alwaysApply: true

The bot will automatically include these rules in its analysis, ensuring consistent code reviews that match your project's standards.

By default, up to 10% of the model context (capped at 100k tokens) is allocated to Cursor rules. On 1M-context models, this allows up to 100k tokens of rules to be included.

## Usage

### Automatic Mode
Expand Down
33 changes: 32 additions & 1 deletion pr_agent/algo/ai_handlers/litellm_ai_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
import os
import litellm
import openai
import requests
try:
# Shim: align Litellm's expected OpenAI type name with current OpenAI SDK
# Older Litellm versions import `ResponseTextConfig`, which was renamed to
# `ResponseFormatTextConfig` in newer OpenAI SDKs.
from openai.types.responses import (
response as _openai_response_mod,
response_create_params as _openai_response_params_mod,
)
if (
not hasattr(_openai_response_mod, "ResponseTextConfig")
and hasattr(_openai_response_mod, "ResponseFormatTextConfig")
):
setattr(
_openai_response_mod,
"ResponseTextConfig",
_openai_response_mod.ResponseFormatTextConfig,
)
# Alias param type as well if needed
if (
not hasattr(_openai_response_params_mod, "ResponseTextConfigParam")
and hasattr(_openai_response_params_mod, "ResponseFormatTextConfigParam")
):
setattr(
_openai_response_params_mod,
"ResponseTextConfigParam",
_openai_response_params_mod.ResponseFormatTextConfigParam,
)
except Exception:
# Best effort compatibility; proceed even if aliasing fails
pass

import litellm
from litellm import acompletion
from tenacity import retry, retry_if_exception_type, stop_after_attempt

Expand Down
4 changes: 2 additions & 2 deletions pr_agent/git_providers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def get_repository_rules_for_prompt():
token_handler = TokenHandler()
rules_tokens = token_handler.count_tokens(rules_content)

max_rules_tokens = int(get_settings().config.get('max_cursor_rules_tokens', 20000))
hard_cap_ratio = float(get_settings().config.get('cursor_rules_context_ratio', 0.25))
max_rules_tokens = int(get_settings().config.get('max_cursor_rules_tokens', 100000))
hard_cap_ratio = float(get_settings().config.get('cursor_rules_context_ratio', 0.10))
model_ctx = get_max_tokens(model)
hard_cap_tokens = max(2000, int(model_ctx * hard_cap_ratio))
allowed_tokens = min(max_rules_tokens, hard_cap_tokens)
Expand Down
4 changes: 2 additions & 2 deletions pr_agent/settings/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ feedback_on_draft_pr=false # Set to true to enable processing of draft PRs
use_cursor_rules=true # Set to true to enable reading official Cursor rules from repositories (.cursor/rules/*.mdc and .cursorrules)

# Cursor rules budgeting
max_cursor_rules_tokens = 20000
cursor_rules_context_ratio = 0.25
max_cursor_rules_tokens = 100000
cursor_rules_context_ratio = 0.10

# Default output budget when not using extended thinking
default_max_output_tokens = 2048
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Core AI provider support
# Bump LiteLLM for GPT-5 routing and latest providers
litellm>=1.74.0
openai>=1.55.3
# Keep LiteLLM and OpenAI in compatible versions to avoid type import mismatches
litellm==1.75.8
openai==1.100.1
anthropic>=0.48
tiktoken==0.8.0

Expand Down