update SWEAgent

This commit is contained in:
liangxinbing 2025-03-20 09:02:50 +08:00
parent e5808d1a90
commit 6fa0b1be95
2 changed files with 5 additions and 4 deletions

View File

@ -29,7 +29,8 @@ class SWEAgent(ToolCallAgent):
async def think(self) -> bool: async def think(self) -> bool:
"""Process current state and decide next action""" """Process current state and decide next action"""
# Update working directory # Update working directory
self.working_dir = await self.bash.execute("pwd") result = await self.bash.execute("pwd")
self.working_dir = result.output
self.next_step_prompt = self.next_step_prompt.format( self.next_step_prompt = self.next_step_prompt.format(
current_dir=self.working_dir current_dir=self.working_dir
) )

View File

@ -3,7 +3,7 @@ import os
from typing import Optional from typing import Optional
from app.exceptions import ToolError from app.exceptions import ToolError
from app.tool.base import BaseTool, CLIResult, ToolResult from app.tool.base import BaseTool, CLIResult
_BASH_DESCRIPTION = """Execute a bash command in the terminal. _BASH_DESCRIPTION = """Execute a bash command in the terminal.
@ -57,7 +57,7 @@ class _BashSession:
if not self._started: if not self._started:
raise ToolError("Session has not started.") raise ToolError("Session has not started.")
if self._process.returncode is not None: if self._process.returncode is not None:
return ToolResult( return CLIResult(
system="tool must be restarted", system="tool must be restarted",
error=f"bash has exited with returncode {self._process.returncode}", error=f"bash has exited with returncode {self._process.returncode}",
) )
@ -140,7 +140,7 @@ class Bash(BaseTool):
self._session = _BashSession() self._session = _BashSession()
await self._session.start() await self._session.start()
return ToolResult(system="tool has been restarted.") return CLIResult(system="tool has been restarted.")
if self._session is None: if self._session is None:
self._session = _BashSession() self._session = _BashSession()