From ca0cb7639f7d764044bd3df380f68fe90b03eaca Mon Sep 17 00:00:00 2001 From: seeker Date: Wed, 3 Jul 2024 22:37:17 +0800 Subject: [PATCH] update: SWE Agent --- metagpt/const.py | 2 ++ metagpt/roles/di/swe.py | 2 +- tests/metagpt/roles/di/run_swe_new.py | 11 +++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/metagpt/const.py b/metagpt/const.py index 94d22bc70..6a0e2c4bb 100644 --- a/metagpt/const.py +++ b/metagpt/const.py @@ -150,5 +150,7 @@ METAGPT_REPORTER_DEFAULT_URL = os.environ.get("METAGPT_REPORTER_URL", "") # Metadata defines AGENT = "agent" SWE_WORKSPACE_ROOT = Path("/tmp/swe_workspace") +if not SWE_WORKSPACE_ROOT.exists(): + SWE_WORKSPACE_ROOT.mkdir(parents=True) # SWE agent SWE_SETUP_PATH = METAGPT_ROOT / "metagpt/tools/swe_agent_commands/setup_default.sh" diff --git a/metagpt/roles/di/swe.py b/metagpt/roles/di/swe.py index 915d186b4..dde686e6a 100644 --- a/metagpt/roles/di/swe.py +++ b/metagpt/roles/di/swe.py @@ -25,7 +25,7 @@ class SWE(RoleZero): tools: list[str] = ["Bash", "Browser:goto,scroll"] terminal: Bash = Field(default_factory=Bash, exclude=True) output_diff: str = "" - max_react_loop: int = 30 + max_react_loop: int = 40 async def _think(self) -> bool: self._set_system_msg() diff --git a/tests/metagpt/roles/di/run_swe_new.py b/tests/metagpt/roles/di/run_swe_new.py index 94ef1e644..8ed1e9107 100644 --- a/tests/metagpt/roles/di/run_swe_new.py +++ b/tests/metagpt/roles/di/run_swe_new.py @@ -7,14 +7,14 @@ FIX_ISSUE1 = """ Write a fix for this issue: https://github.com/langchain-ai/langchain/issues/20453, you can fix it on this repo https://github.com/garylin2099/langchain, """ - -"checkout a branch named test-fix, commit your changes, push, and create a PR to the master branch of https://github.com/iorisa/langchain" +# + "checkout a branch named test-fix, commit your changes, push, and create a PR to the master branch of https://github.com/iorisa/langchain" FIX_ISSUE2 = """ Write a fix for this issue https://github.com/geekan/MetaGPT/issues/1275. You can fix it on the v0.8-release branch of this repo https://github.com/garylin2099/MetaGPT, -during fixing, checkout a branch named test-fix-1275, commit your changes, push, and create a PR to the v0.8-release branch of https://github.com/garylin2099/MetaGPT """ +# + "during fixing, checkout a branch named test-fix-1275, commit your changes, push, and create a PR to the v0.8-release branch of https://github.com/garylin2099/MetaGPT" + FIX_ISSUE3 = """ Write a fix for this issue https://github.com/geekan/MetaGPT/issues/1262. You can fix it on this repo https://github.com/garylin2099/MetaGPT, @@ -30,7 +30,10 @@ if __name__ == "__main__": swe_agent = SWE() logger.info("**** Starting run ****") user_requirement_and_issue = ( - FIX_ISSUE1 + # FIX_ISSUE1 + # FIX_ISSUE2 + # FIX_ISSUE3 + FIX_ISSUE_SIMPLE + """Because the environment is not available, you DO NOT need to run and modify any existing test case files or add new test case files to ensure that the bug is fixed.""" ) asyncio.run(swe_agent.run(user_requirement_and_issue))