From a10b9734944db54c55c4befd3c9b7b56fdddab46 Mon Sep 17 00:00:00 2001 From: liangxinbing <1580466765@qq.com> Date: Thu, 27 Mar 2025 08:55:01 +0800 Subject: [PATCH] Fix bug of SWEAgent --- app/agent/swe.py | 17 +++-------------- app/prompt/swe.py | 6 ------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/app/agent/swe.py b/app/agent/swe.py index 0ac1b36..9044204 100644 --- a/app/agent/swe.py +++ b/app/agent/swe.py @@ -3,7 +3,7 @@ from typing import List from pydantic import Field from app.agent.toolcall import ToolCallAgent -from app.prompt.swe import NEXT_STEP_TEMPLATE, SYSTEM_PROMPT +from app.prompt.swe import SYSTEM_PROMPT from app.tool import Bash, StrReplaceEditor, Terminate, ToolCollection @@ -14,25 +14,14 @@ class SWEAgent(ToolCallAgent): description: str = "an autonomous AI programmer that interacts directly with the computer to solve tasks." system_prompt: str = SYSTEM_PROMPT - next_step_prompt: str = NEXT_STEP_TEMPLATE + next_step_prompt: str = "" available_tools: ToolCollection = ToolCollection( Bash(), StrReplaceEditor(), Terminate() ) special_tool_names: List[str] = Field(default_factory=lambda: [Terminate().name]) - max_steps: int = 30 + max_steps: int = 20 bash: Bash = Field(default_factory=Bash) working_dir: str = "." - - async def think(self) -> bool: - """Process current state and decide next action""" - # Update working directory - result = await self.bash.execute("pwd") - self.working_dir = result.output - self.next_step_prompt = self.next_step_prompt.format( - current_dir=self.working_dir - ) - - return await super().think() diff --git a/app/prompt/swe.py b/app/prompt/swe.py index a496988..389e74b 100644 --- a/app/prompt/swe.py +++ b/app/prompt/swe.py @@ -20,9 +20,3 @@ Remember, you should always include a _SINGLE_ tool call/function call and then If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first tool call, and then after receiving a response you'll be able to issue the second tool call. Note that the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them. """ - -NEXT_STEP_TEMPLATE = """{{observation}} -(Open file: {{open_file}}) -(Current directory: {{working_dir}}) -bash-$ -"""