diff --git a/opendevin/action/fileop.py b/opendevin/action/fileop.py index 262151374270..b3ee9a91d338 100644 --- a/opendevin/action/fileop.py +++ b/opendevin/action/fileop.py @@ -17,10 +17,9 @@ def resolve_path(base_path, file_path): @dataclass class FileReadAction(ExecutableAction): path: str - base_path: str = "" - def run(self, *args, **kwargs) -> FileReadObservation: - path = resolve_path(self.base_path, self.path) + def run(self, controller) -> FileReadObservation: + path = resolve_path(controller.workdir, self.path) with open(path, 'r', encoding='utf-8') as file: return FileReadObservation( path=path, @@ -35,10 +34,9 @@ def message(self) -> str: class FileWriteAction(ExecutableAction): path: str contents: str - base_path: str = "" - def run(self, *args, **kwargs) -> FileWriteObservation: - path = resolve_path(self.base_path, self.path) + def run(self, controller) -> FileWriteObservation: + path = resolve_path(controller.workdir, self.path) with open(path, 'w', encoding='utf-8') as file: file.write(self.contents) return FileWriteObservation(content="", path=self.path) diff --git a/opendevin/controller/agent_controller.py b/opendevin/controller/agent_controller.py index aaa0fcd90acd..8262bc2d5cc2 100644 --- a/opendevin/controller/agent_controller.py +++ b/opendevin/controller/agent_controller.py @@ -7,8 +7,6 @@ from opendevin.action import ( Action, NullAction, - FileReadAction, - FileWriteAction, AgentFinishAction, ) from opendevin.observation import ( @@ -97,12 +95,7 @@ async def step(self, i: int): if isinstance(action, AgentFinishAction): print_with_indent("\nFINISHED") return True - if isinstance(action, (FileReadAction, FileWriteAction)): - action_cls = action.__class__ - _kwargs = action.__dict__ - _kwargs["base_path"] = self.workdir - action = action_cls(**_kwargs) - print(action, flush=True) + if action.executable: try: observation = action.run(self)