Skip to content

feat: Claude Sonnet 4 1M context; Cursor rules budget 10% (cap 100k)#22

Merged
jacsamell merged 1 commit into
mainfrom
feat/claude-1m-context
Aug 19, 2025
Merged

feat: Claude Sonnet 4 1M context; Cursor rules budget 10% (cap 100k)#22
jacsamell merged 1 commit into
mainfrom
feat/claude-1m-context

Conversation

@jacsamell
Copy link
Copy Markdown
Owner

@jacsamell jacsamell commented Aug 19, 2025

PR Type

Enhancement


Description

• Enable 1M context model support with updated cursor rules budgeting
• Increase cursor rules token limit from 20k to 100k tokens
• Reduce context ratio from 25% to 10% with hard cap
• Add OpenAI/LiteLLM compatibility shim for type mismatches


Changes walkthrough 📝

Relevant files
Dependencies
litellm_ai_handler.py
Add OpenAI/LiteLLM compatibility shim for type handling   

pr_agent/algo/ai_handlers/litellm_ai_handler.py

• Add compatibility shim for OpenAI/LiteLLM type mismatches
• Handle
ResponseTextConfig to ResponseFormatTextConfig renaming
• Wrap
aliasing in try/except for best effort compatibility

+32/-1   
requirements.txt
Pin dependency versions for compatibility                               

requirements.txt

• Pin LiteLLM to version 1.75.8 and OpenAI to 1.100.1
• Update comment
about version compatibility requirements

+3/-3     
Configuration changes
utils.py
Update cursor rules token budgeting parameters                     

pr_agent/git_providers/utils.py

• Increase max_cursor_rules_tokens from 20k to 100k
• Reduce
cursor_rules_context_ratio from 0.25 to 0.10

+2/-2     
configuration.toml
Update default cursor rules configuration values                 

pr_agent/settings/configuration.toml

• Update default max_cursor_rules_tokens to 100000
• Update default
cursor_rules_context_ratio to 0.10

+2/-2     
Documentation
README.md
Document updated cursor rules budgeting behavior                 

README.md

• Document new cursor rules budgeting (10% of context, 100k cap)

Explain 1M-context model support for up to 100k rule tokens

+2/-0     

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link
    Copy Markdown
    Contributor

    github-actions Bot commented Aug 19, 2025

    PR Reviewer Guide 🔍

    (Review updated until commit d4454ca)

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
     AI Review Score: 75%
    🧪 No relevant tests
     Confidence score [1-100]: 78
     Complexity score [1-10]: 6
     Security score [1-10]: 8
     Auto approve recommendation: false
     Auto approve reasoning: This PR includes dependency version pinning and runtime monkey-patching of modules through the compatibility shim. These changes could potentially break in different environments or cause import failures. The lack of tests for the new compatibility shim functionality also raises concerns about reliability.
     Requires human approval: Complex Logic
    💡 Code suggestions

    Error Logging

    Add logging to the compatibility shim exception handler to help debug issues when the shim fails to apply correctly.

    Existing code:

    except Exception:
        # Best effort compatibility; proceed even if aliasing fails
        pass
    

    Improved code:

    except Exception as e:
        # Best effort compatibility; proceed even if aliasing fails
        import logging
        logging.debug(f"OpenAI compatibility shim failed: {e}")
        pass
    
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Runtime Patching

    The compatibility shim uses setattr to monkey-patch OpenAI module attributes at import time. This approach is fragile and could fail silently or cause unexpected behavior if module structures change. Consider alternative approaches or add comprehensive testing.

    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
    Version Pinning

    Pinning exact versions of litellm and openai may cause dependency conflicts in environments with other packages that require different versions. Consider using compatible version ranges instead of exact pins.

    litellm==1.75.8
    openai==1.100.1
    

    🔍 Manual review required

    Reason: Manual review required: Complex Logic

    @jacsamell jacsamell force-pushed the feat/claude-1m-context branch from e8f43bc to d4454ca Compare August 19, 2025 04:06
    @jacsamell jacsamell merged commit 98417b5 into main Aug 19, 2025
    2 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant