ComposioHQ / composio

Composio equips agents with well-crafted tools empowering them to tackle complex tasks
https://docs.composio.dev
Other
3.82k stars 1.02k forks source link

Restructre SWE Agent #204

Closed kaavee315 closed 1 month ago

kaavee315 commented 1 month ago

Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
8 files
submit_patch.py
Improve patch submission descriptions and examples             

python/composio/local_tools/local_workspace/submit_patch/actions/submit_patch.py
  • Enhanced the SubmitPatchRequest and SubmitPatch class descriptions to
    include details about the diff format.
  • +11/-2   
    run_evaluation.py
    Simplify CoderAgentArgs initialization and method call     

    python/composio_swe/benchmark/run_evaluation.py
  • Simplified CoderAgentArgs initialization by removing redundant
    parameters.
  • Updated coder.run method to accept issue_config.
  • +2/-6     
    base_swe_agent.py
    Add BaseSWEAgent abstract class                                                   

    python/composio_swe/composio_swe/agent/base_swe_agent.py
  • Introduced BaseSWEAgent abstract class with an abstract run method.
  • +12/-0   
    prompts.py
    Add reviewer backstory template                                                   

    python/composio_swe/composio_swe/agent/prompts.py - Added `REVIEWER_BACKSTORY_TMPL` template for reviewer agent.
    +12/-0   
    swe.py
    Refactor CoderAgent and add reviewer agent                             

    python/composio_swe/composio_swe/agent/swe.py
  • Refactored CoderAgent to inherit from BaseSWEAgent.
  • Moved logger setup and LLM retrieval to utils.py.
  • Added reviewer agent and task to the workflow.
  • +59/-80 
    swe_run.py
    Update CoderAgentArgs initialization and method call         

    python/composio_swe/composio_swe/agent/swe_run.py
  • Updated CoderAgentArgs initialization to remove redundant parameters.
  • Updated coder_agent.run method to accept issue_config.
  • +4/-5     
    utils.py
    Add utility functions for logger and LLM                                 

    python/composio_swe/composio_swe/agent/utils.py - Added utility functions for logger setup and LLM retrieval.
    +34/-0   
    cli.py
    Simplify solve command initialization and method call       

    python/composio_swe/composio_swe/cli/cli.py
  • Updated solve command to simplify CoderAgentArgs initialization and
    method call.
  • +5/-6     
    Documentation
    1 files
    README.md
    Update README with additional setup steps                               

    python/composio_swe/composio_swe/agent/README.md
  • Updated README to include additional setup steps and environment
    variables.
  • +14/-6   

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 1 month ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review [1-5] 4
    ๐Ÿงช Relevant tests No
    ๐Ÿ”’ Security concerns No
    โšก Key issues to review Possible Bug:
    The refactoring in run_evaluation.py and swe_run.py simplifies the initialization of CoderAgentArgs but removes the passing of issue_config directly. This could potentially lead to issues if the issue_config is required in the initialization process and not just in the run method.
    Code Clarity:
    The changes in submit_patch.py enhance the description of patch_code but might benefit from further examples or clearer explanation of what constitutes a "valid patch in diff format."
    Refactoring Impact:
    The introduction of the BaseSWEAgent class and changes in inheritance for CoderAgent are significant. It's important to ensure that all functionalities of the original CoderAgent are preserved or appropriately modified to fit the new structure.
    codiumai-pr-agent-pro[bot] commented 1 month ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add validation to ensure issue_config is not None before using it in the run method ___ **The run method should validate that issue_config is not None before proceeding, to prevent
    potential runtime errors.** [python/composio_swe/composio_swe/agent/swe.py [119-121]](https://github.com/ComposioHQ/composio/pull/204/files#diff-bbb8fcd0bfdb219cf4e20ffd41e3695abb277d9a5efc2c5a315e478976655540R119-R121) ```diff def run(self, issue_config: IssueConfig): + if issue_config is None: + raise ValueError("issue_config must be provided") llm = get_llm() repo_name = issue_config.repo_name ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: This is a valid suggestion to prevent runtime errors by ensuring that `issue_config` is provided before proceeding with the method execution.
    8
    Enhancement
    Log an error message before raising a ValueError in the get_llm function ___ **The get_llm function should log an error message before raising a ValueError when no model
    is found, to aid in debugging.** [python/composio_swe/composio_swe/agent/utils.py [34]](https://github.com/ComposioHQ/composio/pull/204/files#diff-ebba6012e3781136b15802f8496f063323a2d11aba51c645d1d8a5819486dab2R34-R34) ```diff +logger.error("No valid API key found for LLM configuration") raise ValueError("no model is found") ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: Adding an error log before raising an exception is a good practice for better debugging and understanding the error context, making this a useful enhancement.
    7
    Best practice
    Add a try-except block to the run method to handle and log exceptions ___ **The run method should include a try-except block around the main logic to handle potential
    exceptions gracefully and log them for debugging purposes.** [python/composio_swe/composio_swe/agent/swe.py [119-123]](https://github.com/ComposioHQ/composio/pull/204/files#diff-bbb8fcd0bfdb219cf4e20ffd41e3695abb277d9a5efc2c5a315e478976655540R119-R123) ```diff def run(self, issue_config: IssueConfig): - llm = get_llm() - repo_name = issue_config.repo_name - if not repo_name: - raise ValueError("no repo-name configuration is found") + try: + llm = get_llm() + repo_name = issue_config.repo_name + if not repo_name: + raise ValueError("no repo-name configuration is found") ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: Implementing a try-except block for exception handling in the `run` method is a good practice to manage exceptions and maintain the robustness of the application.
    6