From b3dab8b4251ca0aa45ca74f52126c9edb382bc16 Mon Sep 17 00:00:00 2001 From: seeker Date: Wed, 10 Jul 2024 14:49:48 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=A7=BB=E9=99=A4=20swe=20agent=20wi?= =?UTF-8?q?ndow=20=E7=9A=84=E5=AE=9E=E6=97=B6=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E4=B8=BA=20100=20=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/prompts/di/swe_agent.py | 2 +- metagpt/roles/di/swe_agent.py | 22 ++-------------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/metagpt/prompts/di/swe_agent.py b/metagpt/prompts/di/swe_agent.py index ed1f8a011..a1c491210 100644 --- a/metagpt/prompts/di/swe_agent.py +++ b/metagpt/prompts/di/swe_agent.py @@ -7,7 +7,7 @@ https://github.com/princeton-nlp/SWE-agent/tree/main/config/configs SWE_AGENT_SYSTEM_TEMPLATE = """ SETTING: You are an autonomous programmer, and you're working directly in the environment line with a special interface. -The special interface consists of a file editor that shows you {WINDOW} lines of a file at a time. +The special interface consists of a file editor that shows you 100 lines of a file at a time. Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION. Pay attention to the original indentation when replacing the function. If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run. diff --git a/metagpt/roles/di/swe_agent.py b/metagpt/roles/di/swe_agent.py index d0458a22f..7150c0a67 100644 --- a/metagpt/roles/di/swe_agent.py +++ b/metagpt/roles/di/swe_agent.py @@ -1,5 +1,4 @@ import json -import os from pydantic import Field @@ -18,9 +17,7 @@ class SWEAgent(RoleZero): name: str = "Swen" profile: str = "Issue Solver" goal: str = "Resolve GitHub issue" - _bash_window_size: int = 100 - _system_msg: str = SWE_AGENT_SYSTEM_TEMPLATE - system_msg: list[str] = [_system_msg.format(WINDOW=_bash_window_size)] + system_msg: str = [SWE_AGENT_SYSTEM_TEMPLATE] _instruction: str = NEXT_STEP_TEMPLATE tools: list[str] = [ "Bash", @@ -35,7 +32,6 @@ class SWEAgent(RoleZero): run_eval: bool = False async def _think(self) -> bool: - self._update_system_msg() self._format_instruction() res = await super()._think() if self.run_eval: @@ -51,17 +47,6 @@ class SWEAgent(RoleZero): } ) - def _update_system_msg(self): - """ - Sets the system message for the SWE agent. - - Sets the `_bash_window_size` from the environment variable `WINDOW` if it exists. - Formats the `_system_msg` template with the current `_bash_window_size`. - """ - if os.getenv("WINDOW"): - self._bash_window_size = int(os.getenv("WINDOW")) - self.system_msg = [self._system_msg.format(WINDOW=self._bash_window_size)] - def _format_instruction(self): """ Formats the instruction message for the SWE agent. @@ -71,10 +56,7 @@ class SWEAgent(RoleZero): """ state_output = self.terminal.run("state") bash_state = json.loads(state_output) - - self.instruction = self._instruction.format( - WINDOW=self._bash_window_size, examples=MINIMAL_EXAMPLE, **bash_state - ).strip() + self.instruction = self._instruction.format(**bash_state).strip() return self.instruction