diff --git a/README.md b/README.md index 7321adb5..a4eba94f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/pr_agent/algo/ai_handlers/litellm_ai_handler.py b/pr_agent/algo/ai_handlers/litellm_ai_handler.py index cfcec8db..0cf487f3 100644 --- a/pr_agent/algo/ai_handlers/litellm_ai_handler.py +++ b/pr_agent/algo/ai_handlers/litellm_ai_handler.py @@ -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 diff --git a/pr_agent/git_providers/utils.py b/pr_agent/git_providers/utils.py index 285b2a70..49c099b7 100644 --- a/pr_agent/git_providers/utils.py +++ b/pr_agent/git_providers/utils.py @@ -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) diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index feee7b73..323ae1d1 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -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 diff --git a/requirements.txt b/requirements.txt index 596c3115..527d0e32 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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