From 02a4f62918c1f5245dc1b7f6498dc5438d19bc66 Mon Sep 17 00:00:00 2001 From: Karan Vaidya Date: Sat, 15 Jun 2024 22:20:49 +0530 Subject: [PATCH 01/12] Update swe --- coders/composio_coders/swe.py | 21 +++++++++++-------- composio/client/enums.py | 6 ++++++ .../local_workspace/cmd_manager/tool.py | 2 ++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index ae735b9ca..2251e9bf0 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -23,19 +23,21 @@ Your mentor gave you following tips. 1. Always start by initializing the workspace. 2. Use the workspace_id returned to use tools to run commands. The commands are run on shell. - 3. use clone the git repo {repo_name} from the base_commit {base_commit} in workspace - 4. After setting up environment - *Always start with try to replicate the bug that the issues discusses*. + 3. Use clone the git repo {repo_name} from the base_commit {base_commit} in workspace + 4. PLEASE READ THE CODE AND UNDERSTAND THE FILE STRUCTURE OF THE CODEBASE USING GIT REPO TREE ACTION. + 5. POST THAT READ ALL THE READMES AND TRY TO LOOK AT THE FILES RELATED TO THE ISSUE. + 6. AFTER THAT - *ALWAYS START WITH TRY TO REPLICATE THE BUG THAT THE ISSUES DISCUSSES*. If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug. Then start trying to fix it. When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed. If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file, so that you can be sure that the script indeed ran fine all the way through. - 5. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it! - 6. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. - 7. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. - 8. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file. - 9. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it. - 10. When you finish working on the issue, use submit patch tool to submit your patch. + 7. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it! + 8. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. + 9. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. + 10. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file. + 11. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it. + 12. When you finish working on the issue, use submit patch tool to submit your patch. ''' ISSUE_DESC_TMPL = ''' We're currently solving the following issue within our repository. Here's the issue text: @@ -105,6 +107,7 @@ def __init__(self, args: CoderAgentArgs): self.composio_toolset = tool_set.get_tools(apps=[App.LOCALWORKSPACE, App.CMDMANAGERTOOL, App.HISTORYKEEPER,]) + print("composio_toolset: ", self.composio_toolset) # initialize agent-related different prompts self.agent_role = "You are the best programmer. You think carefully and step by step take action." self.agent_goal = "Help fix the given issue / bug in the code. And make sure you get it working." @@ -161,7 +164,7 @@ def get_llm(self): if self.model_env.get("model_env") == "openai": openai_key = self.model_env.get("OPENAI_API_KEY") or os.environ.get("OPENAI_API_KEY") - return ChatOpenAI(model="gpt-4-turbo", OPENAI_API_KEY=openai_key) + return ChatOpenAI(model="gpt-4-turbo", api_key=openai_key) elif self.model_env.get("model_env") == "azure": azure_endpoint = self.model_env.get("endpoint_url") or os.environ.get("AZURE_ENDPOINT") azure_key = self.model_env.get("api_key") or os.environ.get("AZURE_KEY") diff --git a/composio/client/enums.py b/composio/client/enums.py index dde284b3d..9f665e6f6 100644 --- a/composio/client/enums.py +++ b/composio/client/enums.py @@ -13685,6 +13685,12 @@ def from_app_and_action(cls, app: str, name: str) -> "Action": True, True, ) + CMDMANAGERTOOL_GITREPOTREE = ( + "cmdmanagertool", + "cmdmanagertool_gitrepotree", + True, + True, + ) CMDMANAGERTOOL_EDITFILE = ("cmdmanagertool", "cmdmanagertool_editfile", True, True) CMDMANAGERTOOL_RUNCOMMANDONWORKSPACE = ( "cmdmanagertool", diff --git a/composio/local_tools/local_workspace/cmd_manager/tool.py b/composio/local_tools/local_workspace/cmd_manager/tool.py index b5e7ad92e..6a035e5b6 100644 --- a/composio/local_tools/local_workspace/cmd_manager/tool.py +++ b/composio/local_tools/local_workspace/cmd_manager/tool.py @@ -13,6 +13,7 @@ Scroll, SearchDirCmd, SearchFileCmd, + GitRepoTree ) from composio.local_tools.local_workspace.commons import ( HistoryProcessor, @@ -41,6 +42,7 @@ def actions(self) -> list: RunCommandOnWorkspace, GetCurrentDirCmd, GithubCloneCmd, + GitRepoTree, ] def triggers(self) -> list: From a8d07bd7ed4396ade2478218cbb95f49e2805e6a Mon Sep 17 00:00:00 2001 From: Karan Vaidya Date: Sun, 16 Jun 2024 02:01:50 +0530 Subject: [PATCH 02/12] Multi crew --- coders/composio_coders/swe.py | 62 +++++++++++++++---- .../cmd_manager/actions/base_class.py | 4 +- .../cmd_manager/actions/clone_github.py | 2 +- .../cmd_manager/actions/git_tree.py | 10 +-- .../cmd_manager/actions/scroll_cmds.py | 2 +- .../cmd_manager/actions/search_cmds.py | 2 +- 6 files changed, 62 insertions(+), 20 deletions(-) diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index 2251e9bf0..36323010a 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -5,7 +5,7 @@ from pathlib import Path from pydantic import BaseModel, Field from composio_crewai import ComposioToolSet, App -from crewai import Agent, Task +from crewai import Agent, Task, Crew from langchain_openai import AzureChatOpenAI, ChatOpenAI import logging from rich.logging import RichHandler @@ -23,21 +23,23 @@ Your mentor gave you following tips. 1. Always start by initializing the workspace. 2. Use the workspace_id returned to use tools to run commands. The commands are run on shell. - 3. Use clone the git repo {repo_name} from the base_commit {base_commit} in workspace + 3. Use clone action to clone the git repo {repo_name} from the base_commit {base_commit} in workspace. 4. PLEASE READ THE CODE AND UNDERSTAND THE FILE STRUCTURE OF THE CODEBASE USING GIT REPO TREE ACTION. - 5. POST THAT READ ALL THE READMES AND TRY TO LOOK AT THE FILES RELATED TO THE ISSUE. - 6. AFTER THAT - *ALWAYS START WITH TRY TO REPLICATE THE BUG THAT THE ISSUES DISCUSSES*. + 5. POST THAT READ ALL THE RELEVANT READMEs AND TRY TO LOOK AT THE FILES RELATED TO THE ISSUE. + 6. Form a thesis around the issue and the codebase. + 7. THEN TRY TO REPLICATE THE BUG THAT THE ISSUES DISCUSSES. If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug. Then start trying to fix it. When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed. If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file, so that you can be sure that the script indeed ran fine all the way through. - 7. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it! - 8. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. - 9. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. - 10. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file. - 11. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it. - 12. When you finish working on the issue, use submit patch tool to submit your patch. + 8. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it! + 9. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. + 10. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. + 11. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file. + 12. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it. + 13. When you finish working on the issue, use submit patch tool to submit your patch. + 14. SUBMIT THE PATCH TO THE REVIEWER AGENT AGAIN AND ASK THEM TO REVIEW THE PATCH AND SUBMIT IT ONLY IF THEY APPROVE IT. ''' ISSUE_DESC_TMPL = ''' We're currently solving the following issue within our repository. Here's the issue text: @@ -110,7 +112,7 @@ def __init__(self, args: CoderAgentArgs): print("composio_toolset: ", self.composio_toolset) # initialize agent-related different prompts self.agent_role = "You are the best programmer. You think carefully and step by step take action." - self.agent_goal = "Help fix the given issue / bug in the code. And make sure you get it working." + self.agent_goal = "Help fix the given issue / bug in the code. And make sure you get it working. Ask the reviewer agent to review the patch and submit it once they approve it." self.expected_output = "A patch should be generated which fixes the given issue" self.agent_backstory_tmpl = args.agent_backstory_tmpl self.issue_description_tmpl = args.issue_description_tmpl @@ -207,7 +209,41 @@ def run(self): agent=swe_agent, expected_output=self.expected_output, ) - coding_task.execute() + + reviewer_agent = Agent( + role="You are the best reviewer. You think carefully and step by step take action.", + goal="Review the patch and make sure it fixes the issue.", + backstory="An AI Agent tries to solve an issue and submits a patch to the repo. " + "You can assume the AI agent operates as a junior developer and has limited knowledge of the codebase." + "It's your job to review the patch and make sure it fixes the issue." + "The patch might be incomplete. In that case point out the missing parts and ask the AI agent to add them." + "The patch might have some compilation issues/typo. Point out those and ask the AI agent to fix them." + "The patch might have some logical issues. Point out those and ask the AI agent to fix them." + "Once the patch is ready, approve it and ask the AI agent to submit it." + "It is fine to have multiple iterations of the review. Keep iterating until the patch is ready to be submitted." + "The are the best reviewer. You think carefully and step by step take action.", + verbose=True, + llm=llm, + tools=self.composio_toolset, + memory=True, + step_callback=self.add_in_logs, + allow_delegation=True, + ) + + review_task = Task( + description="Review the patch and make sure it fixes the issue.", + agent=reviewer_agent, + context=[coding_task], + expected_output="The patch is ready to be submitted to the repo.", + ) + + crew = Crew( + agents=[swe_agent, reviewer_agent], + tasks=[coding_task, review_task], + memory=True, + ) + + crew.kickoff() self.save_history(self.issue_config.issue_id) @@ -226,5 +262,7 @@ def run(self): } ) c_agent = CoderAgent(args) + + c_agent.run() diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py b/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py index e2f0bd783..5ba054d9e 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py @@ -33,7 +33,9 @@ class BaseRequest(BaseModel): class BaseResponse(BaseModel): - output: str = Field(..., description="output of the command") + class Config: + arbitrary_types_allowed = True + output: any = Field(..., description="output of the command") return_code: int = Field( ..., description="Any output or errors that occurred during the file edit." ) diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/clone_github.py b/composio/local_tools/local_workspace/cmd_manager/actions/clone_github.py index 07abab3fe..f69c13432 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/clone_github.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/clone_github.py @@ -39,7 +39,7 @@ class GithubCloneResponse(BaseResponse): class GithubCloneCmd(BaseAction): """ - Clones a github repository + Clones a github repository at a given commit-id. """ _history_maintains: bool = True diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py b/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py index 4a0856ce7..04cedbd47 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py @@ -16,7 +16,9 @@ class GitRepoTree(BaseAction): """ - generate a tree of the repository. This command lists all files in the current commit across all directories. + Generate a tree of the repository. This command lists all files in the current commit across all directories. + Returns a list of files with their relative paths in the codebase. + It is useful to understand the file structure of the codebase and to find the relevant files for a given issue. """ _display_name = "Git repo tree action" @@ -29,8 +31,7 @@ def execute( ) -> BaseResponse: self._setup(request_data) self.script_file = SCRIPT_EDIT_LINTING - self.command = "git ls-tree -r HEAD" - + self.command = "git ls-tree -r HEAD --name-only" if self.container_process is None: raise ValueError("Container process is not set") @@ -38,7 +39,8 @@ def execute( self.container_process, self.container_obj, self.command, self.parent_pids ) output, return_code = process_output(output, return_code) + files = output.split("\n") return BaseResponse( - output=output, + output=files, return_code=return_code, ) diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/scroll_cmds.py b/composio/local_tools/local_workspace/cmd_manager/actions/scroll_cmds.py index 95e18242d..7bdd2bba5 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/scroll_cmds.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/scroll_cmds.py @@ -28,7 +28,7 @@ class ScrollResponse(BaseResponse): class Scroll(BaseAction): """ - Scrolls the view within a shell session down by 100 lines + Scrolls the view within a shell session down by 100 lines. """ _display_name = "Scroll Action" diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/search_cmds.py b/composio/local_tools/local_workspace/cmd_manager/actions/search_cmds.py index 4823f1028..fe940346b 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/search_cmds.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/search_cmds.py @@ -164,7 +164,7 @@ class GetCurrentDirResponse(BaseResponse): class GetCurrentDirCmd(BaseAction): """ - Gets the current directory. + Gets the current directory. This is equivalent to running 'pwd' in the terminal. """ _display_name = "Get Current Directory Action" From 22d04c867c765798324e33e73492ae32bd0fd1e4 Mon Sep 17 00:00:00 2001 From: shubhra Date: Tue, 18 Jun 2024 16:07:27 +0530 Subject: [PATCH 03/12] changes --- .../benchmark/run_evaluation.py | 117 ++++++++++++++++++ coders/composio_coders/config_store.py | 2 +- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 coders/composio_coders/benchmark/run_evaluation.py diff --git a/coders/composio_coders/benchmark/run_evaluation.py b/coders/composio_coders/benchmark/run_evaluation.py new file mode 100644 index 000000000..e12ab0f9c --- /dev/null +++ b/coders/composio_coders/benchmark/run_evaluation.py @@ -0,0 +1,117 @@ +import os +import json +import datetime +from datasets import load_dataset +from pathlib import Path +import logging +from rich.logging import RichHandler + +from composio_coders.swe import CoderAgent, CoderAgentArgs +from composio_coders.constants import KEY_API_KEY +from composio_coders.context import Context, set_context + + +CONFIG_FILE_PATH = "./base_task_config.yaml" +TASK_OUTPUT_PATH = "./task_output" + +# Path of the current script +script_path = Path(__file__).resolve() +script_dir = script_path.parent +base_task_config_path = script_dir / Path(CONFIG_FILE_PATH) + + +# get logger +LOGGER_NAME = "local_workspace" + +handler = RichHandler(show_time=False, show_path=False) +handler.setLevel(logging.DEBUG) +logger = logging.getLogger(LOGGER_NAME) +logger.setLevel(logging.DEBUG) +logger.addHandler(handler) +logger.propagate = False + +''' + princeton swe bench lite dataset has these fields + instance_id: (str) - A formatted instance identifier, usually as repo_owner__repo_name-PR-number. + patch: (str) - The gold patch, the patch generated by the PR (minus test-related code), that resolved the issue. + repo: (str) - The repository owner/name identifier from GitHub. + base_commit: (str) - The commit hash of the repository representing the HEAD of the repository before the solution PR is applied. + hints_text: (str) - Comments made on the issue prior to the creation of the solution PR’s first commit creation date. + created_at: (str) - The creation date of the pull request. + test_patch: (str) - A test-file patch that was contributed by the solution PR. + problem_statement: (str) - The issue title and body. + version: (str) - Installation version to use for running evaluation. + environment_setup_commit: (str) - commit hash to use for environment setup and installation. + FAIL_TO_PASS: (str) - A json list of strings that represent the set of tests resolved by the PR and tied to the issue resolution. + PASS_TO_PASS: (str) - A json list of strings that represent tests that should pass before and after the PR application. +''' + + +def filter_from_repo_name(curr_dataset, repo_name): + filtered_dataset = curr_dataset.filter(lambda x: x["repo"] == repo_name.strip().lower()) + return filtered_dataset + + +def get_issues_dataset(): + test_dataset = load_dataset("princeton-nlp/SWE-bench_Lite", split="test[23:33]") + return test_dataset + + +def build_issue_description(hints, problem_statement): + if not problem_statement or not problem_statement.strip(): + raise ValueError("problem statement is empty") + tmpl = "" + if hints: + tmpl = f"Here are few hints to solve the issue described in problem_statement {hints}" + tmpl += f'''\n\n + Here is the issue, that you have to solve all ob your own + {problem_statement} + ''' + return tmpl + + +def run(): + """ + Main function to load and display entries from the SWE-bench lite dataset. + """ + + issues = get_issues_dataset() + for issue in issues: + issue_description = build_issue_description(issue["hints_text"], + issue["problem_statement"]) + patch = issue["patch"] + install_commit_id = issue["environment_setup_commit"] + instance_id = issue["instance_id"] + issue_config = { + "repo_name": issue["repo"], + "issue_id": issue["instance_id"], + "base_commit_id": issue["base_commit"], + "issue_desc": issue_description, + } + logger.info(f"starting agent for issue-id: {issue['instance_id']}\n" + f"issue-description: {issue_description}\n" + f"repo_name: {issue['repo']}\n") + + print("--------------------------------------------------") + + model_env_config = { + KEY_API_KEY: "142b9b40120a4eda89bac0f7b035a2b1", + "azure_endpoint": "https://testingswedencentral.openai.azure.com/", + "model_env": "azure", + } + ctx = Context() + ctx.issue_config = issue_config + ctx.model_env = model_env_config + set_context(ctx) + + args = CoderAgentArgs( + agent_logs_dir=ctx.agent_logs_dir, + issue_config=ctx.issue_config, + model_env_config=ctx.model_env, + ) + coder = CoderAgent(args) + coder.run() + + +if __name__ == "__main__": + run() diff --git a/coders/composio_coders/config_store.py b/coders/composio_coders/config_store.py index 80e470ec3..dcf33375f 100644 --- a/coders/composio_coders/config_store.py +++ b/coders/composio_coders/config_store.py @@ -1,6 +1,6 @@ import typing as t -from composio.storage import LocalStorage +from composio.storage.base import LocalStorage class ModelEnv(LocalStorage): From 9bb837efd1cc8d2b53251590c9b99691f09f55ff Mon Sep 17 00:00:00 2001 From: shubhra Date: Tue, 18 Jun 2024 19:07:12 +0530 Subject: [PATCH 04/12] adding git-tree in a file --- .../local_workspace/cmd_manager/actions/git_tree.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py b/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py index 04cedbd47..ffc3ed227 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/git_tree.py @@ -19,6 +19,8 @@ class GitRepoTree(BaseAction): Generate a tree of the repository. This command lists all files in the current commit across all directories. Returns a list of files with their relative paths in the codebase. It is useful to understand the file structure of the codebase and to find the relevant files for a given issue. + The command writes the result to a file in current directory. Read the file 'git_repo_tree.txt' for getting the + git-repo-tree results """ _display_name = "Git repo tree action" @@ -31,7 +33,7 @@ def execute( ) -> BaseResponse: self._setup(request_data) self.script_file = SCRIPT_EDIT_LINTING - self.command = "git ls-tree -r HEAD --name-only" + self.command = "git ls-tree -r HEAD --name-only > ./git_repo_tree.txt" if self.container_process is None: raise ValueError("Container process is not set") From 73d62fb97f244027d9d5f9cbebe6f3e22952c9ea Mon Sep 17 00:00:00 2001 From: shubhra Date: Wed, 19 Jun 2024 09:43:07 +0530 Subject: [PATCH 05/12] wip - workspace without agent --- coders/composio_coders/swe.py | 58 +++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index 103b480a4..e3f62d04c 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -1,9 +1,13 @@ import datetime import json import logging +import os from pathlib import Path from pydantic import BaseModel, Field -from composio_crewai import ComposioToolSet, App +from composio_crewai import ComposioToolSet, App, Action +from composio.local_tools.local_workspace.workspace.actions.create_workspace import CreateWorkspaceResponse +from composio.local_tools.local_workspace.cmd_manager.actions.clone_github import GithubCloneRequest, GithubCloneResponse +from composio import Composio from crewai import Agent, Task, Crew from typing import Any, Dict, List @@ -26,26 +30,25 @@ AGENT_BACKSTORY_TMPL = """ You are an autonomous programmer, your task is to solve the issue given in task with the tools in hand. Your mentor gave you following tips. - 1. Always start by initializing the workspace. - 2. Use the workspace_id returned to use tools to run commands. The commands are run on shell. - 3. Use clone action to clone the git repo {repo_name} from the base_commit {base_commit} in workspace. - 4. PLEASE READ THE CODE AND UNDERSTAND THE FILE STRUCTURE OF THE CODEBASE USING GIT REPO TREE ACTION. - 5. POST THAT READ ALL THE RELEVANT READMEs AND TRY TO LOOK AT THE FILES RELATED TO THE ISSUE. - 6. Form a thesis around the issue and the codebase. - 7. THEN TRY TO REPLICATE THE BUG THAT THE ISSUES DISCUSSES. + 1. A workspace is initialized for you, and you will be working on {workspace_id}. The git repo is cloned in + the path {repo_name}, you need to work in this directory. + 2. PLEASE READ THE CODE AND UNDERSTAND THE FILE STRUCTURE OF THE CODEBASE USING GIT REPO TREE ACTION. + 3. POST THAT READ ALL THE RELEVANT READMEs AND TRY TO LOOK AT THE FILES RELATED TO THE ISSUE. + 4. Form a thesis around the issue and the codebase. + 5. THEN TRY TO REPLICATE THE BUG THAT THE ISSUES DISCUSSES. If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug. Then start trying to fix it. When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed. If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file, so that you can be sure that the script indeed ran fine all the way through. - 8. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it! - 9. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. - 10. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. - 11. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file. - 12. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it. - 13. When you finish working on the issue, use submit patch tool to submit your patch. - 14. SUBMIT THE PATCH TO THE REVIEWER AGENT AGAIN AND ASK THEM TO REVIEW THE PATCH AND SUBMIT IT ONLY IF THEY APPROVE IT. + 6. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it! + 7. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. + 8. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. + 9. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file. + 10. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it. + 11. When you finish working on the issue, use submit patch tool to submit your patch. + 12. SUBMIT THE PATCH TO THE REVIEWER AGENT AGAIN AND ASK THEM TO REVIEW THE PATCH AND SUBMIT IT ONLY IF THEY APPROVE IT. """ ISSUE_DESC_TMPL = """ We're currently solving the following issue within our repository. Here's the issue text: @@ -109,7 +112,8 @@ def __init__(self, args: CoderAgentArgs): self.composio_toolset = tool_set.get_tools(apps=[App.LOCALWORKSPACE, App.CMDMANAGERTOOL, App.HISTORYKEEPER,]) - print("composio_toolset: ", self.composio_toolset) + composio_client = Composio() + self.entity = composio_client.get_entity("swe-agent") # initialize agent-related different prompts self.agent_role = "You are the best programmer. You think carefully and step by step take action." @@ -169,6 +173,8 @@ def get_llm(self): if model_env == MODEL_ENV_AZURE: azure_endpoint = self.model_env.get(KEY_AZURE_ENDPOINT) azure_key = self.model_env.get(KEY_API_KEY) + os.environ["AZURE_OPENAI_API_KEY"] = self.model_env[KEY_AZURE_ENDPOINT] + os.environ["AZURE_OPENAI_API_KEY"] = self.model_env[KEY_API_KEY] azure_llm = AzureChatOpenAI( azure_endpoint=azure_endpoint, api_key=azure_key, @@ -182,21 +188,21 @@ def get_llm(self): def run(self): llm = self.get_llm() - self.logger.info( - "starting agent for issue-id: %s\n" - "issue-description: %s\n" - "repo_name: %s\n", - self.issue_config.issue_id, - self.issue_config.issue_desc, - self.issue_config.issue_desc, - ) - + workspace_create_resp: CreateWorkspaceResponse = self.entity.execute(Action.LOCALWORKSPACE_CREATEWORKSPACEACTION, {}) + workspace_id = workspace_create_resp.workspace_id + logger.info(f"workspace is created, workspace-id is: {workspace_id}") + git_clone_response = self.entity.execute(Action.CMDMANAGERTOOL_GITHUBCLONECMD, + params={"workspace_id": workspace_id, "repo_name": self.issue_config.repo_name}) issue_added_instruction = self.issue_description_tmpl.format( issue=self.issue_config.issue_desc, issue_id=self.issue_config.issue_id ) backstory_added_instruction = self.agent_backstory_tmpl.format( - repo_name=self.repo_name, base_commit=self.issue_config.base_commit_id + workspace_id=workspace_id, + repo_name=self.repo_name, + base_commit=self.issue_config.base_commit_id ) + logger.info(f"git clone response: {git_clone_response}") + swe_agent = Agent( role=self.agent_role, goal=self.agent_goal, From 113d02e5641708f3ada3fb93d8ba67ddc674dcf4 Mon Sep 17 00:00:00 2001 From: shubhra Date: Wed, 19 Jun 2024 10:55:51 +0530 Subject: [PATCH 06/12] wip- workspace start without agent --- coders/composio_coders/swe.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index e3f62d04c..680a5d092 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -30,8 +30,8 @@ AGENT_BACKSTORY_TMPL = """ You are an autonomous programmer, your task is to solve the issue given in task with the tools in hand. Your mentor gave you following tips. - 1. A workspace is initialized for you, and you will be working on {workspace_id}. The git repo is cloned in - the path {repo_name}, you need to work in this directory. + 1. A workspace is initialized for you, and you will be working on workspace, where workspace_id is: {workspace_id}. The git repo is cloned in + the path {repo_name_dir}, you need to work in this directory. 2. PLEASE READ THE CODE AND UNDERSTAND THE FILE STRUCTURE OF THE CODEBASE USING GIT REPO TREE ACTION. 3. POST THAT READ ALL THE RELEVANT READMEs AND TRY TO LOOK AT THE FILES RELATED TO THE ISSUE. 4. Form a thesis around the issue and the codebase. @@ -199,6 +199,7 @@ def run(self): backstory_added_instruction = self.agent_backstory_tmpl.format( workspace_id=workspace_id, repo_name=self.repo_name, + repo_name_dir="/" + self.repo_name.split("/")[-1].strip(), base_commit=self.issue_config.base_commit_id ) logger.info(f"git clone response: {git_clone_response}") From 36aea0d602da30d2d6a7274200785df2517a2be5 Mon Sep 17 00:00:00 2001 From: shubhra Date: Wed, 19 Jun 2024 11:08:13 +0530 Subject: [PATCH 07/12] install dependency in prompt --- coders/composio_coders/swe.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index 680a5d092..4a665bb9b 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -37,7 +37,8 @@ 4. Form a thesis around the issue and the codebase. 5. THEN TRY TO REPLICATE THE BUG THAT THE ISSUES DISCUSSES. If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug. - Then start trying to fix it. + Before running the bug-reproduction script, make sure all the dependencies are installed to run that script. + 6. Once bug-reproduction script has run successfully, move on to start trying to fix it. When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed. If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file, From 16b81921741b05bfa4d5716dad93e8200a2df3e0 Mon Sep 17 00:00:00 2001 From: shubhra Date: Wed, 19 Jun 2024 13:05:56 +0530 Subject: [PATCH 08/12] changes --- coders/composio_coders/swe.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index c4e8e7e23..f86834320 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -39,8 +39,7 @@ 4. Form a thesis around the issue and the codebase. 5. THEN TRY TO REPLICATE THE BUG THAT THE ISSUES DISCUSSES. If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug. - Before running the bug-reproduction script, make sure all the dependencies are installed to run that script. - 6. Once bug-reproduction script has run successfully, move on to start trying to fix it. + Then start trying to fix it. When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed. If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file, @@ -126,7 +125,8 @@ def __init__(self, args: CoderAgentArgs): tool_set = ComposioToolSet() self.composio_toolset = tool_set.get_tools(apps=[App.LOCALWORKSPACE, App.CMDMANAGERTOOL, - App.HISTORYKEEPER,]) + App.HISTORYKEEPER, + App.SUBMITPATCHTOOL]) composio_client = Composio() self.entity = composio_client.get_entity("swe-agent") # initialize composio client @@ -190,7 +190,7 @@ def add_in_logs(self, step_output): def get_llm(self): model_env = self.model_env.get(KEY_MODEL_ENV) if model_env == MODEL_ENV_OPENAI: - openai_key = self.model_env.get(KEY_API_KEY) + openai_key = os.environ.get(("OPANAI_API_KEY")) return ChatOpenAI(model="gpt-4-turbo", api_key=openai_key) if model_env == MODEL_ENV_AZURE: azure_endpoint = self.model_env.get(KEY_AZURE_ENDPOINT) From 122487007fac0e14e5ccd1d1761ac16d0167570f Mon Sep 17 00:00:00 2001 From: shubhra Date: Wed, 19 Jun 2024 13:14:37 +0530 Subject: [PATCH 09/12] format fix --- .../benchmark/run_evaluation.py | 1 - coders/composio_coders/swe.py | 72 +++++++++++-------- .../cmd_manager/actions/base_class.py | 1 + .../local_workspace/cmd_manager/tool.py | 2 +- 4 files changed, 45 insertions(+), 31 deletions(-) diff --git a/coders/composio_coders/benchmark/run_evaluation.py b/coders/composio_coders/benchmark/run_evaluation.py index 1cad516e6..638d1d464 100644 --- a/coders/composio_coders/benchmark/run_evaluation.py +++ b/coders/composio_coders/benchmark/run_evaluation.py @@ -66,7 +66,6 @@ def run(): issues = get_issues_dataset() for issue in issues: - issue_description = build_issue_description( issue["hints_text"], issue["problem_statement"] ) diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index f86834320..86c7fa70d 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -3,12 +3,6 @@ import logging import os from pathlib import Path -from pydantic import BaseModel, Field -from composio_crewai import ComposioToolSet, App, Action -from composio.local_tools.local_workspace.workspace.actions.create_workspace import CreateWorkspaceResponse -from composio.local_tools.local_workspace.cmd_manager.actions.clone_github import GithubCloneRequest, GithubCloneResponse -from composio import Composio -from crewai import Agent, Task, Crew from typing import Any, Dict, List import langchain_core @@ -20,13 +14,16 @@ MODEL_ENV_AZURE, MODEL_ENV_OPENAI, ) -from composio_crewai import App, ComposioToolSet -from crewai import Agent, Task +from composio_crewai import Action, App, ComposioToolSet +from crewai import Agent, Crew, Task from langchain_openai import AzureChatOpenAI, ChatOpenAI from pydantic import BaseModel, Field from rich.logging import RichHandler from composio import Composio +from composio.local_tools.local_workspace.workspace.actions.create_workspace import ( + CreateWorkspaceResponse, +) AGENT_BACKSTORY_TMPL = """ @@ -45,10 +42,17 @@ we recommend adding a print("Script completed successfully, no errors.") command at the end of the file, so that you can be sure that the script indeed ran fine all the way through. 6. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it! - 7. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. - 8. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. - 9. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file. - 10. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it. + 7. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, + don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker. + 8. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like + to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. + Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command. + 9. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). + The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, + so they might change the current open file. + 10. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. + Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another + command to fix it. 11. When you finish working on the issue, use submit patch tool to submit your patch. 12. SUBMIT THE PATCH TO THE REVIEWER AGENT AGAIN AND ASK THEM TO REVIEW THE PATCH AND SUBMIT IT ONLY IF THEY APPROVE IT. """ @@ -123,10 +127,14 @@ def __init__(self, args: CoderAgentArgs): # initialize composio toolset tool_set = ComposioToolSet() - self.composio_toolset = tool_set.get_tools(apps=[App.LOCALWORKSPACE, - App.CMDMANAGERTOOL, - App.HISTORYKEEPER, - App.SUBMITPATCHTOOL]) + self.composio_toolset = tool_set.get_tools( + apps=[ + App.LOCALWORKSPACE, + App.CMDMANAGERTOOL, + App.HISTORYKEEPER, + App.SUBMITPATCHTOOL, + ] + ) composio_client = Composio() self.entity = composio_client.get_entity("swe-agent") # initialize composio client @@ -210,11 +218,18 @@ def get_llm(self): def run(self): llm = self.get_llm() - workspace_create_resp: CreateWorkspaceResponse = self.entity.execute(Action.LOCALWORKSPACE_CREATEWORKSPACEACTION, {}) + workspace_create_resp: CreateWorkspaceResponse = self.entity.execute( + Action.LOCALWORKSPACE_CREATEWORKSPACEACTION, {} + ) workspace_id = workspace_create_resp.workspace_id logger.info(f"workspace is created, workspace-id is: {workspace_id}") - git_clone_response = self.entity.execute(Action.CMDMANAGERTOOL_GITHUBCLONECMD, - params={"workspace_id": workspace_id, "repo_name": self.issue_config.repo_name}) + git_clone_response = self.entity.execute( + Action.CMDMANAGERTOOL_GITHUBCLONECMD, + params={ + "workspace_id": workspace_id, + "repo_name": self.issue_config.repo_name, + }, + ) issue_added_instruction = self.issue_description_tmpl.format( issue=self.issue_config.issue_desc, issue_id=self.issue_config.issue_id ) @@ -222,7 +237,7 @@ def run(self): workspace_id=workspace_id, repo_name=self.repo_name, repo_name_dir="/" + self.repo_name.split("/")[-1].strip(), - base_commit=self.issue_config.base_commit_id + base_commit=self.issue_config.base_commit_id, ) logger.info(f"git clone response: {git_clone_response}") @@ -248,14 +263,14 @@ def run(self): role="You are the best reviewer. You think carefully and step by step take action.", goal="Review the patch and make sure it fixes the issue.", backstory="An AI Agent tries to solve an issue and submits a patch to the repo. " - "You can assume the AI agent operates as a junior developer and has limited knowledge of the codebase." - "It's your job to review the patch and make sure it fixes the issue." - "The patch might be incomplete. In that case point out the missing parts and ask the AI agent to add them." - "The patch might have some compilation issues/typo. Point out those and ask the AI agent to fix them." - "The patch might have some logical issues. Point out those and ask the AI agent to fix them." - "Once the patch is ready, approve it and ask the AI agent to submit it." - "It is fine to have multiple iterations of the review. Keep iterating until the patch is ready to be submitted." - "The are the best reviewer. You think carefully and step by step take action.", + "You can assume the AI agent operates as a junior developer and has limited knowledge of the codebase." + "It's your job to review the patch and make sure it fixes the issue." + "The patch might be incomplete. In that case point out the missing parts and ask the AI agent to add them." + "The patch might have some compilation issues/typo. Point out those and ask the AI agent to fix them." + "The patch might have some logical issues. Point out those and ask the AI agent to fix them." + "Once the patch is ready, approve it and ask the AI agent to submit it." + "It is fine to have multiple iterations of the review. Keep iterating until the patch is ready to be submitted." + "The are the best reviewer. You think carefully and step by step take action.", verbose=True, llm=llm, tools=self.composio_toolset, @@ -307,5 +322,4 @@ def run(self): ) c_agent = CoderAgent(args) - c_agent.run() diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py b/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py index 5ba054d9e..adfded58f 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py @@ -35,6 +35,7 @@ class BaseRequest(BaseModel): class BaseResponse(BaseModel): class Config: arbitrary_types_allowed = True + output: any = Field(..., description="output of the command") return_code: int = Field( ..., description="Any output or errors that occurred during the file edit." diff --git a/composio/local_tools/local_workspace/cmd_manager/tool.py b/composio/local_tools/local_workspace/cmd_manager/tool.py index 6a035e5b6..b51d44b4f 100644 --- a/composio/local_tools/local_workspace/cmd_manager/tool.py +++ b/composio/local_tools/local_workspace/cmd_manager/tool.py @@ -6,6 +6,7 @@ EditFile, FindFileCmd, GetCurrentDirCmd, + GitRepoTree, GithubCloneCmd, GoToLineNumInOpenFile, OpenFile, @@ -13,7 +14,6 @@ Scroll, SearchDirCmd, SearchFileCmd, - GitRepoTree ) from composio.local_tools.local_workspace.commons import ( HistoryProcessor, From 971097e84260ba805d83f575282852b695e041a9 Mon Sep 17 00:00:00 2001 From: shubhra Date: Wed, 19 Jun 2024 13:20:15 +0530 Subject: [PATCH 10/12] balck fix --- composio/storage/__init__.py | 1 + tests/test_cli/test_connections.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/composio/storage/__init__.py b/composio/storage/__init__.py index 02b69ed20..d80425fee 100644 --- a/composio/storage/__init__.py +++ b/composio/storage/__init__.py @@ -1,4 +1,5 @@ """ Composio user account storage helpers. """ + from .base import LocalStorage diff --git a/tests/test_cli/test_connections.py b/tests/test_cli/test_connections.py index ff9ad4d63..360d8ffef 100644 --- a/tests/test_cli/test_connections.py +++ b/tests/test_cli/test_connections.py @@ -2,7 +2,6 @@ Test connections command group. """ - from tests.test_cli.base import BaseCliTest From 9fdbcdc54971ea16a9005c174306d863e8567308 Mon Sep 17 00:00:00 2001 From: shubhra Date: Wed, 19 Jun 2024 13:23:51 +0530 Subject: [PATCH 11/12] balck fix --- coders/composio_coders/benchmark/run_evaluation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/coders/composio_coders/benchmark/run_evaluation.py b/coders/composio_coders/benchmark/run_evaluation.py index 638d1d464..dc7df1f73 100644 --- a/coders/composio_coders/benchmark/run_evaluation.py +++ b/coders/composio_coders/benchmark/run_evaluation.py @@ -89,7 +89,6 @@ def run(): print("--------------------------------------------------") model_env_config = { - KEY_API_KEY: "test-key", "azure_endpoint": "test-endpoint", "model_env": "azure", From 66a3af42fedfa84cc5aa45a153bcfbe409c62a0b Mon Sep 17 00:00:00 2001 From: Karan Vaidya Date: Wed, 19 Jun 2024 15:40:29 +0530 Subject: [PATCH 12/12] Fix lint --- .gitignore | 3 ++- coders/composio_coders/swe.py | 4 ++-- .../local_workspace/cmd_manager/actions/base_class.py | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 21b8b4c59..532721fd8 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ temp .test_results .trunk refactor_debug.ipynb - +**/coder_agent_logs_* +**/.composio.coder.* diff --git a/coders/composio_coders/swe.py b/coders/composio_coders/swe.py index 86c7fa70d..0ce161f96 100644 --- a/coders/composio_coders/swe.py +++ b/coders/composio_coders/swe.py @@ -222,7 +222,7 @@ def run(self): Action.LOCALWORKSPACE_CREATEWORKSPACEACTION, {} ) workspace_id = workspace_create_resp.workspace_id - logger.info(f"workspace is created, workspace-id is: {workspace_id}") + logger.info("workspace is created, workspace-id is: %s", workspace_id) git_clone_response = self.entity.execute( Action.CMDMANAGERTOOL_GITHUBCLONECMD, params={ @@ -239,7 +239,7 @@ def run(self): repo_name_dir="/" + self.repo_name.split("/")[-1].strip(), base_commit=self.issue_config.base_commit_id, ) - logger.info(f"git clone response: {git_clone_response}") + logger.info("git clone response: %s", git_clone_response) swe_agent = Agent( role=self.agent_role, diff --git a/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py b/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py index adfded58f..ae6aa12ce 100644 --- a/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py +++ b/composio/local_tools/local_workspace/cmd_manager/actions/base_class.py @@ -1,6 +1,6 @@ +import typing as t from abc import ABC, abstractmethod from pathlib import Path -from typing import Optional from pydantic import BaseModel, Field @@ -36,7 +36,7 @@ class BaseResponse(BaseModel): class Config: arbitrary_types_allowed = True - output: any = Field(..., description="output of the command") + output: t.Any = Field(..., description="output of the command") return_code: int = Field( ..., description="Any output or errors that occurred during the file edit." ) @@ -53,8 +53,8 @@ class BaseAction(Action[BaseRequest, BaseResponse], ABC): _tool_name = "cmdmanagertool" script_file = "" command = "" - workspace_factory: Optional[WorkspaceManagerFactory] = None - history_processor: Optional[HistoryProcessor] = None + workspace_factory: t.Optional[WorkspaceManagerFactory] = None + history_processor: t.Optional[HistoryProcessor] = None def __init__(self): super().__init__()